Skip to contentSkip to conversation

Fix xm block-create

PATCH New Anthony Liguori 1 participant 1 message Aug 12, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix xm block-create

xm block-create doesn't work. It seems like this command hasn't even been tested (perhaps since the un-Twisting?). This particular problem was that one function was being called with self instead of the right argument and another function's return value was being used when it didn't actually return anything.

This patch also improves the error handling a bit by making sure we don't thrown an exception on a log statement with a None value. In general, one should always use the % formatter instead of concatination for strings in Python (even though this is not what this patch does).

Regards,

Anthony Liguori

Signed-off-by Anthony Liguori

# HG changeset patch
# User Anthony Liguori <[email protected]>
# Node ID 17e1b03d6932fa4eb827d61fd7cb32c04213e421
# Parent 1c0812b8fbf5e3415b45cb2bb068610e28f9b7df
Make sure to pass in dev_type instead of self as this is what the function actually expects.

tools/python/xen/xend/XendDomainInfo.py +2 -2
diff -r 1c0812b8fbf5 -r 17e1b03d6932 tools/python/xen/xend/XendDomainInfo.py
@@ -138,7 +138,7 @@
     if domlist and dom == domlist[0]['dom']:
         return domlist[0]
     return None
-    
+
 class XendDomainInfo:
     """Virtual machine object."""
 
@@ -747,7 +747,7 @@
         @param dev_config: device configuration
         """
         dev_type = sxp.name(dev_config)
-        dev = self.createDevice(self, dev_config, change=True)
+        dev = self.createDevice(dev_type, dev_config, change=True)
         self.config.append(['device', dev.getConfig()])
         return dev.sxpr()
 

# HG changeset patch
# User Anthony Liguori <[email protected]>
# Node ID 1c0812b8fbf5e3415b45cb2bb068610e28f9b7df
# Parent faec6bf5081bc6d6632901fd771876fadfd6ae46
Have DeviceController::createDevice return the actual device as this is expected in the DomainInfo::create_device code.

tools/python/xen/xend/server/controller.py +2 -0
diff -r faec6bf5081b -r 1c0812b8fbf5 tools/python/xen/xend/server/controller.py
@@ -283,6 +283,8 @@
         dev.attach(recreate=recreate, change=change)
         dev.exportToDB()
 
+        return dev
+
     def configureDevice(self, id, config, change=False):
         """Reconfigure an existing device.
         May be defined in subclass."""

# HG changeset patch
# User Anthony Liguori <[email protected]>
# Node ID faec6bf5081bc6d6632901fd771876fadfd6ae46 # Parent 8937fe723eef24375a0eae488443e1c5948c1a7a Make sure to explictly cast to avoid Internal Server Errors

tools/python/xen/xend/server/controller.py +2 -2
diff -r 8937fe723eef -r faec6bf5081b tools/python/xen/xend/server/controller.py
@@ -142,7 +142,7 @@
     def createDevController(self, type, vm, recreate=False):
         cls = self.getDevControllerClass(type)
         if not cls:
-            raise XendError("unknown device type: " + type)
+            raise XendError("unknown device type: " + str(type))
         return cls.createDevController(vm, recreate=recreate)
 
 def getDevControllerTable():
@@ -325,7 +325,7 @@
     def getDevice(self, id, error=False):
         dev = self.devices.get(id)
         if error and not dev:
-            raise XendError("invalid device id: " + id)
+            raise XendError("invalid device id: " + str(id))
         return dev
 
     def getDeviceIds(self):

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel