# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1201551627 28800
# Node ID dc93669fb2b0b6b83d32f349676389a320097c5c
# Parent 5362ddf2f1ce65ac965b64cbe40b7db026ee2ebc
[RFC] Remove the embedded object parsing pieces from VirtualSystemManagmentService.
This patch only removes the parsing from DefineSystem(). Also updates the DefineSystem()
call to expect instances instead of strings as arguments.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 5362ddf2f1ce -r dc93669fb2b0 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Tue Jan 22 16:22:15 2008 -0500
+++ b/src/Virt_VirtualSystemManagementService.c Mon Jan 28 12:20:27 2008 -0800
@@ -89,37 +89,20 @@ static CMPIStatus define_system_parse_ar
static CMPIStatus define_system_parse_args(const CMPIArgs *argsin,
CMPIInstance **sys,
const char *ns,
- struct inst_list *res)
+ CMPIArray **res)
{
CMPIStatus s = {CMPI_RC_ERR_FAILED, NULL};
- const char *sys_str = NULL;
- CMPIArray *res_arr;
- int ret;
-
- if (cu_get_str_arg(argsin, "SystemSettings", &sys_str) !=
CMPI_RC_OK) {
+
+ if (cu_get_inst_arg(argsin, "SystemSettings", sys) != CMPI_RC_OK) {
CU_DEBUG("No SystemSettings string argument");
goto out;
}
- ret = cu_parse_embedded_instance(sys_str,
- _BROKER,
- ns,
- sys);
- if (ret) {
- CU_DEBUG("Unable to parse SystemSettings instance");
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "SystemSettings parse error");
- goto out;
- }
-
- if (cu_get_array_arg(argsin, "ResourceSettings", &res_arr) !=
+ if (cu_get_array_arg(argsin, "ResourceSettings", res) !=
CMPI_RC_OK) {
CU_DEBUG("Failed to get array arg");
goto out;
}
-
- ret = parse_str_inst_array(res_arr, ns, res);
CMSetStatus(&s, CMPI_RC_OK);
@@ -317,24 +300,34 @@ static int rasd_to_vdev(CMPIInstance *in
return 0;
}
-static int classify_resources(struct inst_list *all,
+static int classify_resources(CMPIArray *resources,
struct domain *domain)
{
int i;
uint16_t type;
+ int count;
domain->dev_disk_ct = domain->dev_net_ct = 0;
domain->dev_vcpu_ct = domain->dev_mem_ct = 0;
-
- domain->dev_disk = calloc(all->cur, sizeof(struct virt_device));
- domain->dev_vcpu = calloc(all->cur, sizeof(struct virt_device));
- domain->dev_mem = calloc(all->cur, sizeof(struct virt_device));
- domain->dev_net = calloc(all->cur, sizeof(struct virt_device));
-
- for (i = 0; i < all->cur; i++) {
+
+ count = CMGetArrayCount(resources, NULL);
+ if (count < 1)
+ return 0;
+
+ domain->dev_disk = calloc(count, sizeof(struct virt_device));
+ domain->dev_vcpu = calloc(count, sizeof(struct virt_device));
+ domain->dev_mem = calloc(count, sizeof(struct virt_device));
+ domain->dev_net = calloc(count, sizeof(struct virt_device));
+
+ for (i = 0; i < count; i++) {
CMPIObjectPath *op;
-
- op = CMGetObjectPath(all->list[i], NULL);
+ CMPIData item;
+
+ item = CMGetArrayElementAt(resources, i, NULL);
+ if (CMIsNullObject(item.value.inst))
+ return 0;
+
+ op = CMGetObjectPath(item.value.inst, NULL);
if (op == NULL)
return 0;
@@ -343,16 +336,16 @@ static int classify_resources(struct ins
return 0;
if (type == CIM_RASD_TYPE_PROC)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_vcpu[domain->dev_vcpu_ct++]);
else if (type == CIM_RASD_TYPE_MEM)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_mem[domain->dev_mem_ct++]);
else if (type == CIM_RASD_TYPE_DISK)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_disk[domain->dev_disk_ct++]);
else if (type == CIM_RASD_TYPE_NET)
- rasd_to_vdev(all->list[i],
+ rasd_to_vdev(item.value.inst,
&domain->dev_net[domain->dev_net_ct++]);
}
@@ -398,7 +391,7 @@ static CMPIInstance *connect_and_create(
}
static CMPIInstance *create_system(CMPIInstance *vssd,
- struct inst_list *resources,
+ CMPIArray *resources,
const CMPIObjectPath *ref,
CMPIStatus *s)
{
@@ -467,10 +460,8 @@ static CMPIStatus define_system(CMPIMeth
CMPIInstance *vssd;
CMPIInstance *sys;
CMPIObjectPath *sys_op;
- struct inst_list res;
+ CMPIArray *res;
CMPIStatus s;
-
- inst_list_init(&res);
CU_DEBUG("DefineSystem");
@@ -478,11 +469,9 @@ static CMPIStatus define_system(CMPIMeth
if (s.rc != CMPI_RC_OK)
goto out;
- sys = create_system(vssd, &res, reference, &s);
+ sys = create_system(vssd, res, reference, &s);
if (sys == NULL)
goto out;
-
- inst_list_free(&res);
CMAddArg(argsout, "ResultingSystem", &sys, CMPI_instance);
@@ -1141,8 +1130,8 @@ static struct method_handler DefineSyste
static struct method_handler DefineSystem = {
.name = "DefineSystem",
.handler = define_system,
- .args = {{"SystemSettings", CMPI_string},
- {"ResourceSettings", CMPI_stringA},
+ .args = {{"SystemSettings", CMPI_instance},
+ {"ResourceSettings", CMPI_instanceA},
{"ReferencedConfiguration", CMPI_string},
ARG_END
}