diff --git a/core-modules/005QubesNetVm.py b/core-modules/005QubesNetVm.py index c721bbab..33934f4b 100644 --- a/core-modules/005QubesNetVm.py +++ b/core-modules/005QubesNetVm.py @@ -23,7 +23,7 @@ # import sys import os.path -import xen.lowlevel.xs +import libvirt from qubes.qubes import QubesVm,register_qubes_vm_class,vmm,dry_run from qubes.qubes import defaults,system_path,vm_files @@ -153,6 +153,18 @@ class QubesNetVm(QubesVm): if connected_vms and not force: raise QubesException("There are other VMs connected to this VM: " + str([vm.name for vm in connected_vms])) + # detach network interfaces of connected VMs before shutting down, + # otherwise libvirt will not notice it and will try to detach them + # again (which would fail, obviously). + # This code can be removed when #1426 got implemented + for vm in self.connected_vms.values(): + if vm.is_running(): + try: + vm.detach_network() + except (QubesException, libvirt.libvirtError): + # ignore errors + pass + super(QubesNetVm, self).shutdown(force=force) def add_external_ip_permission(self, xid):