[PATCH 0 of 6] Enhance ComputerSystem enum/get functions for use in assocs and Adopt interface changes to assocs

This patch set first enhances the ComputerSystem's enum and get functions to prepare a straight access to domain instances out of associations. Aterwards the interface changes are adopted to the corresponing associations providers.

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204541457 -3600 # Node ID 7a93b0ab4de3663e75f43176cce67b70e2064fd7 # Parent 27e78288c82426835126eaa07dba1e425c756f3f ComputerSystem: enhance enum functionality for use in assocs Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 27e78288c824 -r 7a93b0ab4de3 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Mon Mar 03 11:34:52 2008 +0100 +++ b/src/Virt_ComputerSystem.c Mon Mar 03 11:50:57 2008 +0100 @@ -302,184 +302,168 @@ static int set_other_id_info(const CMPIB } /* Populate an instance with information from a domain */ -static int instance_from_dom(const CMPIBroker *broker, - virDomainPtr dom, - const char *prefix, - CMPIInstance *instance) -{ +static CMPIStatus set_properties(const CMPIBroker *broker, + virDomainPtr dom, + const char *prefix, + CMPIInstance *instance) +{ + CMPIStatus s = {CMPI_RC_ERR_FAILED, NULL}; char *uuid = NULL; - int ret = 1; if (!set_name_from_dom(dom, instance)) { /* Print trace error */ - return 0; + goto out; } if (!set_uuid_from_dom(dom, instance, &uuid)) { /* Print trace error */ - ret = 0; goto out; } if (!set_capdesc_from_dom(dom, instance)) { /* Print trace error */ - ret = 0; goto out; } if (!set_state_from_dom(broker, dom, instance)) { /* Print trace error */ - ret = 0; goto out; } if (!set_creation_class(instance)) { /* Print trace error */ - ret = 0; goto out; } if (!set_other_id_info(broker, uuid, prefix, instance)) { /* Print trace error */ - ret = 0; goto out; } /* More attributes here, of course */ + cu_statusf(broker, &s, + CMPI_RC_OK, + ""); + out: free(uuid); - return ret; -} - -/* Given a hypervisor connection and a domain name, return an instance */ -CMPIInstance *instance_from_name(const CMPIBroker *broker, - virConnectPtr conn, - const char *name, - const CMPIObjectPath *op) -{ - virDomainPtr dom; - CMPIInstance *instance; - - dom = virDomainLookupByName(conn, name); - if (dom == NULL) - return NULL; - - instance = get_typed_instance(broker, - pfx_from_conn(conn), - "ComputerSystem", - NAMESPACE(op)); - if (instance == NULL) - goto out; - - if (!instance_from_dom(broker, - dom, - pfx_from_conn(conn), - instance)) - instance = NULL; - - out: - virDomainFree(dom); - - return instance; -} - -/* Enumerate domains on the given connection, return results */ -int enum_domains(const CMPIBroker *broker, - virConnectPtr conn, - const char *ns, - struct inst_list *instlist) -{ + return s; +} + +static CMPIStatus instance_from_dom(const CMPIBroker *broker, + const CMPIObjectPath *reference, + virConnectPtr conn, + virDomainPtr domain, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "ComputerSystem", + NAMESPACE(reference)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to init ComputerSystem instance"); + goto out; + } + + s = set_properties(broker, + domain, + pfx_from_conn(conn), + inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: + return s; +} + +CMPIStatus enum_domains(const CMPIBroker *broker, + const CMPIObjectPath *reference, + struct inst_list *instlist) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; virDomainPtr *list = NULL; + virConnectPtr conn = NULL; int count; int i; + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) + goto out; + count = get_domain_list(conn, &list); - if (count <= 0) - goto out; + if (count <= 0) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to get domain list"); + goto out; + } for (i = 0; i < count; i++) { - CMPIInstance *inst; - - inst = get_typed_instance(broker, - pfx_from_conn(conn), - "ComputerSystem", - ns); - if (inst == NULL) + CMPIInstance *inst = NULL; + + s = instance_from_dom(broker, + reference, + conn, + list[i], + &inst); + if (s.rc != CMPI_RC_OK) goto end; - if (instance_from_dom(broker, - list[i], - pfx_from_conn(conn), - inst)) - inst_list_add(instlist, inst); - - end: + inst_list_add(instlist, inst); + + end: virDomainFree(list[i]); } - out: + + out: + virConnectClose(conn); free(list); - return 1; + return s; } static CMPIStatus return_enum_domains(const CMPIObjectPath *reference, const CMPIResult *results, - int names_only) + bool names_only) { struct inst_list list; - CMPIStatus s; - virConnectPtr conn = NULL; - int ret; - - conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); - if (conn == NULL) - return s; + CMPIStatus s = {CMPI_RC_OK, NULL}; inst_list_init(&list); - ret = enum_domains(_BROKER, conn, NAMESPACE(reference), &list); - if (!ret) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Failed to get domain list"); - goto out; - } + + s = enum_domains(_BROKER, reference, &list); + if (s.rc != CMPI_RC_OK) + goto out; if (names_only) cu_return_instance_names(results, &list); else cu_return_instances(results, &list); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: inst_list_free(&list); - virConnectClose(conn); - - return s; -} - -CMPIStatus get_domain(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **inst) -{ - CMPIInstance *_inst; + return s; +} + +CMPIStatus get_domain_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst) +{ + CMPIInstance *inst = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; virConnectPtr conn = NULL; - const char *name; - - if (!provider_is_responsible(broker, reference, &s)) - return s; - - if (cu_get_str_path(reference, "Name", &name) != CMPI_RC_OK) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "No domain name specified"); - return s; - } + virDomainPtr dom; conn = connect_by_classname(broker, CLASSNAME(reference), &s); if (conn == NULL) { @@ -489,35 +473,59 @@ CMPIStatus get_domain(const CMPIBroker * return s; } - _inst = instance_from_name(broker, conn, name, reference); - if (_inst == NULL) { + dom = virDomainLookupByName(conn, name); + if (dom == NULL) { cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", name); - goto out; - } - - s = cu_validate_ref(broker, reference, _inst); - - out: + "No such instance (%s).", + name); + goto out; + } + + s = instance_from_dom(broker, + reference, + conn, + dom, + &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: + virDomainFree(dom); virConnectClose(conn); - *inst = _inst; - - return s; -} - -static CMPIStatus return_domain(const CMPIObjectPath *reference, - const CMPIResult *results) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - - s = get_domain(_BROKER, reference, &inst); + + return s; +} + +CMPIStatus get_domain_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + const char *name = NULL; + + if (cu_get_str_path(reference, "Name", &name) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "No domain name specified"); + goto out; + } + + s = get_domain_by_name(broker, reference, name, &inst); if (s.rc != CMPI_RC_OK) - return s; - - CMReturnInstance(results, inst); - + goto out; + + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: + return s; } @@ -526,7 +534,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_enum_domains(reference, results, 1); + return return_enum_domains(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -536,7 +544,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_enum_domains(reference, results, 0); + return return_enum_domains(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -545,7 +553,17 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - return return_domain(reference, results); + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; + + s = get_domain_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: + return s; } DEFAULT_CI(); diff -r 27e78288c824 -r 7a93b0ab4de3 src/Virt_ComputerSystem.h --- a/src/Virt_ComputerSystem.h Mon Mar 03 11:34:52 2008 +0100 +++ b/src/Virt_ComputerSystem.h Mon Mar 03 11:50:57 2008 +0100 @@ -24,33 +24,16 @@ #include "misc_util.h" /** - * Return an instance of a Virt_ComputerSystem, based on a name - * - * @param broker A pointer to the current broker - * @param conn The libvirt connection to use - * @param name The name of the desired domain instance - * @param ns The namespace to use - * @returns The instance or NULL on failure - */ -CMPIInstance *instance_from_name(const CMPIBroker *broker, - virConnectPtr conn, - const char *name, - const CMPIObjectPath *ns); - - -/** * Get a list of domain instances * * @param broker A pointer to the current broker - * @param conn The libvirt connection to use - * @param op The namespace to use + * @param reference The object path containing namespace and prefix info * @param instlist A pointer to an initialized inst_list to populate - * @returns nonzero on success + * @returns CMPIStatus */ -int enum_domains(const CMPIBroker *broker, - virConnectPtr conn, - const char *ns, - struct inst_list *instlist); +CMPIStatus enum_domains(const CMPIBroker *broker, + const CMPIObjectPath *reference, + struct inst_list *instlist); /** * Get domain instance specified by the client given domain @@ -58,13 +41,26 @@ int enum_domains(const CMPIBroker *broke * * @param broker A pointer to the current broker * @param ref The client given object path - * @param inst In case of success the pointer to the instance + * @param _inst In case of success the pointer to the instance * @returns CMPIStatus */ -CMPIStatus get_domain(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **inst); +CMPIStatus get_domain_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); +/** + * Get domain instance specified by the domain name + * + * @param broker A pointer to the current broker + * @param ref The object path containing namespace and prefix info + * @param name The domain name + * @param _inst In case of success the pointer to the instance + * @returns CMPIStatus + */ +CMPIStatus get_domain_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst); #endif

Heidi Eckhart wrote:
# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204541457 -3600 # Node ID 7a93b0ab4de3663e75f43176cce67b70e2064fd7 # Parent 27e78288c82426835126eaa07dba1e425c756f3f ComputerSystem: enhance enum functionality for use in assocs Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com>
+CMPIStatus enum_domains(const CMPIBroker *broker, + const CMPIObjectPath *reference, + struct inst_list *instlist) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; virDomainPtr *list = NULL; + virConnectPtr conn = NULL; int count; int i;
+ conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) + goto out; + count = get_domain_list(conn, &list); - if (count <= 0) - goto out; + if (count <= 0) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to get domain list"); + goto out; + }
for (i = 0; i < count; i++) { - CMPIInstance *inst; - - inst = get_typed_instance(broker, - pfx_from_conn(conn), - "ComputerSystem", - ns); - if (inst == NULL) + CMPIInstance *inst = NULL; + + s = instance_from_dom(broker, + reference, + conn, + list[i], + &inst); + if (s.rc != CMPI_RC_OK) goto end;
- if (instance_from_dom(broker, - list[i], - pfx_from_conn(conn), - inst)) - inst_list_add(instlist, inst); - - end: + inst_list_add(instlist, inst); + + end: virDomainFree(list[i]); } - out: + + out: + virConnectClose(conn); free(list);
- return 1; + return s; }
This isn't so much a problem with the patch as it is something brought to my attention by the patch, but I'm not a huge fan of the "goto end;" bit in the for loop. I know we use "goto out;" a ton for error cases, which I've gotten used to, but I'm still not a big fan of using goto and in this case I think we could avoid it without much trouble. Something like: if (s.rc != CMPI_RC_OK) { virDomainFree(list[i]); continue; } should achieve the same functionality but in what I would call a much cleaner way. Everyone, feel free to chime in here one way or the other. -- -Jay

JG> if (s.rc != CMPI_RC_OK) { JG> virDomainFree(list[i]); JG> continue; JG> } JG> should achieve the same functionality but in what I would call a much JG> cleaner way. Everyone, feel free to chime in here one way or the JG> other. That's a valid point, although I would rather have one cleanup path to avoid leaks in the future. Why not just have the conditional be (s.rc == CMPI_RC_OK) and do the add there? Anyway, it's minor so I've applied this patch set. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
JG> if (s.rc != CMPI_RC_OK) { JG> virDomainFree(list[i]); JG> continue; JG> }
JG> should achieve the same functionality but in what I would call a much JG> cleaner way. Everyone, feel free to chime in here one way or the JG> other.
That's a valid point, although I would rather have one cleanup path to avoid leaks in the future. Why not just have the conditional be (s.rc == CMPI_RC_OK) and do the add there?
Anyway, it's minor so I've applied this patch set.
Fine - for me both points are valid and I will take care of them in the future and apply where necessary and as possible :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204541458 -3600 # Node ID 15e12adf6218a512063fe87b836b87e8e3aed569 # Parent 7a93b0ab4de3663e75f43176cce67b70e2064fd7 SD: adopt changes in ComputerSystem provider interface Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 7a93b0ab4de3 -r 15e12adf6218 src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Mon Mar 03 11:50:57 2008 +0100 +++ b/src/Virt_SystemDevice.c Mon Mar 03 11:50:58 2008 +0100 @@ -97,37 +97,6 @@ static int get_all_devices(const char *n return i; } -static CMPIInstance *host_instance(char *name, - const CMPIObjectPath *ref) -{ - CMPIInstance *inst = NULL; - virConnectPtr conn = NULL; - CMPIStatus s; - CMPIObjectPath *op; - char *host_class; - - host_class = get_typed_class(CLASSNAME(ref), - "ComputerSystem"); - if (host_class == NULL) - goto out; - - op = CMNewObjectPath(_BROKER, NAMESPACE(ref), host_class, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) - goto out; - - conn = connect_by_classname(_BROKER, host_class, &s); - if (conn == NULL) - goto out; - - inst = instance_from_name(_BROKER, conn, name, op); - - out: - free(host_class); - virConnectClose(conn); - - return inst; -} - static CMPIStatus sys_to_dev(const CMPIObjectPath *ref, struct std_assoc_info *info, struct inst_list *list) @@ -140,7 +109,7 @@ static CMPIStatus sys_to_dev(const CMPIO if (!match_hypervisor_prefix(ref, info)) return s; - s = get_domain(_BROKER, ref, &inst); + s = get_domain_by_ref(_BROKER, ref, &inst); if (s.rc != CMPI_RC_OK) goto out; @@ -177,7 +146,6 @@ static CMPIStatus dev_to_sys(const CMPIO const char *devid = NULL; char *host = NULL; char *dev = NULL; - CMPIInstance *sys; CMPIInstance *inst = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -202,18 +170,11 @@ static CMPIStatus dev_to_sys(const CMPIO goto out; } - sys = host_instance(host, ref); - - if (sys == NULL) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to find DeviceID `%s'", devid); - else { - inst_list_add(list, sys); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - } + s = get_domain_by_name(_BROKER, ref, host, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); out: free(dev);

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204541459 -3600 # Node ID f6c14b91e8da58e79221b9e7ccb652419dffcc23 # Parent 15e12adf6218a512063fe87b836b87e8e3aed569 VSMS: adopt ComputerSystem interface changes Adopt the interface changes of ComputerSystem to connect_and_create(). Also added missing virDomainFree(). Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 15e12adf6218 -r f6c14b91e8da src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Mar 03 11:50:58 2008 +0100 +++ b/src/Virt_VirtualSystemManagementService.c Mon Mar 03 11:50:59 2008 +0100 @@ -331,7 +331,7 @@ static CMPIInstance *connect_and_create( virConnectPtr conn; virDomainPtr dom; const char *name; - CMPIInstance *inst; + CMPIInstance *inst = NULL; conn = connect_by_classname(_BROKER, CLASSNAME(ref), s); if (conn == NULL) { @@ -349,14 +349,16 @@ static CMPIInstance *connect_and_create( } name = virDomainGetName(dom); - inst = instance_from_name(_BROKER, conn, (char *)name, ref); - if (inst == NULL) { + + *s = get_domain_by_name(_BROKER, ref, name, &inst); + if (s->rc != CMPI_RC_OK) { CU_DEBUG("Failed to get new instance"); cu_statusf(_BROKER, s, CMPI_RC_ERR_FAILED, "Failed to lookup resulting system"); } + virDomainFree(dom); virConnectClose(conn); return inst;

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204541459 -3600 # Node ID a92cf052a7742789abbec11a463578fb4f8ae24d # Parent f6c14b91e8da58e79221b9e7ccb652419dffcc23 HD: adopt ComputerSystem interface changes Adopted interface changes to ComputerSystem. Fixed wrong return in vs_to_host(). Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r f6c14b91e8da -r a92cf052a774 src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Mon Mar 03 11:50:59 2008 +0100 +++ b/src/Virt_HostedDependency.c Mon Mar 03 11:50:59 2008 +0100 @@ -46,7 +46,7 @@ static CMPIStatus vs_to_host(const CMPIO if (!match_hypervisor_prefix(ref, info)) goto out; - s = get_domain(_BROKER, ref, &instance); + s = get_domain_by_ref(_BROKER, ref, &instance); if (s.rc != CMPI_RC_OK) goto out; @@ -64,8 +64,6 @@ static CMPIStatus host_to_vs(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - int ret; - virConnectPtr conn; CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance = NULL; @@ -76,19 +74,7 @@ static CMPIStatus host_to_vs(const CMPIO if (s.rc != CMPI_RC_OK) goto out; - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance"); - goto out; - } - - ret = enum_domains(_BROKER, conn, NAMESPACE(ref), list); - if (!ret) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Failed to get domain list"); + s = enum_domains(_BROKER, ref, list); out: return s;

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204541460 -3600 # Node ID 5c6274463420e89bebccb718d310b53c7f712909 # Parent a92cf052a7742789abbec11a463578fb4f8ae24d EC: adopt ComputerSystem interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r a92cf052a774 -r 5c6274463420 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Mar 03 11:50:59 2008 +0100 +++ b/src/Virt_ElementCapabilities.c Mon Mar 03 11:51:00 2008 +0100 @@ -205,7 +205,7 @@ static CMPIStatus cs_to_cap(const CMPIOb if (!match_hypervisor_prefix(ref, info)) goto out; - s = get_domain(_BROKER, ref, &inst); + s = get_domain_by_ref(_BROKER, ref, &inst); if (s.rc != CMPI_RC_OK) goto out; @@ -229,8 +229,7 @@ static CMPIStatus cap_to_cs(const CMPIOb struct inst_list *list) { const char *inst_id; - CMPIInstance *inst; - virConnectPtr conn; + CMPIInstance *inst = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; if (!match_hypervisor_prefix(ref, info)) @@ -247,19 +246,11 @@ static CMPIStatus cap_to_cs(const CMPIOb goto out; } - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - inst = instance_from_name(_BROKER, conn, inst_id, ref); - if (inst) - inst_list_add(list, inst); - else - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", inst_id); - - virConnectClose(conn); + s = get_domain_by_name(_BROKER, ref, inst_id, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); out: return s;

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204541460 -3600 # Node ID eefe9c56b43c7ca0cad6f579fd88c5b89134bba0 # Parent 5c6274463420e89bebccb718d310b53c7f712909 SDS: adopt ComputerSystem interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 5c6274463420 -r eefe9c56b43c src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Mon Mar 03 11:51:00 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Mon Mar 03 11:51:00 2008 +0100 @@ -127,7 +127,7 @@ static CMPIStatus vs_to_vssd(const CMPIO if (!match_hypervisor_prefix(ref, info)) return s; - s = get_domain(_BROKER, ref, &inst); + s = get_domain_by_ref(_BROKER, ref, &inst); if (s.rc != CMPI_RC_OK) goto out; @@ -156,10 +156,8 @@ static CMPIStatus vssd_to_vs(const CMPIO char *pfx = NULL; char *name = NULL; int ret; - virConnectPtr conn = NULL; - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *cs; - CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) return s; @@ -183,25 +181,15 @@ static CMPIStatus vssd_to_vs(const CMPIO goto out; } - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - cs = instance_from_name(_BROKER, - conn, - name, - ref); - if (cs != NULL) - inst_list_add(list, cs); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); + s = get_domain_by_name(_BROKER, ref, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); + out: free(name); free(pfx); - - virConnectClose(conn); return s; }

Heidi Eckhart wrote:
This patch set first enhances the ComputerSystem's enum and get functions to prepare a straight access to domain instances out of associations. Aterwards the interface changes are adopted to the corresponing associations providers.
This looks good. I noticed one thing, but it's more or less a style issue and not worth holding the patchset back, especially since it appears to have existed before the patch. I will note it in a reply to that patch, just to help us remember it. +1 -- -Jay
participants (3)
-
Dan Smith
-
Heidi Eckhart
-
Jay Gagnon