# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1207668726 14400
# Node ID ddbd91b1f796acc59db18997ded9faf8ebf14006
# Parent ade926a6ad096be7c1bebab3eb7ac4080aac9088
Change how processors are represented using RASD.
We currently do one RASD per processor per domain, but it looks like that isn't going
to work very well with how we do scheduling, so this switches the "read"
representation over to one RASD per domain, with VirtualQuantity set appropriately.
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
diff -r ade926a6ad09 -r ddbd91b1f796 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Mon Apr 07 14:31:06 2008 -0400
+++ b/libxkutil/device_parsing.c Tue Apr 08 11:32:06 2008 -0400
@@ -337,7 +337,6 @@ static int parse_vcpu_device(xmlNode *no
struct virt_device *list = NULL;
char *count_str;
int count;
- int i;
count_str = get_node_content(node);
if (count_str == NULL)
@@ -347,24 +346,15 @@ static int parse_vcpu_device(xmlNode *no
free(count_str);
- list = calloc(count, sizeof(*list));
+ list = calloc(1, sizeof(*list));
if (list == NULL)
goto err;
-
- 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;
- }
+
+ list->dev.vcpu.quantity = count;
*vdevs = list;
- return count;
+ return 1;
err:
free(list);
@@ -620,7 +610,7 @@ struct virt_device *virt_device_dup(stru
dev->dev.mem.size = _dev->dev.mem.size;
dev->dev.mem.maxsize = _dev->dev.mem.maxsize;
} else if (dev->type == CIM_RES_TYPE_PROC) {
- dev->dev.vcpu.number = _dev->dev.vcpu.number;
+ dev->dev.vcpu.quantity = _dev->dev.vcpu.quantity;
} else if (dev->type == CIM_RES_TYPE_EMU) {
DUP_FIELD(dev, _dev, dev.emu.path);
} else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
@@ -672,6 +662,32 @@ static int _get_mem_device(const char *x
return 1;
}
+static int _get_proc_device(const char *xml, struct virt_device **list)
+{
+ struct virt_device *proc_devs = NULL;
+ struct virt_device *proc_dev = NULL;
+ int ret;
+
+ ret = parse_devices(xml, &proc_devs, CIM_RES_TYPE_PROC);
+ if (ret <= 0)
+ return ret;
+
+ proc_dev = malloc(sizeof(*proc_dev));
+ if (proc_dev == NULL)
+ return 0;
+
+ memset(proc_dev, 0, sizeof(*proc_dev));
+
+ proc_dev->type = CIM_RES_TYPE_PROC;
+ proc_dev->id = strdup("proc");
+ proc_dev->dev.vcpu.quantity = proc_devs[0].dev.vcpu.quantity;
+ *list = proc_dev;
+
+ cleanup_virt_devices(&proc_devs, ret);
+
+ return 1;
+};
+
int get_devices(virDomainPtr dom, struct virt_device **list, int type)
{
char *xml;
@@ -683,6 +699,8 @@ int get_devices(virDomainPtr dom, struct
if (type == CIM_RES_TYPE_MEM)
ret = _get_mem_device(xml, list);
+ else if (type == CIM_RES_TYPE_PROC)
+ ret = _get_proc_device(xml, list);
else
ret = parse_devices(xml, list, type);
diff -r ade926a6ad09 -r ddbd91b1f796 libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Mon Apr 07 14:31:06 2008 -0400
+++ b/libxkutil/device_parsing.h Tue Apr 08 11:32:06 2008 -0400
@@ -50,7 +50,7 @@ struct mem_device {
};
struct vcpu_device {
- uint32_t number;
+ uint32_t quantity;
};
struct emu_device {
diff -r ade926a6ad09 -r ddbd91b1f796 src/Virt_RASD.c
--- a/src/Virt_RASD.c Mon Apr 07 14:31:06 2008 -0400
+++ b/src/Virt_RASD.c Tue Apr 08 11:32:06 2008 -0400
@@ -168,6 +168,9 @@ static CMPIInstance *rasd_from_vdev(cons
(CMPIValue *)&dev->dev.mem.size, CMPI_uint64);
CMSetProperty(inst, "Limit",
(CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64);
+ } else if (dev->type == CIM_RES_TYPE_PROC) {
+ CMSetProperty(inst, "VirtualQuantity",
+ (CMPIValue *)&dev->dev.vcpu.quantity, CMPI_uint32);
}
/* FIXME: Put the HostResource in place */