ia64/xen-unstable

changeset 15305:a43a03d53781

xend: Fix xm block-detach regression introduced by c/s 15157.

Prior to this c/s, user was able to specify device name or id, e.g.
xm block-detach dom xvdb
xm block-detach dom 15728

Now, 'xm block-detach dom xvdb' silently fails. xend.log does contain
the following

[2007-06-07 11:39:18 xend.XendDomainInfo 3775] DEBUG
(XendDomainInfo:519) devName=vbd/51712
[2007-06-07 11:39:18 xend.XendDomainInfo 3775] DEBUG
(XendDomainInfo:527) Could not find the device xvdb

This patch restores the previous behavior but retains the bugfix
introduced by c/s 15571.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author kfraser@localhost.localdomain
date Mon Jun 11 10:14:54 2007 +0100 (2007-06-11)
parents 93f77a5a8437
children 6f06bd06ef47
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Sun Jun 10 19:58:22 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Jun 11 10:14:54 2007 +0100
     1.3 @@ -546,31 +546,18 @@ class XendDomainInfo:
     1.4              self.getDeviceController(devclass).waitForDevices()
     1.5  
     1.6      def destroyDevice(self, deviceClass, devid, force = False):
     1.7 -        found = True                    # Assume devid is an integer.
     1.8          try:
     1.9 -            devid = int(devid)
    1.10 +            dev = int(devid)
    1.11          except ValueError:
    1.12 -            # devid is not a number, let's search for it in xenstore.
    1.13 -            devicePath = '%s/device/%s' % (self.dompath, deviceClass)
    1.14 -            found = False
    1.15 -            for entry in xstransact.List(devicePath):
    1.16 -                log.debug("Attempting to find devid at %s/%s", devicePath, entry)
    1.17 -                backend = xstransact.Read('%s/%s' % (devicePath, entry),
    1.18 -                                          "backend")
    1.19 -                if backend != None:
    1.20 -                    devName = '%s/%s' % (deviceClass, entry)
    1.21 -                    log.debug("devName=%s", devName)
    1.22 -                    if devName == devid:
    1.23 -                        # We found the integer matching our devid, use it instead
    1.24 -                        devid = int(entry)
    1.25 -                        found = True
    1.26 -                        break
    1.27 -
    1.28 -        if not found:
    1.29 -            log.debug("Could not find the device %s", devid)
    1.30 -            return None
    1.31 -        log.debug("devid = %s", devid)
    1.32 -        return self.getDeviceController(deviceClass).destroyDevice(devid, force)
    1.33 +            # devid is not a number but a string containing either device
    1.34 +            # name (e.g. xvda) or device_type/device_id (e.g. vbd/51728)
    1.35 +            dev = type(devid) is str and devid.split('/')[-1] or None
    1.36 +            if dev == None:
    1.37 +                log.debug("Could not find the device %s", devid)
    1.38 +                return None
    1.39 +
    1.40 +        log.debug("dev = %s", dev)
    1.41 +        return self.getDeviceController(deviceClass).destroyDevice(dev, force)
    1.42  
    1.43      def getDeviceSxprs(self, deviceClass):
    1.44          if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):