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
This commit is contained in:
Marek Marczykowski-Górecki 2015-12-06 14:31:43 +01:00
parent 9f04743388
commit 2658c9a6e6
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -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):