Change in vdsm[master]: libvirtvm: fix xml generation for all the devices

fsimonce at redhat.com fsimonce at redhat.com
Fri Apr 5 14:00:32 UTC 2013


Federico Simoncelli has uploaded a new change for review.

Change subject: libvirtvm: fix xml generation for all the devices
......................................................................

libvirtvm: fix xml generation for all the devices

In one of the patches of the before_device_create series has been
removed the XML generation for the regular devices.
This patch fixes the behavior reintroducing the missing XML.

Change-Id: Ifb4f9eb32bc58371cec66301275689660193447b
Signed-off-by: Federico Simoncelli <fsimonce at redhat.com>
---
M vdsm/libvirtvm.py
1 file changed, 15 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/13637/1

diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 607dedb..6f45226 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1304,25 +1304,24 @@
 
         for devType in self._devices:
             for dev in self._devices[devType]:
-                if not getattr(dev, 'custom', {}):
-                    continue
+                if hasattr(dev, 'custom'):
+                    yield
 
-                yield dev
-
-    def _beforeDeviceCreateHooks(self, domxml):
+    def _beforeDeviceCreateHooks(self, dev):
         """
         Run before_device_create hook script for devices with custom properties
 
         The resulting device xml is cached in dev._deviceXML.
         """
+        deviceXML = dev.getXML()
 
-        for dev in self._customDevices():
-            deviceXML = dev.getXML().toxml(encoding='utf-8')
-            deviceXML = hooks.before_device_create(
-                deviceXML, self.conf, dev.custom)
-            dev._deviceXML = deviceXML
-            domxml._devices.appendChild(
-                xml.dom.minidom.parseString(deviceXML).firstChild)
+        if not hasattr(dev, 'custom'):
+            return deviceXML
+
+        dev._deviceXML = hooks.before_device_create(
+            deviceXML.toxml(encoding='utf-8'), self.conf, dev.custom)
+
+        return xml.dom.minidom.parseString(dev._deviceXML).firstChild
 
     def _buildCmdLine(self):
         domxml = _DomXML(self.conf, self.log)
@@ -1347,7 +1346,10 @@
         domxml.appendInput()
         domxml.appendGraphics()
 
-        self._beforeDeviceCreateHooks(domxml)
+        for devType in self._devices:
+            for dev in self._devices[devType]:
+                deviceXML = self._beforeDeviceCreateHooks(dev)
+                domxml._devices.appendChild(deviceXML)
 
         for drive in self._devices[vm.DISK_DEVICES][:]:
             if not hasattr(drive, 'volumeChain'):


--
To view, visit http://gerrit.ovirt.org/13637
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb4f9eb32bc58371cec66301275689660193447b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce at redhat.com>


More information about the vdsm-patches mailing list