xen/15157_modified.patch

69 lines
3.0 KiB
Diff

diff -ru a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py 2007-06-08 11:19:37.000000000 -0600
+++ b/tools/python/xen/xend/XendDomainInfo.py 2007-06-08 11:23:59.000000000 -0600
@@ -545,20 +545,17 @@
def destroyDevice(self, deviceClass, devid, force = False):
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)
- for entry in xstransact.List(devicePath):
- backend = xstransact.Read('%s/%s' % (devicePath, entry),
- "backend")
- devName = xstransact.Read(backend, "dev")
- if devName == devid:
- # We found the integer matching our devid, use it instead
- devid = entry
- break
-
- return self.getDeviceController(deviceClass).destroyDevice(devid, force)
+ # 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
+
+ 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):
@@ -1354,20 +1351,19 @@
self.image.destroy(suspend)
return
- while True:
- t = xstransact("%s/device" % self.dompath)
- for devclass in XendDevices.valid_devices():
- for dev in t.list(devclass):
- try:
- t.remove(dev)
- except:
- # Log and swallow any exceptions in removal --
- # there's nothing more we can do.
- log.exception(
- "Device release failed: %s; %s; %s",
- self.info['name_label'], devclass, dev)
- if t.commit():
- break
+ t = xstransact("%s/device" % self.dompath)
+ for devclass in XendDevices.valid_devices():
+ for dev in t.list(devclass):
+ try:
+ log.debug("Removing %s", dev);
+ self.destroyDevice(devclass, dev, False);
+ except:
+ # Log and swallow any exceptions in removal --
+ # there's nothing more we can do.
+ log.exception("Device release failed: %s; %s; %s",
+ self.info['name_label'], devclass, dev)
+
+
def getDeviceController(self, name):
"""Get the device controller for this domain, and if it