[PATCH 00 of 17] #2 Updates for libcmpiutil API change

Fixed ElementCapabilities after Kaitlin's recent fix patch. Fixed the STREQ check that was accidentally removed in the last version. This refactors all of the necessary functions in libvirt-cim for the new API. Things only got cleaner, I think. I also found a substantial number of memory leaks in the process, which are fundamentally fixed by the new API which I think is a validation of it as "the right thing to do". All required changes should have been easily spotted by the compiler, but some testing would be good.

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID cc0d80e1229bbd45e62c409336ce6020fbdebdbf # Parent f230e4d57a78a48efb5c32e70e048ce229c2cca4 Fixes to misc_util for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r f230e4d57a78 -r cc0d80e1229b libxkutil/misc_util.c --- a/libxkutil/misc_util.c Wed Nov 28 11:27:09 2007 +0100 +++ b/libxkutil/misc_util.c Wed Nov 28 09:50:29 2007 -0800 @@ -86,15 +86,18 @@ void free_domain_list(virDomainPtr *list virDomainFree(list[i]); } -char *get_key_from_ref_arg(const CMPIArgs *args, char *arg, char *key) +const char *get_key_from_ref_arg(const CMPIArgs *args, char *arg, char *key) { CMPIObjectPath *ref = NULL; - - ref = cu_get_ref_arg(args, arg); - if (ref == NULL) - return NULL; - - return cu_get_str_path(ref, key); + const char *val = NULL; + + if (cu_get_ref_arg(args, arg, &ref) != CMPI_RC_OK) + return NULL; + + if (cu_get_str_path(ref, key, &val) != CMPI_RC_OK) + return NULL; + + return val; } bool domain_exists(virConnectPtr conn, const char *name) @@ -352,7 +355,7 @@ bool domain_online(virDomainPtr dom) (info.state == VIR_DOMAIN_RUNNING); } -int parse_id(char *id, +int parse_id(const char *id, char **pfx, char **name) { @@ -386,15 +389,12 @@ bool parse_instanceid(const CMPIObjectPa char **name) { int ret; - char *id = NULL; - - id = cu_get_str_path(ref, "InstanceID"); - if (id == NULL) + const char *id = NULL; + + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) return false; ret = parse_id(id, pfx, name); - - free(id); if (!ret) return false; diff -r f230e4d57a78 -r cc0d80e1229b libxkutil/misc_util.h --- a/libxkutil/misc_util.h Wed Nov 28 11:27:09 2007 +0100 +++ b/libxkutil/misc_util.h Wed Nov 28 09:50:29 2007 -0800 @@ -84,7 +84,7 @@ CMPIInstance *get_typed_instance(const C /* Parse an OrgID:LocID string into its constituent parts */ int parse_instance_id(char *iid, char **orgid, char **locid); -char *get_key_from_ref_arg(const CMPIArgs *args, char *arg, char *key); +const char *get_key_from_ref_arg(const CMPIArgs *args, char *arg, char *key); bool domain_exists(virConnectPtr conn, const char *name); bool domain_online(virDomainPtr dom); @@ -94,7 +94,7 @@ char *association_prefix(const char *pro char *association_prefix(const char *provider_name); bool match_pn_to_cn(const char *pn, const char *cn); -int parse_id(char *id, char **pfx, char **name); +int parse_id(const char *id, char **pfx, char **name); bool parse_instanceid(const CMPIObjectPath *ref, char **pfx, char **name); bool libvirt_cim_init(void);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID 6d9aed8314c6a9c00ee506d724695859c623e396 # Parent cc0d80e1229bbd45e62c409336ce6020fbdebdbf Fixes to ComputerSystem for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r cc0d80e1229b -r 6d9aed8314c6 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_ComputerSystem.c Wed Nov 28 09:50:29 2007 -0800 @@ -277,7 +277,7 @@ static int instance_from_dom(const CMPIB /* Given a hypervisor connection and a domain name, return an instance */ CMPIInstance *instance_from_name(const CMPIBroker *broker, virConnectPtr conn, - char *name, + const char *name, const CMPIObjectPath *op) { virDomainPtr dom; @@ -376,7 +376,7 @@ static CMPIStatus return_enum_domains(co static CMPIStatus get_domain(const CMPIObjectPath *reference, const CMPIResult *results, - char *name) + const char *name) { CMPIInstance *inst; CMPIStatus s; @@ -440,10 +440,9 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - char *name; - - name = cu_get_str_path(reference, "Name"); - if (name == NULL) { + const char *name; + + if (cu_get_str_path(reference, "Name", &name) != CMPI_RC_OK) { CMPIStatus s; CMSetStatusWithChars(_BROKER, &s, @@ -602,7 +601,7 @@ static CMPIStatus state_change_reset(vir return s; } -static CMPIStatus __state_change(char *name, +static CMPIStatus __state_change(const char *name, uint16_t state, const CMPIObjectPath *ref) { @@ -660,7 +659,7 @@ static CMPIStatus state_change(CMPIMetho CMPIStatus s; uint16_t state; int ret; - char *name = NULL; + const char *name = NULL; ret = cu_get_u16_arg(argsin, "RequestedState", &state); if (!ret) { @@ -668,8 +667,7 @@ static CMPIStatus state_change(CMPIMetho goto out; } - name = cu_get_str_path(reference, "Name"); - if (name == NULL) { + if (cu_get_str_path(reference, "Name", &name) != CMPI_RC_OK) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, "Name key not specified"); @@ -679,8 +677,6 @@ static CMPIStatus state_change(CMPIMetho s = __state_change(name, state, reference); out: - free(name); - return s; } diff -r cc0d80e1229b -r 6d9aed8314c6 src/Virt_ComputerSystem.h --- a/src/Virt_ComputerSystem.h Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_ComputerSystem.h Wed Nov 28 09:50:29 2007 -0800 @@ -34,7 +34,7 @@ */ CMPIInstance *instance_from_name(const CMPIBroker *broker, virConnectPtr conn, - char *name, + const char *name, const CMPIObjectPath *ns);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID ca82a00fd6dafc045f2d5958feeb2decb2f750bc # Parent 6d9aed8314c6a9c00ee506d724695859c623e396 Fixes to Device for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 6d9aed8314c6 -r ca82a00fd6da src/Virt_Device.c --- a/src/Virt_Device.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_Device.c Wed Nov 28 09:50:29 2007 -0800 @@ -470,7 +470,7 @@ CMPIInstance *instance_from_devid(const static CMPIStatus get_device(const CMPIObjectPath *reference, const CMPIResult *results, - char *devid) + const char *devid) { CMPIStatus s; virConnectPtr conn; @@ -525,10 +525,9 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - char *devid; - - devid = cu_get_str_path(reference, "DeviceID"); - if (devid == NULL) { + const char *devid; + + if (cu_get_str_path(reference, "DeviceID", &devid) != CMPI_RC_OK) { CMPIStatus s; CMSetStatusWithChars(_BROKER, &s,

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID 06430b32cb03cf118ec1c8e866b2bc12ad7513a3 # Parent ca82a00fd6dafc045f2d5958feeb2decb2f750bc Fixes to SystemDevice for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r ca82a00fd6da -r 06430b32cb03 src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_SystemDevice.c Wed Nov 28 09:50:29 2007 -0800 @@ -158,14 +158,13 @@ static CMPIStatus sys_to_dev(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - char *host = NULL; + const char *host = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; int ret; ASSOC_MATCH(info->provider_name, CLASSNAME(ref)); - host = cu_get_str_path(ref, "Name"); - if (host == NULL) { + if (cu_get_str_path(ref, "Name", &host) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing Name"); @@ -205,7 +204,7 @@ static CMPIStatus dev_to_sys(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - char *devid = NULL; + const char *devid = NULL; char *host = NULL; char *dev = NULL; CMPIInstance *sys; @@ -213,8 +212,7 @@ static CMPIStatus dev_to_sys(const CMPIO ASSOC_MATCH(info->provider_name, CLASSNAME(ref)); - devid = cu_get_str_path(ref, "DeviceID"); - if (devid == NULL) { + if (cu_get_str_path(ref, "DeviceID", &devid) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing DeviceID"); @@ -242,7 +240,6 @@ static CMPIStatus dev_to_sys(const CMPIO out: free(dev); free(host); - free(devid); return s; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID e66205565a64aaaf90b62604948ab5d6c9b52d05 # Parent 06430b32cb03cf118ec1c8e866b2bc12ad7513a3 Fixes to RASD for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 06430b32cb03 -r e66205565a64 src/Virt_RASD.c --- a/src/Virt_RASD.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_RASD.c Wed Nov 28 09:50:29 2007 -0800 @@ -247,11 +247,10 @@ static CMPIStatus GetInstance(CMPIInstan { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - char *id = NULL; + const char *id = NULL; uint16_t type; - id = cu_get_str_path(ref, "InstanceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -274,8 +273,6 @@ static CMPIStatus GetInstance(CMPIInstan CMPI_RC_ERR_FAILED, "Unknown instance"); out: - free(id); - return s; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID 19721bc1591be90ca7d419fa807fee68fb56d6ae # Parent e66205565a64aaaf90b62604948ab5d6c9b52d05 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@us.ibm.com> diff -r e66205565a64 -r 19721bc1591b src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Wed Nov 28 09:50:29 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);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID cac519783620f111b033536c6e57978bc3eb7798 # Parent 19721bc1591be90ca7d419fa807fee68fb56d6ae Fixes to VSMC for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 19721bc1591b -r cac519783620 src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Wed Nov 28 09:50:29 2007 -0800 @@ -95,10 +95,9 @@ CMPIStatus get_vsm_cap(const CMPIBroker CMPIStatus s; CMPIObjectPath *op; char *classname = NULL; - char *sys_name = NULL; - - sys_name = cu_get_str_path(ref, "Name"); - if (sys_name == NULL) { + const char *sys_name = NULL; + + if (cu_get_str_path(ref, "Name", &sys_name) != CMPI_RC_OK) { CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED, "Missing key: Name"); @@ -134,7 +133,6 @@ CMPIStatus get_vsm_cap(const CMPIBroker out: free(classname); - free(sys_name); return s; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID fde363d69d8db4a85a2fdc52cad40ccc5ccc4236 # Parent cac519783620f111b033536c6e57978bc3eb7798 Fixes to DevicePool for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r cac519783620 -r fde363d69d8d src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_DevicePool.c Wed Nov 28 09:50:29 2007 -0800 @@ -730,10 +730,9 @@ static CMPIStatus GetInstance(CMPIInstan CMPIStatus s; CMPIInstance *inst; virConnectPtr conn = NULL; - char *id = NULL; - - id = cu_get_str_path(reference, "InstanceID"); - if (id == NULL) { + const char *id = NULL; + + if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -756,7 +755,6 @@ static CMPIStatus GetInstance(CMPIInstan out: - free(id); virConnectClose(conn); return s;

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID d144424ac5e89ea217f1a6dda6842c4b9643fb74 # Parent fde363d69d8db4a85a2fdc52cad40ccc5ccc4236 Fixes to RegisteredProfile for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r fde363d69d8d -r d144424ac5e8 src/Virt_RegisteredProfile.c --- a/src/Virt_RegisteredProfile.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_RegisteredProfile.c Wed Nov 28 09:50:29 2007 -0800 @@ -124,11 +124,10 @@ static CMPIStatus get_prof(const CMPIObj { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance = NULL; - char* id; + const char* id; int i; - id = cu_get_str_path(ref, "InstanceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, "No InstanceID specified"); @@ -149,9 +148,6 @@ static CMPIStatus get_prof(const CMPIObj CMReturnInstance(results, instance); else CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); - - - free(id); return s; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID 89505650ebf53eadacd7dbac45c5a0c5cd664907 # Parent d144424ac5e89ea217f1a6dda6842c4b9643fb74 Fixes to ECTP for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r d144424ac5e8 -r 89505650ebf5 src/Virt_ElementConformsToProfile.c --- a/src/Virt_ElementConformsToProfile.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_ElementConformsToProfile.c Wed Nov 28 09:50:29 2007 -0800 @@ -101,11 +101,10 @@ static CMPIStatus prof_to_elem(const CMP struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - char *id; + const char *id; int i; - id = cu_get_str_path(ref, "InstanceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, "No InstanceID specified"); @@ -116,13 +115,11 @@ static CMPIStatus prof_to_elem(const CMP if (STREQ(id, profiles[i]->reg_id)) { s = elem_instances(ref, info, list, profiles[i]); if ((s.rc != CMPI_RC_OK)) - goto error; + goto out; break; } } - - error: - free(id); + out: return s; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196272229 28800 # Node ID becc78027309750c7cfd300e55d33b9e774eef6a # Parent 89505650ebf53eadacd7dbac45c5a0c5cd664907 Changes to SettingsDefineCapabilities for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 89505650ebf5 -r becc78027309 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Wed Nov 28 09:50:29 2007 -0800 @@ -499,7 +499,7 @@ static struct sdc_rasd_prop *disk_max(co CMPIStatus *s) { bool ret; - char *inst_id; + const char *inst_id; CMPIrc prop_ret; uint16_t free_space; uint64_t free_64; @@ -507,8 +507,7 @@ static struct sdc_rasd_prop *disk_max(co CMPIInstance *pool_inst; struct sdc_rasd_prop *rasd = NULL; - inst_id = cu_get_str_path(ref, "InstanceID"); - if (inst_id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) { cu_statusf(_BROKER, s, CMPI_RC_ERR_FAILED, "Could not get InstanceID."); @@ -558,7 +557,6 @@ static struct sdc_rasd_prop *disk_max(co } out: - free(inst_id); return rasd; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196273290 28800 # Node ID 30dcc8eaa9a5455815dae18df6b0a98e7e352fc5 # Parent becc78027309750c7cfd300e55d33b9e774eef6a Fixes to ElementCapabilities for libcmpiutil API change Changes: - Updated to reflect new code in Kaitlin's recent patch - Fixed to *not* remove a valid STREQ() check in sys_to_cap() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r becc78027309 -r 30dcc8eaa9a5 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Wed Nov 28 09:50:29 2007 -0800 +++ b/src/Virt_ElementCapabilities.c Wed Nov 28 10:08:10 2007 -0800 @@ -53,8 +53,8 @@ static CMPIStatus sys_to_cap(const CMPIO { CMPIInstance *inst; CMPIrc host_rc; - char *host_name = NULL; - char *sys_name = NULL; + const char *host_name = NULL; + const char *sys_name = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; s = get_host_cs(_BROKER, ref, &inst); @@ -65,7 +65,13 @@ static CMPIStatus sys_to_cap(const CMPIO if (host_rc != CMPI_RC_OK) goto out; - sys_name = cu_get_str_path(ref, "Name"); + if (cu_get_str_path(ref, "Name", &sys_name) != CMPI_RC_OK) { + cu_statusf(_BROKER, *s, + CMPI_RC_ERR_FAILED, + "Missing `Name' property"); + goto out; + } + if (!STREQ(sys_name, host_name)) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "System '%s' is not a host system.", sys_name); @@ -76,7 +82,6 @@ static CMPIStatus sys_to_cap(const CMPIO if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); out: - free(sys_name); return s; } @@ -84,16 +89,15 @@ static CMPIStatus cap_to_sys(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - char *inst_id; + const char *inst_id; char *host; char *device; - char *host_name; + const char *host_name; CMPIrc host_rc; CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; - inst_id = cu_get_str_path(ref, "InstanceID"); - if (inst_id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Could not get InstanceID."); @@ -123,7 +127,6 @@ static CMPIStatus cap_to_sys(const CMPIO out: free(host); free(device); - free(inst_id); return s; } @@ -133,10 +136,9 @@ static CMPIStatus cs_to_cap(const CMPIOb { CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; - char *sys_name = NULL; - - sys_name = cu_get_str_path(ref, "Name"); - if (sys_name == NULL) { + const char *sys_name = NULL; + + if (cu_get_str_path(ref, "Name", &sys_name) != CMPI_RC_OK) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing key: Name"); @@ -148,8 +150,6 @@ static CMPIStatus cs_to_cap(const CMPIOb inst_list_add(list, inst); out: - free(sys_name); - return s; } @@ -157,15 +157,14 @@ static CMPIStatus cap_to_cs(const CMPIOb struct std_assoc_info *info, struct inst_list *list) { - char *inst_id; + const char *inst_id; char *host; char *device; CMPIInstance *inst; virConnectPtr conn; CMPIStatus s = {CMPI_RC_OK, NULL}; - inst_id = cu_get_str_path(ref, "InstanceID"); - if (inst_id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Could not get InstanceID."); @@ -191,7 +190,7 @@ static CMPIStatus cap_to_cs(const CMPIOb error1: free(host); free(device); - free(inst_id); + return s; } @@ -208,13 +207,12 @@ static CMPIStatus pool_to_alloc(const CM struct inst_list *list) { int ret; - char *inst_id; + const char *inst_id; uint16_t type; CMPIInstance *inst = NULL; CMPIStatus s = {CMPI_RC_OK}; - inst_id = cu_get_str_path(ref, "InstanceID"); - if (inst_id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, "Could not get InstanceID."); goto out; @@ -237,8 +235,6 @@ static CMPIStatus pool_to_alloc(const CM inst_list_add(list, inst); out: - free(inst_id); - return s; } static CMPIInstance *make_ref(const CMPIObjectPath *ref,

DS> + cu_statusf(_BROKER, *s, ^^ Should be &s. Forgot to qref before sending out the set. Fixed locally. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196273390 28800 # Node ID 03b1c5492150286774f9087cb273146553d86f37 # Parent 30dcc8eaa9a5455815dae18df6b0a98e7e352fc5 Fixes to VSSDComponent for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 30dcc8eaa9a5 -r 03b1c5492150 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Wed Nov 28 10:08:10 2007 -0800 +++ b/src/Virt_VSSDComponent.c Wed Nov 28 10:09:50 2007 -0800 @@ -117,15 +117,14 @@ static CMPIStatus rasd_to_vssd(const CMP { CMPIStatus s; CMPIInstance *vssd = NULL; - char *id = NULL; + const char *id = NULL; char *host = NULL; char *devid = NULL; int ret; ASSOC_MATCH(info->provider_name, CLASSNAME(ref)); - id = cu_get_str_path(ref, "InstanceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -145,7 +144,6 @@ static CMPIStatus rasd_to_vssd(const CMP inst_list_add(list, vssd); out: - free(id); free(host); free(devid);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196273390 28800 # Node ID e8350716e6731e00ba1d7e093d9cdef696a9f9bb # Parent 03b1c5492150286774f9087cb273146553d86f37 Fixes to SettingsDefineState for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 03b1c5492150 -r e8350716e673 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Wed Nov 28 10:09:50 2007 -0800 +++ b/src/Virt_SettingsDefineState.c Wed Nov 28 10:09:50 2007 -0800 @@ -46,7 +46,7 @@ static CMPIInstance *find_rasd(struct in CMPIInstance *inst; for (i = 0; i < list->cur; i++) { - char *id; + const char *id; int ret; inst = list->list[i]; @@ -55,12 +55,8 @@ static CMPIInstance *find_rasd(struct in if (ret != CMPI_RC_OK) continue; - if (STREQ(id, devid)) { - free(id); + if (STREQ(id, devid)) return inst; - } else { - free(id); - } } return NULL; @@ -73,15 +69,14 @@ static CMPIStatus dev_to_rasd(const CMPI CMPIStatus s; CMPIInstance *rasd; struct inst_list rasds; - char *id = NULL; + const char *id = NULL; char *name = NULL; char *devid = NULL; int ret; inst_list_init(&rasds); - id = cu_get_str_path(ref, "DeviceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "DeviceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing DeviceID"); @@ -109,14 +104,13 @@ static CMPIStatus dev_to_rasd(const CMPI CMSetStatus(&s, CMPI_RC_OK); out: - free(id); free(name); free(devid); return s; } -static CMPIInstance *_get_typed_device(char *id, +static CMPIInstance *_get_typed_device(const char *id, int type, const CMPIObjectPath *ref, CMPIStatus *s) @@ -161,13 +155,12 @@ static CMPIStatus rasd_to_dev(const CMPI { CMPIStatus s; CMPIInstance *dev = NULL; - char *id = NULL; + const char *id = NULL; uint16_t type; ASSOC_MATCH(info->provider_name, CLASSNAME(ref)); - id = cu_get_str_path(ref, "InstanceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -190,8 +183,6 @@ static CMPIStatus rasd_to_dev(const CMPI CMSetStatus(&s, CMPI_RC_OK); out: - free(id); - return s; } @@ -201,7 +192,7 @@ static CMPIStatus vs_to_vssd(const CMPIO { virConnectPtr conn = NULL; virDomainPtr dom = NULL; - char *name; + const char *name; CMPIInstance *vssd; CMPIStatus s; @@ -209,8 +200,7 @@ static CMPIStatus vs_to_vssd(const CMPIO if (conn == NULL) return s; - name = cu_get_str_path(ref, "Name"); - if (name == NULL) { + if (cu_get_str_path(ref, "Name", &name) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing Name property"); @@ -232,7 +222,6 @@ static CMPIStatus vs_to_vssd(const CMPIO CMSetStatus(&s, CMPI_RC_OK); out: - free(name); virDomainFree(dom); virConnectClose(conn); @@ -244,7 +233,7 @@ static CMPIStatus vssd_to_vs(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - char *id = NULL; + const char *id = NULL; char *pfx = NULL; char *name = NULL; int ret; @@ -252,8 +241,7 @@ static CMPIStatus vssd_to_vs(const CMPIO CMPIStatus s; CMPIInstance *cs; - id = cu_get_str_path(ref, "InstanceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -284,7 +272,6 @@ static CMPIStatus vssd_to_vs(const CMPIO out: free(name); free(pfx); - free(id); virConnectClose(conn);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196273390 28800 # Node ID 7d60f525a9732ff3635001565ae0ef8b72b38eb7 # Parent e8350716e6731e00ba1d7e093d9cdef696a9f9bb Fixes to RAFP for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r e8350716e673 -r 7d60f525a973 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Wed Nov 28 10:09:50 2007 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Wed Nov 28 10:09:50 2007 -0800 @@ -43,7 +43,7 @@ static CMPIStatus rasd_to_pool(const CMP { CMPIStatus s; uint16_t type; - char *id = NULL; + const char *id = NULL; char *poolid = NULL; virConnectPtr conn = NULL; struct inst_list _list; @@ -58,8 +58,7 @@ static CMPIStatus rasd_to_pool(const CMP goto out; } - id = cu_get_str_path(ref, "InstanceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -92,7 +91,6 @@ static CMPIStatus rasd_to_pool(const CMP } out: - free(id); free(poolid); virConnectClose(conn); inst_list_free(&_list); @@ -106,7 +104,7 @@ static int filter_by_pool(struct inst_li { int i; uint16_t type; - char *rasd_id = NULL; + const char *rasd_id = NULL; char *poolid = NULL; for (i = 0; i < src->cur; i++) { @@ -126,8 +124,6 @@ static int filter_by_pool(struct inst_li poolid = pool_member_of(_BROKER, CLASSNAME(op), type, rasd_id); if (STREQ(poolid, _poolid)) inst_list_add(dest, inst); - - free(rasd_id); } return dest->cur; @@ -182,10 +178,9 @@ static CMPIStatus pool_to_rasd(const CMP struct inst_list *list) { CMPIStatus s; - char *poolid; - - poolid = cu_get_str_path(ref, "InstanceID"); - if (poolid == NULL) { + const char *poolid; + + if (cu_get_str_path(ref, "InstanceID", &poolid) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -222,8 +217,6 @@ static CMPIStatus pool_to_rasd(const CMP CMSetStatus(&s, CMPI_RC_OK); out: - free(poolid); - return s; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196273390 28800 # Node ID d2ca8217aebe475321b531657cbebcf90cd755c2 # Parent 7d60f525a9732ff3635001565ae0ef8b72b38eb7 Fixes to EAFP for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 7d60f525a973 -r d2ca8217aebe src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Wed Nov 28 10:09:50 2007 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Wed Nov 28 10:09:50 2007 -0800 @@ -63,7 +63,7 @@ static CMPIStatus vdev_to_pool(const CMP { CMPIStatus s; uint16_t type; - char *id = NULL; + const char *id = NULL; char *poolid = NULL; virConnectPtr conn = NULL; CMPIInstance *pool = NULL; @@ -76,8 +76,7 @@ static CMPIStatus vdev_to_pool(const CMP goto out; } - id = cu_get_str_path(ref, "DeviceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "DeviceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing DeviceID"); @@ -107,7 +106,6 @@ static CMPIStatus vdev_to_pool(const CMP } out: - free(id); free(poolid); virConnectClose(conn); @@ -124,23 +122,20 @@ static int filter_by_pool(struct inst_li for (i = 0; i < src->cur; i++) { CMPIInstance *inst = src->list[i]; - char *cn = NULL; - char *dev_id = NULL; + const char *cn = NULL; + const char *dev_id = NULL; cu_get_str_prop(inst, "CreationClassName", &cn); cu_get_str_prop(inst, "DeviceID", &dev_id); if ((dev_id == NULL) || (cn == NULL)) - goto end; + continue; printf("Device %hhi:%s", type, dev_id); poolid = pool_member_of(_BROKER, cn, type, dev_id); if (poolid && STREQ(poolid, _poolid)) inst_list_add(dest, inst); - end: - free(dev_id); - free(cn); } return dest->cur; @@ -200,11 +195,10 @@ static CMPIStatus pool_to_vdev(const CMP struct std_assoc_info *info, struct inst_list *list) { - char *poolid; + const char *poolid; CMPIStatus s; - poolid = cu_get_str_path(ref, "InstanceID"); - if (poolid == NULL) { + if (cu_get_str_path(ref, "InstanceID", &poolid) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -244,8 +238,6 @@ static CMPIStatus pool_to_vdev(const CMP CMSetStatus(&s, CMPI_RC_OK); out: - free(poolid); - return s; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196273390 28800 # Node ID dbc8be685fa5a1588fad5dfec31310ef520c5007 # Parent d2ca8217aebe475321b531657cbebcf90cd755c2 Fixes to ElementSettingData for libcmpiutil API change Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r d2ca8217aebe -r dbc8be685fa5 src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Wed Nov 28 10:09:50 2007 -0800 +++ b/src/Virt_ElementSettingData.c Wed Nov 28 10:09:50 2007 -0800 @@ -90,13 +90,12 @@ static CMPIStatus rasd_to_rasd(const CMP { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - char *id = NULL; + const char *id = NULL; uint16_t type; ASSOC_MATCH(info->provider_name, CLASSNAME(ref)); - id = cu_get_str_path(ref, "InstanceID"); - if (id == NULL) { + if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -122,8 +121,6 @@ static CMPIStatus rasd_to_rasd(const CMP inst_list_add(list, inst); out: - free(id); - return s; }
participants (2)
-
Dan Smith
-
Kaitlin Rupert