libxl_pci: Fix guest shutdown with PCI PT attached
authorAnthony PERARD <anthony.perard@citrix.com>
Mon, 30 Sep 2019 16:39:40 +0000 (17:39 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Fri, 4 Oct 2019 15:55:02 +0000 (16:55 +0100)
commitc9cccbdff8b5fd341e0aca03c303ed30e8b9840e
tree8bfa5226db0f21a3c879468fe57cbf931bdca92c
parent7988902b933cecb0e2459a11a4813a8f5cb0941b
libxl_pci: Fix guest shutdown with PCI PT attached

Before the problematic commit, libxl used to ignore error when
destroying (force == true) a passthrough device. If the DM failed to
detach the pci device within the allowed time, the timed out error
raised skip part of pci_remove_*, but also raise the error up to the
caller of libxl__device_pci_destroy_all, libxl__destroy_domid, and
thus the destruction of the domain fails.

When a *pci_destroy* function is called (so we have force=true), error
should mostly be ignored. If the DM didn't confirmed that the device
is removed, we will print a warning and keep going if force=true.
The patch reorder the functions so that pci_remove_timeout() calls
pci_remove_detatched() like it's done when DM calls are successful.

We also clean the QMP states and associated timeouts earlier, as soon
as they are not needed anymore.

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