libxl_qmp: Have a lock for QMP socket access
authorAnthony PERARD <anthony.perard@citrix.com>
Mon, 18 Nov 2019 17:13:08 +0000 (17:13 +0000)
committerWei Liu <wl@xen.org>
Mon, 18 Nov 2019 22:59:51 +0000 (22:59 +0000)
commit5a870b02cb803283a28f7916b68fe785f39e81f0
tree394dba54251d1b4947b8f8bd0c2c43116f274cd1
parentf3e4fb552a1be6b2a77c6730b3bffe25ffd8fb00
libxl_qmp: Have a lock for QMP socket access

This patch workaround the fact that it's not possible to connect
multiple time to a single QMP socket. QEMU listen on the socket with
a backlog value of 1, which mean that on Linux when concurrent thread
call connect() on the socket, they get EAGAIN.

Background:
    This happens when attempting to create a guest with multiple
    pci devices passthrough, libxl creates one connection per device to
    attach and execute connect() on all at once before any single
    connection has finished.

To work around this, we use a new lock.

Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
tools/libxl/libxl_internal.c
tools/libxl/libxl_internal.h
tools/libxl/libxl_qmp.c