[Libvirt-cim] [PATCH] If the resource type of a devices is set to UNKNOWN, do not generate XML for it

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Mar 4 21:04:27 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1236200658 28800
# Node ID ad367dfd38f4a78eeaf5369bb00d22bbf6aec911
# Parent  e3dd4cec1b61373e738fe3ba58557ae543b41789
If the resource type of a devices is set to UNKNOWN, do not generate XML for it

xmlgen was recently refactored, so this adds back in behavior that was missed
during the refactor.  If the resource type of a device is CIM_RES_TYPE_UNKNOWN,
then the xml generation for that device should be skipped.

The RemoveResources() call sets a device's type to UNKNOWN to indicate that
the device should be marked for removal.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r e3dd4cec1b61 -r ad367dfd38f4 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c	Tue Mar 03 10:04:00 2009 -0700
+++ b/libxkutil/xmlgen.c	Wed Mar 04 13:04:18 2009 -0800
@@ -128,6 +128,10 @@
         const char *msg = NULL;;
 
         for (i = 0; (i < dominfo->dev_disk_ct) && (msg == NULL); i++) {
+                struct virt_device *dev = &dominfo->dev_disk[i];
+                if (dev->type == CIM_RES_TYPE_UNKNOWN)
+                        continue;
+
                 struct disk_device *disk = &dominfo->dev_disk[i].dev.disk;
                 CU_DEBUG("Disk: %i %s %s",
                          disk->disk_type,
@@ -229,6 +233,9 @@
 
         for (i = 0; (i < dominfo->dev_net_ct) && (msg == NULL); i++) {
                 struct virt_device *dev = &dominfo->dev_net[i];
+                if (dev->type == CIM_RES_TYPE_UNKNOWN)
+                        continue;
+
                 struct net_device *net = &dev->dev.net;
 
                 if (STREQ(dev->dev.net.type, "network"))
@@ -331,6 +338,9 @@
         for (i = 0; i < dominfo->dev_graphics_ct; i++) {
                 xmlNodePtr tmp;
                 struct virt_device *_dev = &dominfo->dev_graphics[i];
+                if (_dev->type == CIM_RES_TYPE_UNKNOWN)
+                        continue;
+
                 struct graphics_device *dev = &_dev->dev.graphics;
 
                 tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL);
@@ -353,6 +363,9 @@
         for (i = 0; i < dominfo->dev_input_ct; i++) {
                 xmlNodePtr tmp;
                 struct virt_device *_dev = &dominfo->dev_input[i];
+                if (_dev->type == CIM_RES_TYPE_UNKNOWN)
+                        continue;
+
                 struct input_device *dev = &_dev->dev.input;
 
                 tmp = xmlNewChild(root, NULL, BAD_CAST "input", NULL);




More information about the Libvirt-cim mailing list