ia64/xen-unstable

changeset 7241:0bc466c25560

Rename all dying domains to be prefixed with Zombie. This allows a new domain
to be created with the same name, fixing the race condition inside XendDomain
that caused bug #278.

Move the state_set(TERMINATED) call onto the end of cleanupDomain rather than
destroyDomain, so that this flag is set when XendDomain cleans up a domain
that was killed without going through Xend.

Remove is_terminated, as this check is no longer necessary, since we are using
Zombie prefixes instead.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Thu Oct 06 11:09:14 2005 +0100 (2005-10-06)
parents 1cfe0875658d
children 4ab4f023a6ce
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Oct 06 11:04:49 2005 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Oct 06 11:09:14 2005 +0100
     1.3 @@ -97,6 +97,7 @@ SHUTDOWN_TIMEOUT = 30
     1.4  DOMROOT = '/local/domain/'
     1.5  VMROOT  = '/vm/'
     1.6  
     1.7 +ZOMBIE_PREFIX = 'Zombie-'
     1.8  
     1.9  xc = xen.lowlevel.xc.new()
    1.10  xroot = XendRoot.instance()
    1.11 @@ -997,8 +998,6 @@ class XendDomainInfo:
    1.12          dominfo = domain_by_name(name)
    1.13          if not dominfo:
    1.14              return
    1.15 -        if dominfo.is_terminated():
    1.16 -            return
    1.17          if self.domid is None:
    1.18              raise VmError("VM name '%s' already in use by domain %d" %
    1.19                            (name, dominfo.domid))
    1.20 @@ -1100,6 +1099,14 @@ class XendDomainInfo:
    1.21          except:
    1.22              log.exception("Removing domain path failed.")
    1.23  
    1.24 +        try:
    1.25 +            if not self.info['name'].startswith(ZOMBIE_PREFIX):
    1.26 +                self.info['name'] = self.generateZombieName()
    1.27 +        except:
    1.28 +            log.exception("Renaming Zombie failed.")
    1.29 +
    1.30 +        self.state_set(STATE_VM_TERMINATED)
    1.31 +
    1.32  
    1.33      def cleanupVm(self):
    1.34          """Cleanup VM resources.  Idempotent.  Nothrow guarantee."""
    1.35 @@ -1123,24 +1130,16 @@ class XendDomainInfo:
    1.36          log.debug("XendDomainInfo.destroyDomain(%s)", str(self.domid))
    1.37  
    1.38          self.cleanupDomain()
    1.39 -        
    1.40 +
    1.41          try:
    1.42              if self.domid is not None:
    1.43                  xc.domain_destroy(dom=self.domid)
    1.44          except:
    1.45              log.exception("XendDomainInfo.destroy: xc.domain_destroy failed.")
    1.46  
    1.47 -        self.state_set(STATE_VM_TERMINATED)
    1.48 -
    1.49  
    1.50      ## private:
    1.51  
    1.52 -    def is_terminated(self):
    1.53 -        """Check if a domain has been terminated.
    1.54 -        """
    1.55 -        return self.state == STATE_VM_TERMINATED
    1.56 -
    1.57 -
    1.58      def release_devices(self):
    1.59          """Release all domain's devices.  Nothrow guarantee."""
    1.60  
    1.61 @@ -1353,6 +1352,18 @@ class XendDomainInfo:
    1.62                  n += 1
    1.63  
    1.64  
    1.65 +    def generateZombieName(self):
    1.66 +        n = 0
    1.67 +        name = ZOMBIE_PREFIX + self.info['name']
    1.68 +        while True:
    1.69 +            try:
    1.70 +                self.check_name(name)
    1.71 +                return name
    1.72 +            except VmError:
    1.73 +                n += 1
    1.74 +                name = "%s%d-%s" % (ZOMBIE_PREFIX, n, self.info['name'])
    1.75 +
    1.76 +
    1.77      def configure_bootloader(self):
    1.78          if not self.info['bootloader']:
    1.79              return