@@ -346,15 +347,24 @@ static int parse_vcpu_device(xmlNode *no
free(count_str);
- list = calloc(1, sizeof(*list));
+ list = calloc(count, sizeof(*list));
if (list == NULL)
goto err;
-
- list->dev.vcpu.quantity = count;
+
+ for (i = 0; i < count; i++) {
+ struct virt_device *vdev = &list[i];
+ struct vcpu_device *cdev = &vdev->dev.vcpu;
+
+ cdev->number = i;
+
+ vdev->type = CIM_RES_TYPE_PROC;
+ if (asprintf(&vdev->id, "%i", i) == -1)
+ vdev->id = NULL;
+ }
*vdevs = list;
- return 1;
+ return count;
You could do return count + 1 here and then use the quantity instead of
number. This would save you a step in the rasd_from_vdev() call.
But either way is fine by me.
static void print_dev_emu(struct virt_device *dev,
diff -r 01b0a24fc16f -r f0153bd85ec1 src/Virt_RASD.c
--- a/src/Virt_RASD.c Mon Apr 14 15:17:08 2008 -0700
+++ b/src/Virt_RASD.c Tue Apr 15 11:50:05 2008 -0400
@@ -169,8 +169,10 @@ static CMPIInstance *rasd_from_vdev(cons
CMSetProperty(inst, "Limit",
(CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64);
} else if (dev->type == CIM_RES_TYPE_PROC) {
+ /* This would be the place to set the virtualquantity. */
+ int quantity = dev->dev.vcpu.number + 1;
Probably doesn't matter for this case, but the type here should match
the type you set in CMSetProperty.
CMSetProperty(inst, "VirtualQuantity",
- (CMPIValue *)&dev->dev.vcpu.quantity,
CMPI_uint32);
+ (CMPIValue *)&quantity, CMPI_uint32);
This needs to be CMPI_uint64 (per the mof) - otherwise, the attribute
might not set correctly in all cases.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com