libxl_pci: Don't hold QMP connection while waiting
authorAnthony PERARD <anthony.perard@citrix.com>
Thu, 31 Oct 2019 12:17:27 +0000 (12:17 +0000)
committerWei Liu <wl@xen.org>
Mon, 18 Nov 2019 23:01:10 +0000 (23:01 +0000)
commite28eed55a41e4d70c3bd7b0efb1668dd93d8bed6
tree95a044833e07698dee7b314d65b1e722c39d539a
parent5a870b02cb803283a28f7916b68fe785f39e81f0
libxl_pci: Don't hold QMP connection while waiting

After sending the 'device_del' command for a PCI passthrough device,
we wait until QEMU has effectively deleted the device, this involves
executing more QMP commands. While waiting, libxl hold the connection.

It isn't necessary to hold the connection and it prevents others from
making progress, so this patch releases the QMP connection.

For background:
    e.g., when a guest is created with several pci passthrough
    attached, on `xl destroy` all the devices needs to be detach, and
    this is usually what happens:
- 'device_del' called for the 1st pci device
- 'query-pci' checking if pci still there, it is
- wait 1s
- 'query-pci' checking again, and it's gone
-> now the same can be done for the second pci device, so
plenty of waiting on others when pci detach can be done in
parallel.

    On shutdown, libxl usually keeps waiting because QEMU never
    releases the device because the guest kernel never responds QEMU's
    unplug queries. So detaching of the 1st device waits until a
    timeout stops it, and since the same timeout is setup at the same
    time for the other devices to detach, the 'device_del' command is
    never sent for those.

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_pci.c