ia64/xen-unstable

changeset 12141:7ae6323db2f8

[XEND] Remove mistake of not checking xenstore's name entry for Dom0

Also fix logic with detecting whether devid is an int or not because
xm passes this as a string all the time.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Oct 19 17:48:54 2006 +0100 (2006-10-19)
parents f0c7f258c19e
children 73cd81de36ea
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Oct 19 17:46:54 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Oct 19 17:48:54 2006 +0100
     1.3 @@ -93,9 +93,8 @@ class XendDomain:
     1.4                  dom0info = [d for d in self._running_domains() \
     1.5                              if d['domid'] == DOM0_ID][0]
     1.6                  
     1.7 +                dom0info['name'] = DOM0_NAME
     1.8                  dom0 = XendDomainInfo.recreate(dom0info, True)
     1.9 -                # Sometimes this is not set?
    1.10 -                dom0.setName(DOM0_NAME)
    1.11                  self._add_domain(dom0)
    1.12              except IndexError:
    1.13                  raise XendError('Unable to find Domain 0')
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Oct 19 17:46:54 2006 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Oct 19 17:48:54 2006 +0100
     2.3 @@ -29,6 +29,7 @@ import time
     2.4  import threading
     2.5  import re
     2.6  import copy
     2.7 +from types import StringTypes
     2.8  
     2.9  import xen.lowlevel.xc
    2.10  from xen.util import asserts
    2.11 @@ -183,7 +184,8 @@ def recreate(info, priv):
    2.12          raise XendError('No domain path in store for existing '
    2.13                          'domain %d' % domid)
    2.14  
    2.15 -    log.info("Recreating domain %d, UUID %s.", domid, xeninfo['uuid'])
    2.16 +    log.info("Recreating domain %d, UUID %s. at %s" %
    2.17 +             (domid, xeninfo['uuid'], dompath))
    2.18  
    2.19      # need to verify the path and uuid if not Domain-0
    2.20      # if the required uuid and vm aren't set, then that means
    2.21 @@ -193,29 +195,28 @@ def recreate(info, priv):
    2.22      #       abort or ignore, but there may be cases where xenstore's
    2.23      #       entry disappears (eg. xenstore-rm /)
    2.24      #
    2.25 -    if domid != 0:
    2.26 -        try:
    2.27 -            vmpath = xstransact.Read(dompath, "vm")
    2.28 -            if not vmpath:
    2.29 -                log.warn('/dom/%d/vm is missing. recreate is confused, '
    2.30 -                         'trying our best to recover' % domid)
    2.31 -                needs_reinitialising = True
    2.32 -                raise XendError('reinit')
    2.33 -            
    2.34 -            uuid2_str = xstransact.Read(vmpath, "uuid")
    2.35 -            if not uuid2_str:
    2.36 -                log.warn('%s/uuid/ is missing. recreate is confused, '
    2.37 -                         'trying our best to recover' % vmpath)
    2.38 -                needs_reinitialising = True
    2.39 -                raise XendError('reinit')
    2.40 -
    2.41 -            uuid2 = uuid.fromString(uuid2_str)
    2.42 -            if uuid1 != uuid2:
    2.43 -                log.warn('UUID in /vm does not match the UUID in /dom/%d.'
    2.44 -                         'Trying out best to recover' % domid)
    2.45 -                needs_reinitialising = True
    2.46 -        except XendError:
    2.47 -            pass # our best shot at 'goto' in python :)
    2.48 +    try:
    2.49 +        vmpath = xstransact.Read(dompath, "vm")
    2.50 +        if not vmpath:
    2.51 +            log.warn('/local/domain/%d/vm is missing. recreate is '
    2.52 +                     'confused, trying our best to recover' % domid)
    2.53 +            needs_reinitialising = True
    2.54 +            raise XendError('reinit')
    2.55 +        
    2.56 +        uuid2_str = xstransact.Read(vmpath, "uuid")
    2.57 +        if not uuid2_str:
    2.58 +            log.warn('%s/uuid/ is missing. recreate is confused, '
    2.59 +                     'trying our best to recover' % vmpath)
    2.60 +            needs_reinitialising = True
    2.61 +            raise XendError('reinit')
    2.62 +        
    2.63 +        uuid2 = uuid.fromString(uuid2_str)
    2.64 +        if uuid1 != uuid2:
    2.65 +            log.warn('UUID in /vm does not match the UUID in /dom/%d.'
    2.66 +                     'Trying out best to recover' % domid)
    2.67 +            needs_reinitialising = True
    2.68 +    except XendError:
    2.69 +        pass # our best shot at 'goto' in python :)
    2.70  
    2.71      vm = XendDomainInfo(xeninfo, domid, dompath, augment = True, priv = priv)
    2.72      
    2.73 @@ -537,7 +538,10 @@ class XendDomainInfo:
    2.74              self.getDeviceController(devclass).waitForDevices()
    2.75  
    2.76      def destroyDevice(self, deviceClass, devid):
    2.77 -        if type(devid) is str:
    2.78 +        try:
    2.79 +            devid = int(devid)
    2.80 +        except ValueError:
    2.81 +            # devid is not a number, let's search for it in xenstore.
    2.82              devicePath = '%s/device/%s' % (self.dompath, deviceClass)
    2.83              for entry in xstransact.List(devicePath):
    2.84                  backend = xstransact.Read('%s/%s' % (devicePath, entry),
    2.85 @@ -547,6 +551,7 @@ class XendDomainInfo:
    2.86                      # We found the integer matching our devid, use it instead
    2.87                      devid = entry
    2.88                      break
    2.89 +                
    2.90          return self.getDeviceController(deviceClass).destroyDevice(devid)
    2.91  
    2.92