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
Этот коммит содержится в:
Marek Marczykowski-Górecki 2015-11-14 23:36:22 +01:00
родитель 46cbb4a133
Коммит 7359e394bc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 063938BA42CFA724

Просмотреть файл

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