# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196195058 28800
# Node ID 6e84b22c2d0251897d1f12a97fc79a0cfa2c0db9
# Parent bf7fc8b2c3b68b409052757853b450002bb7e1da
Fixes to VSMS for libcmpiutil API change
Changed the name of a variable to avoid having to break a line in an ugly
way. If this is too much of a violation of the recently defined policy,
I'll changed it :)
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r bf7fc8b2c3b6 -r 6e84b22c2d02 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Tue Nov 27 12:22:26 2007 -0800
+++ b/src/Virt_VirtualSystemManagementService.c Tue Nov 27 12:24:18 2007 -0800
@@ -92,12 +92,11 @@ static CMPIStatus define_system_parse_ar
struct inst_list *res)
{
CMPIStatus s = {CMPI_RC_ERR_FAILED, NULL};
- char *sys_str = NULL;
+ const char *sys_str = NULL;
CMPIArray *res_arr;
int ret;
- sys_str = cu_get_str_arg(argsin, "SystemSettings");
- if (sys_str == NULL) {
+ if (cu_get_str_arg(argsin, "SystemSettings", &sys_str) !=
CMPI_RC_OK) {
CU_DEBUG("No SystemSettings string argument");
goto out;
}
@@ -114,8 +113,8 @@ static CMPIStatus define_system_parse_ar
goto out;
}
- res_arr = cu_get_array_arg(argsin, "ResourceSettings");
- if (res_arr == NULL) {
+ if (cu_get_array_arg(argsin, "ResourceSettings", &res_arr) !=
+ CMPI_RC_OK) {
CU_DEBUG("Failed to get array arg");
goto out;
}
@@ -125,8 +124,6 @@ static CMPIStatus define_system_parse_ar
CMSetStatus(&s, CMPI_RC_OK);
out:
- free(sys_str);
-
return s;
}
@@ -135,11 +132,14 @@ static int vssd_to_domain(CMPIInstance *
{
uint16_t tmp;
int ret = 0;
+ const char *val;
+
+ ret = cu_get_str_prop(inst, "VirtualSystemIdentifier", &val);
+ if (ret != CMPI_RC_OK)
+ goto out;
free(domain->name);
- ret = cu_get_str_prop(inst, "VirtualSystemIdentifier",
&domain->name);
- if (ret != CMPI_RC_OK)
- goto out;
+ domain->name = strdup(val);
ret = cu_get_u16_prop(inst, "AutomaticShutdownAction", &tmp);
if (ret != CMPI_RC_OK)
@@ -153,15 +153,19 @@ static int vssd_to_domain(CMPIInstance *
domain->on_crash = (int)tmp;
+ ret = cu_get_str_prop(inst, "Bootloader", &val);
+ if (ret != CMPI_RC_OK)
+ val = "";
+
free(domain->bootloader);
- ret = cu_get_str_prop(inst, "Bootloader", &domain->bootloader);
+ domain->bootloader = strdup(val);
+
+ ret = cu_get_str_prop(inst, "BootloaderArgs", &val);
if (ret != CMPI_RC_OK)
- domain->bootloader = strdup("");
+ val = "";
free(domain->bootloader_args);
- ret = cu_get_str_prop(inst, "BootloaderArgs",
&domain->bootloader_args);
- if (ret != CMPI_RC_OK)
- domain->bootloader_args = strdup("");
+ domain->bootloader_args = strdup(val);
ret = 1;
out:
@@ -172,7 +176,8 @@ static int rasd_to_vdev(CMPIInstance *in
struct virt_device *dev)
{
uint16_t type;
- char *id = NULL;
+ const char *id = NULL;
+ const char *val = NULL;
char *name = NULL;
char *devid = NULL;
CMPIObjectPath *op;
@@ -196,16 +201,20 @@ static int rasd_to_vdev(CMPIInstance *in
free(dev->dev.disk.virtual_dev);
dev->dev.disk.virtual_dev = devid;
+ if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK)
+ val = "/dev/null";
+
free(dev->dev.disk.source);
- cu_get_str_prop(inst, "Address",
&dev->dev.disk.source);
+ dev->dev.disk.source = strdup(val);
} else if (type == VIRT_DEV_NET) {
free(dev->dev.net.mac);
dev->dev.net.mac = devid;
+ if (cu_get_str_prop(inst, "NetworkType", &val) !=
CMPI_RC_OK)
+ val = "bridge";
+
free(dev->dev.net.type);
- cu_get_str_prop(inst, "NetworkType",
&dev->dev.net.type);
- if (dev->dev.net.type == NULL)
- dev->dev.net.type = strdup("bridge");
+ dev->dev.net.type = strdup(val);
} else if (type == VIRT_DEV_MEM) {
cu_get_u64_prop(inst, "VirtualQuantity",
&dev->dev.mem.size);
cu_get_u64_prop(inst, "Reservation",
&dev->dev.mem.size);
@@ -215,12 +224,10 @@ static int rasd_to_vdev(CMPIInstance *in
dev->dev.mem.maxsize <<= 10;
}
- free(id);
free(name);
return 1;
err:
- free(id);
free(name);
free(devid);
@@ -411,7 +418,7 @@ static CMPIStatus destroy_system(CMPIMet
const CMPIArgs *argsin,
CMPIArgs *argsout)
{
- char *dom_name = NULL;
+ const char *dom_name = NULL;
CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIValue rc;
CMPIObjectPath *sys;
@@ -426,8 +433,7 @@ static CMPIStatus destroy_system(CMPIMet
goto error1;
}
- sys = cu_get_ref_arg(argsin, "AffectedSystem");
- if (sys == NULL) {
+ if (cu_get_ref_arg(argsin, "AffectedSystem", &sys) != CMPI_RC_OK)
{
rc.uint32 = IM_RC_FAILED;
goto error2;
}
@@ -455,7 +461,6 @@ static CMPIStatus destroy_system(CMPIMet
rc.uint32 = IM_RC_SYS_NOT_FOUND;
}
- free(dom_name);
error2:
virConnectClose(conn);
error1:
@@ -467,7 +472,7 @@ static CMPIStatus update_system_settings
CMPIInstance *vssd)
{
CMPIStatus s;
- char *name = NULL;
+ const char *name = NULL;
CMPIrc ret;
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
@@ -513,7 +518,6 @@ static CMPIStatus update_system_settings
out:
free(xml);
- free(name);
virDomainFree(dom);
virConnectClose(conn);
cleanup_dominfo(&dominfo);
@@ -529,11 +533,10 @@ static CMPIStatus mod_system_settings(CM
const CMPIArgs *argsin,
CMPIArgs *argsout)
{
- char *inst_str;
+ const char *inst_str;
CMPIInstance *inst;
- inst_str = cu_get_str_arg(argsin, "SystemSettings");
- if (inst == NULL) {
+ if (cu_get_str_arg(argsin, "SystemSettings", &inst_str) !=
CMPI_RC_OK) {
CMPIStatus s;
cu_statusf(_BROKER, &s,
@@ -878,7 +881,7 @@ static CMPIStatus _update_resource_setti
for (i = 0; i < list->cur; i++) {
CMPIInstance *inst = list->list[i];
- char *id = NULL;
+ const char *id = NULL;
char *name = NULL;
char *devid = NULL;
virDomainPtr dom = NULL;
@@ -910,7 +913,6 @@ static CMPIStatus _update_resource_setti
end:
free(name);
free(devid);
- free(id);
virDomainFree(dom);
if (s.rc != CMPI_RC_OK)
@@ -927,21 +929,20 @@ static CMPIStatus update_resource_settin
const CMPIArgs *argsin,
resmod_fn func)
{
- CMPIArray *array;
+ CMPIArray *arr;
CMPIStatus s;
struct inst_list list;
inst_list_init(&list);
- array = cu_get_array_arg(argsin, "ResourceSettings");
- if (array == NULL) {
+ if (cu_get_array_arg(argsin, "ResourceSettings", &arr) !=
CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Missing ResourceSettings");
goto out;
}
- parse_str_inst_array(array, NAMESPACE(ref), &list);
+ parse_str_inst_array(arr, NAMESPACE(ref), &list);
s = _update_resource_settings(ref, &list, func);
@@ -1052,7 +1053,7 @@ CMPIStatus get_vsms(const CMPIObjectPath
CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *inst = NULL;
CMPIInstance *host = NULL;
- char *val = NULL;
+ const char *val = NULL;
virConnectPtr conn = NULL;
*_inst = NULL;
@@ -1089,7 +1090,6 @@ CMPIStatus get_vsms(const CMPIObjectPath
CMSetProperty(inst, "SystemName",
(CMPIValue *)val, CMPI_chars);
- free(val);
if (cu_get_str_prop(host, "CreationClassName", &val) != CMPI_RC_OK)
{
cu_statusf(broker, &s,
@@ -1100,7 +1100,6 @@ CMPIStatus get_vsms(const CMPIObjectPath
CMSetProperty(inst, "SystemCreationClassName",
(CMPIValue *)val, CMPI_chars);
- free(val);
CMSetStatus(&s, CMPI_RC_OK);