[Libvirt-cim] [PATCH] Fix VSMS resource_add so that and additional tag is not added for processor

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Jun 2 16:59:36 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1212425931 25200
# Node ID 7cf0b0142edb638ce43cc8f3209eef12b2f5e04b
# Parent  0c8d4baf3ee1f6eb96f7d1d49276fa6cc44c4685
Fix VSMS resource_add so that and additional tag is not added for processor.

The same is also true for memory.  Also, be sure not to increment the count for processor and memory since a guest will not have muultiple tags for these devices.

Remove check for memory after find_list().  We don't want to skip this becuase it's possible to update the memory of a defined guest.  It is not possible to update the memory of a running guest, but this case is already handled by attach_device() in device_parsing.c

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

diff -r 0c8d4baf3ee1 -r 7cf0b0142edb src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Fri May 30 06:57:03 2008 -0700
+++ b/src/Virt_VirtualSystemManagementService.c	Mon Jun 02 09:58:51 2008 -0700
@@ -1035,7 +1035,7 @@
                 goto out;
 
         _list = find_list(dominfo, type, &count);
-        if ((type == CIM_RES_TYPE_MEM) || (_list == NULL)) {
+        if (_list == NULL) {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
                            "Cannot add resources of type %" PRIu16, type);
@@ -1052,22 +1052,36 @@
                 goto out;
         }
 
-        list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device));
-        if (list == NULL) {
-                /* No memory */
-                cu_statusf(_BROKER, &s,
+        if ((type == CIM_RES_TYPE_PROC) || (type == CIM_RES_TYPE_MEM)) {
+                if (_list == NULL) {
+                        cu_statusf(_BROKER, &s,
+                                   CMPI_RC_ERR_FAILED,
+                                   "Cannot modify resource: %" PRIu16, type);
+                        goto out;
+                }
+                list = *_list;
+
+                dev = &list[0];
+        } else {
+                list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device));
+                if (list == NULL) {
+                        /* No memory */
+                        cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
                            "Failed to allocate memory");
-                goto out;
+                       goto out;
+                }
+
+                *_list = list;
+                memset(&list[*count], 0, sizeof(list[*count]));
+
+                dev = &list[*count];
+                dev->type = type;
+                dev->id = strdup(devid);
         }
-
-        *_list = list;
-        memset(&list[*count], 0, sizeof(list[*count]));
-
-        dev = &list[*count];
-
         dev->type = type;
         dev->id = strdup(devid);
+
         rasd_to_vdev(rasd, dominfo, dev, ns);
 
         s = _resource_dynamic(dominfo, dev, RESOURCE_ADD, CLASSNAME(op));
@@ -1077,7 +1091,9 @@
         cu_statusf(_BROKER, &s,
                    CMPI_RC_OK,
                    "");
-        (*count)++;
+
+        if ((type != CIM_RES_TYPE_PROC) && (type != CIM_RES_TYPE_MEM))
+                (*count)++;
 
  out:
         return s;




More information about the Libvirt-cim mailing list