ia64/xen-unstable

changeset 19554:b920a2f799d9

xend: clean up qemu-dm related items on domain destroy

Some qemu-dm related stuffs might be left behind after the domain is
destroyed.
- xenstore entry, /local/domain/0/device-model/<domid>
- named pipes, /var/run/tap/qemu-{read,write}-<domid>

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Apr 17 13:04:47 2009 +0100 (2009-04-17)
parents 655dc3bc1d8e
children 150662e5adfc
files tools/python/xen/xend/image.py
line diff
     1.1 --- a/tools/python/xen/xend/image.py	Thu Apr 16 11:54:06 2009 +0100
     1.2 +++ b/tools/python/xen/xend/image.py	Fri Apr 17 13:04:47 2009 +0100
     1.3 @@ -561,9 +561,9 @@ class ImageHandler:
     1.4      def destroyDeviceModel(self):
     1.5          if self.device_model is None:
     1.6              return
     1.7 -        if self.pid:
     1.8 -            self.sentinel_lock.acquire()
     1.9 -            try:
    1.10 +        self.sentinel_lock.acquire()
    1.11 +        try:
    1.12 +            if self.pid:
    1.13                  try:
    1.14                      os.kill(self.pid, signal.SIGHUP)
    1.15                  except OSError, exn:
    1.16 @@ -592,22 +592,22 @@ class ImageHandler:
    1.17                      except OSError:
    1.18                          # This happens if the process doesn't exist.
    1.19                          pass
    1.20 -                state = xstransact.Remove("/local/domain/0/device-model/%i"
    1.21 -                                          % self.vm.getDomid())
    1.22 -            finally:
    1.23 -                self.pid = None
    1.24 -                self.sentinel_lock.release()
    1.25 +        finally:
    1.26 +            self.pid = None
    1.27 +            self.sentinel_lock.release()
    1.28              
    1.29 -            try:
    1.30 -                os.unlink('/var/run/tap/qemu-read-%d' % self.vm.getDomid())
    1.31 -                os.unlink('/var/run/tap/qemu-write-%d' % self.vm.getDomid())
    1.32 -            except:
    1.33 -                pass
    1.34 -            try:
    1.35 -                del sentinel_fifos_inuse[self.sentinel_path_fifo]
    1.36 -                os.unlink(self.sentinel_path_fifo)
    1.37 -            except:
    1.38 -                pass
    1.39 +        state = xstransact.Remove("/local/domain/0/device-model/%i"
    1.40 +                                  % self.vm.getDomid())
    1.41 +        try:
    1.42 +            os.unlink('/var/run/tap/qemu-read-%d' % self.vm.getDomid())
    1.43 +            os.unlink('/var/run/tap/qemu-write-%d' % self.vm.getDomid())
    1.44 +        except:
    1.45 +            pass
    1.46 +        try:
    1.47 +            del sentinel_fifos_inuse[self.sentinel_path_fifo]
    1.48 +            os.unlink(self.sentinel_path_fifo)
    1.49 +        except:
    1.50 +            pass
    1.51  
    1.52      def setCpuid(self):
    1.53          xc.domain_set_policy_cpuid(self.vm.getDomid())