From 2658c9a6e69ed272f49e71e04b5b342ea2dc388f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 6 Dec 2015 14:31:43 +0100 Subject: [PATCH] core: detach PCI devices before shutting down VM When VM is shutting down it doesn't disconnect PCI frontend (?), so when VM is destroyed it ends up in timeouts in PCI backend shutdown (which can't communicate with frontend at that stage). Prevent this by detaching PCI devices while VM is still running. Fixes QubesOS/qubes-issues#1494 Fixes QubesOS/qubes-issues#1425 --- core-modules/000QubesVm.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index 99e94740..4e326080 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -1948,6 +1948,14 @@ class QubesVm(object): if not self.is_running(): raise QubesException ("VM already stopped!") + # try to gracefully detach PCI devices before shutdown, to mitigate + # timeouts on forcible detach at domain destroy; if that fails, too bad + try: + for pcidev in self.pcidevs: + self.libvirt_domain.detachDevice(self._format_pci_dev(pcidev)) + except libvirt.libvirtError: + pass + self.libvirt_domain.shutdown() def force_shutdown(self, xid = None):