From a6a7efc9a711db4016a037c8ee84c12e41eab8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 29 Jan 2018 23:06:21 +0100 Subject: [PATCH] vm/mix/net: fix handling network detach/attach on VM startup - catch both QubesException and libvirtError - do not kill starting VM just because an error while connecting _other_ VMs to it - try to detach network first (and do not abort on error) - if libvirt/libxl will manage to cleanup stale interface this way, the attach operation below may succeed. Fixes QubesOS/qubes-issues#3163 --- qubes/vm/mix/net.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/qubes/vm/mix/net.py b/qubes/vm/mix/net.py index 351618ae..85d06dd2 100644 --- a/qubes/vm/mix/net.py +++ b/qubes/vm/mix/net.py @@ -262,15 +262,13 @@ class NetVMMixin(qubes.events.Emitter): vm.log.info('Attaching network') try: - # 1426 - vm.run('modprobe -r xen-netfront xennet', - user='root', wait=True) - except: # pylint: disable=bare-except - pass + vm.detach_network() + except (qubes.exc.QubesException, libvirt.libvirtError): + vm.log.warning('Cannot detach old network', exc_info=1) try: vm.attach_network() - except qubes.exc.QubesException: + except (qubes.exc.QubesException, libvirt.libvirtError): vm.log.warning('Cannot attach network', exc_info=1) @qubes.events.handler('domain-pre-shutdown')