core: detach connected VMs when shutting down NetVM
This is workaround for missing libxl/libvirt functionality: QubesOS/qubes-issues#1426 Also it should improve system shutdown time, as this is the situation where all the VMs are shutting down simultaneously. Fixes QubesOS/qubes-issues#1425
This commit is contained in:
parent
46cbb4a133
commit
7359e394bc
@ -23,7 +23,7 @@
|
|||||||
#
|
#
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
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 QubesVm,register_qubes_vm_class,vmm,dry_run
|
||||||
from qubes.qubes import defaults,system_path,vm_files
|
from qubes.qubes import defaults,system_path,vm_files
|
||||||
@ -153,6 +153,18 @@ class QubesNetVm(QubesVm):
|
|||||||
if connected_vms and not force:
|
if connected_vms and not force:
|
||||||
raise QubesException("There are other VMs connected to this VM: " + str([vm.name for vm in connected_vms]))
|
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)
|
super(QubesNetVm, self).shutdown(force=force)
|
||||||
|
|
||||||
def add_external_ip_permission(self, xid):
|
def add_external_ip_permission(self, xid):
|
||||||
|
Loading…
Reference in New Issue
Block a user