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>
This commit is contained in:
kfraser@localhost.localdomain committed 2007-06-11 10:14:54 +01:00
1 parent 840f138cfa
commit 34eef35280
1 file changed
+9 -22
+9 -22
View File
@@ -546,31 +546,18 @@ class XendDomainInfo:
self.getDeviceController(devclass).waitForDevices()
def destroyDevice(self, deviceClass, devid, force = False):
found = True # Assume devid is an integer.
try:
devid = int(devid)
dev = int(devid)
except ValueError:
# devid is not a number, let's search for it in xenstore.
devicePath = '%s/device/%s' % (self.dompath, deviceClass)
found = False
for entry in xstransact.List(devicePath):
log.debug("Attempting to find devid at %s/%s", devicePath, entry)
backend = xstransact.Read('%s/%s' % (devicePath, entry),
"backend")
if backend != None:
devName = '%s/%s' % (deviceClass, entry)
log.debug("devName=%s", devName)
if devName == devid:
# We found the integer matching our devid, use it instead
devid = int(entry)
found = True
break
# devid is not a number but a string containing either device
# name (e.g. xvda) or device_type/device_id (e.g. vbd/51728)
dev = type(devid) is str and devid.split('/')[-1] or None
if dev == None:
log.debug("Could not find the device %s", devid)
return None
if not found:
log.debug("Could not find the device %s", devid)
return None
log.debug("devid = %s", devid)
return self.getDeviceController(deviceClass).destroyDevice(devid, force)
log.debug("dev = %s", dev)
return self.getDeviceController(deviceClass).destroyDevice(dev, force)
def getDeviceSxprs(self, deviceClass):
if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.