dom0: improve vif cleanup
Just remove dead devices from xenstore, there is no point in waiting for its shutdown (which 'xl' does) as backend domain is dead.
This commit is contained in:
parent
600877b830
commit
053944470c
@ -603,28 +603,17 @@ class QubesVm(object):
|
|||||||
if not self.is_running():
|
if not self.is_running():
|
||||||
return
|
return
|
||||||
|
|
||||||
p = subprocess.Popen (["/usr/sbin/xl", "network-list", self.name],
|
dev_basepath = '/local/domain/%d/device/vif' % self.xid
|
||||||
stdout=subprocess.PIPE)
|
for dev in xs.list('', dev_basepath):
|
||||||
result = p.communicate()
|
# check if backend domain is alive
|
||||||
for line in result[0].split('\n'):
|
backend_xid = int(xs.read('', '%s/%s/backend-id' % (dev_basepath, dev)))
|
||||||
m = re.match(r"^(\d+)\s*(\d+)", line)
|
if xl_ctx.domid_to_name(backend_xid) is not None:
|
||||||
if m:
|
# check if device is still active
|
||||||
retcode = subprocess.call(["/usr/sbin/xl", "list", m.group(2)],
|
if xs.read('', '%s/%s/state' % (dev_basepath, dev)) == '4':
|
||||||
stderr=subprocess.PIPE)
|
continue
|
||||||
if retcode != 0:
|
# remove dead device
|
||||||
# Don't check retcode - it always will fail when backend domain is down
|
xs.rm('', '%s/%s' % (dev_basepath, dev))
|
||||||
subprocess.call(["/usr/sbin/xl",
|
|
||||||
"network-detach", self.name, m.group(1)], stderr=subprocess.PIPE)
|
|
||||||
# Wait for device destroy (in most cases just ensure that device already is removed)
|
|
||||||
tries = 0
|
|
||||||
path = "{0}/device/vif/0/state".format(xs.get_domain_path(self.xid))
|
|
||||||
while xs.read('', path) is not None:
|
|
||||||
time.sleep(0.1)
|
|
||||||
tries += 1
|
|
||||||
if tries > 10:
|
|
||||||
# timeout
|
|
||||||
break
|
|
||||||
|
|
||||||
def create_xenstore_entries(self, xid = None):
|
def create_xenstore_entries(self, xid = None):
|
||||||
if dry_run:
|
if dry_run:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user