From 577dd2b076331fd69a0836a91a7314290de1c2bc Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Thu, 1 Sep 2011 00:01:53 +0200 Subject: [PATCH] dom0: when cleaning up network devices, wait for actual device destroy Otherwise subsequent network-attach will not be noticed by frontend driver. --- dom0/qvm-core/qubes.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index aa050227..a1c62a8e 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -609,6 +609,15 @@ class QubesVm(object): # Don't check retcode - it always will fail when backend domain is down subprocess.call(["/usr/sbin/xl", "network-detach", self.name, m.group(1)], stderr=subprocess.PIPE) + # Wait for device destroy + tries = 0 + path = "'{0}/device/vif/0/state".format(xs.get_domain_path(self.xid)) + while xs.read(path): + time.sleep(0.1) + tries += 1 + if tries > 10: + # timeout + break def create_xenstore_entries(self, xid): if dry_run: