[PATCH 0 of 5] #2 - Update single instance interface on HostSystem and Adopt HostSystem interface to assocs

This patch set update the HostSystem provider to follow the common look and feel of single instance providers. The interface changes on HostSystem have been adopted to the associations HD, HRP, EC and HS. diff to patch set 1: fixed HD - missing braces (thanks to eagle eye kaitlin

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204534935 -3600 # Node ID 7957f5828b31c7d557f828e0d9b63eaaebd6db0f # Parent e61accae90e146b1eb57eade5d397a9fe2047a52 HostSystem: adopt interface of single instance providers During the last updates to single instance providers, a common interface look and feel has established. This patch adopts these changes to HostSystem. Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r e61accae90e1 -r 7957f5828b31 src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Fri Feb 29 06:55:11 2008 -0800 +++ b/src/Virt_HostSystem.c Mon Mar 03 10:02:15 2008 +0100 @@ -36,19 +36,6 @@ const static CMPIBroker *_BROKER; -CMPIStatus validate_host_ref(const CMPIBroker *broker, - const CMPIObjectPath *ref) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - - s = get_host_cs(broker, ref, &inst); - if (inst != NULL) - s = cu_validate_ref(broker, ref, inst); - - return s; -} - static int set_host_system_properties(CMPIInstance *instance) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -70,18 +57,23 @@ static int set_host_system_properties(CM return 1; } -CMPIStatus get_host_cs(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance) +CMPIStatus get_host(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst, + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; virConnectPtr conn = NULL; - *instance = NULL; conn = connect_by_classname(broker, CLASSNAME(reference), &s); - if (conn == NULL) - return s; + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } inst = get_typed_instance(broker, pfx_from_conn(conn), @@ -97,43 +89,36 @@ CMPIStatus get_host_cs(const CMPIBroker set_host_system_properties(inst); - out: - virConnectClose(conn); - *instance = inst; - - return s; -} - -static CMPIStatus return_host_cs(const CMPIObjectPath *reference, - const CMPIResult *results, - bool name_only, - bool is_get_inst) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *instance; - - s = get_host_cs(_BROKER, reference, &instance); - if (s.rc != CMPI_RC_OK) - goto out; - - if (instance == NULL) { - if (is_get_inst) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance"); - goto out; - } - if (is_get_inst) { - s = cu_validate_ref(_BROKER, reference, instance); + s = cu_validate_ref(broker, reference, inst); if (s.rc != CMPI_RC_OK) goto out; } + *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_host(const CMPIObjectPath *reference, + const CMPIResult *results, + bool name_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_host(_BROKER, reference, &inst, is_get_inst); + if (s.rc != CMPI_RC_OK || inst == NULL) + goto out; + if (name_only) - cu_return_instance_name(results, instance); + cu_return_instance_name(results, inst); else - CMReturnInstance(results, instance); + CMReturnInstance(results, inst); out: return s; @@ -147,8 +132,8 @@ CMPIStatus get_host_system_properties(co CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *host = NULL; - s = get_host_cs(broker, ref, &host); - if (s.rc != CMPI_RC_OK) + s = get_host(broker, ref, &host, false); + if (s.rc != CMPI_RC_OK || host == NULL) goto out; if (cu_get_str_prop(host, "Name", name) != CMPI_RC_OK) { @@ -174,10 +159,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_host_cs(reference, - results, - true, - false); + return return_host(reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -187,10 +169,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_host_cs(reference, - results, - false, - false); + return return_host(reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -199,10 +178,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - return return_host_cs(reference, - results, - false, - true); + return return_host(reference, results, false, true); } DEFAULT_CI(); diff -r e61accae90e1 -r 7957f5828b31 src/Virt_HostSystem.h --- a/src/Virt_HostSystem.h Fri Feb 29 06:55:11 2008 -0800 +++ b/src/Virt_HostSystem.h Mon Mar 03 10:02:15 2008 +0100 @@ -21,16 +21,14 @@ #ifndef __VIRT_HOSTSYSTEM_H #define __VIRT_HOSTSYSTEM_H -CMPIStatus get_host_cs(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance); +CMPIStatus get_host(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst, + bool is_get_inst); CMPIStatus get_host_system_properties(const char **name, const char **ccname, const CMPIObjectPath *ref, const CMPIBroker *broker); -CMPIStatus validate_host_ref(const CMPIBroker *broker, - const CMPIObjectPath *ref); - #endif

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204540080 -3600 # Node ID d6992120c4edd5643f53edfe2255d5a1a657ba80 # Parent 7957f5828b31c7d557f828e0d9b63eaaebd6db0f HD: validate client given object path wbemain -ac KVM_HostedDependency 'http://localhost/root/virt:KVM_HostSystem.CreationClassName="KVM_HostSystem",Name="wrong"' returns instances instead of NOT_FOUND wbemain -ac CIM_HostedDependency 'http://localhost/root/virt:KVM_ComputerSystem.CreationClassName="KVM_ComputerSystem",Name="wrong"' returns an instance instead of NOT_FOUND Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 7957f5828b31 -r d6992120c4ed src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Mon Mar 03 10:02:15 2008 +0100 +++ b/src/Virt_HostedDependency.c Mon Mar 03 11:28:00 2008 +0100 @@ -41,15 +41,22 @@ static CMPIStatus vs_to_host(const CMPIO struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *instance; + CMPIInstance *instance = NULL; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; - s = get_host_cs(_BROKER, ref, &instance); + s = get_domain(_BROKER, ref, &instance); + if (s.rc != CMPI_RC_OK) + goto out; + + s = get_host(_BROKER, ref, &instance, false); if (s.rc == CMPI_RC_OK) - inst_list_add(list, instance); + goto out; + inst_list_add(list, instance); + + out: return s; } @@ -60,29 +67,30 @@ static CMPIStatus host_to_vs(const CMPIO int ret; virConnectPtr conn; CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *instance = NULL; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; + + s = get_host(_BROKER, ref, &instance, true); + if (s.rc != CMPI_RC_OK) + goto out; conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - return 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_OK, - ""); - } else { + if (!ret) cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Failed to get domain list"); - } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - + out: return s; }

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204540082 -3600 # Node ID 74515c28683ce659b54af726d7bc5cec62995df1 # Parent d6992120c4edd5643f53edfe2255d5a1a657ba80 HRP: adopt HostSystem interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r d6992120c4ed -r 74515c28683c src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Mon Mar 03 11:28:00 2008 +0100 +++ b/src/Virt_HostedResourcePool.c Mon Mar 03 11:28:02 2008 +0100 @@ -41,23 +41,23 @@ static CMPIStatus pool_to_sys(const CMPI struct std_assoc_info *info, struct inst_list *list) { - CMPIInstance *host; CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; s = get_pool_inst(_BROKER, ref, &inst); if ((s.rc != CMPI_RC_OK) || (inst == NULL)) - return s; + goto out; - s = get_host_cs(_BROKER, ref, &host); + s = get_host(_BROKER, ref, &inst, false); if (s.rc != CMPI_RC_OK) - return s; + goto out; - inst_list_add(list, host); + inst_list_add(list, inst); + out: return s; } @@ -66,19 +66,20 @@ static CMPIStatus sys_to_pool(const CMPI struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; int i; virConnectPtr conn; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; - s = validate_host_ref(_BROKER, ref); + s = get_host(_BROKER, ref, &inst, true); if (s.rc != CMPI_RC_OK) - return s; + goto out; conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) - return s; + goto out; for (i = 0; device_pool_names[i]; i++) get_pool_by_type(_BROKER, @@ -87,10 +88,7 @@ static CMPIStatus sys_to_pool(const CMPI NAMESPACE(ref), list); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - + out: return s; }

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204540491 -3600 # Node ID 9b3626d6b286b7e7190b4a760c349a45985ec5f2 # Parent 74515c28683ce659b54af726d7bc5cec62995df1 EC: adopt HostSystem interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 74515c28683c -r 9b3626d6b286 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Mar 03 11:28:02 2008 +0100 +++ b/src/Virt_ElementCapabilities.c Mon Mar 03 11:34:51 2008 +0100 @@ -125,13 +125,13 @@ static CMPIStatus sys_to_cap(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - CMPIInstance *inst; - CMPIStatus s = {CMPI_RC_OK, NULL}; - - if (!match_hypervisor_prefix(ref, info)) - goto out; - - s = validate_host_ref(_BROKER, ref); + CMPIInstance *inst = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = get_host(_BROKER, ref, &inst, true); if (s.rc != CMPI_RC_OK) goto out; @@ -164,7 +164,7 @@ static CMPIStatus cap_to_sys_or_service( if (inst != NULL) inst_list_add(list, inst); - s = get_host_cs(_BROKER, ref, &inst); + s = get_host(_BROKER, ref, &inst, false); if (s.rc != CMPI_RC_OK) goto out;

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204540492 -3600 # Node ID 27e78288c82426835126eaa07dba1e425c756f3f # Parent 9b3626d6b286b7e7190b4a760c349a45985ec5f2 HS: adopt HostSystem interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 9b3626d6b286 -r 27e78288c824 src/Makefile.am --- a/src/Makefile.am Mon Mar 03 11:34:51 2008 +0100 +++ b/src/Makefile.am Mon Mar 03 11:34:52 2008 +0100 @@ -54,10 +54,10 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_SettingsDefineState.la \ libVirt_ResourceAllocationFromPool.la \ libVirt_ElementAllocatedFromPool.la \ + libVirt_VSMigrationService.la \ libVirt_HostedService.la \ libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ - libVirt_VSMigrationService.la \ libVirt_VSMigrationSettingData.la \ libVirt_VirtualSystemSnapshotService.la \ libVirt_VirtualSystemSnapshotServiceCapabilities.la diff -r 9b3626d6b286 -r 27e78288c824 src/Virt_HostedService.c --- a/src/Virt_HostedService.c Mon Mar 03 11:34:51 2008 +0100 +++ b/src/Virt_HostedService.c Mon Mar 03 11:34:52 2008 +0100 @@ -40,8 +40,7 @@ static CMPIStatus validate_service_ref(c static CMPIStatus validate_service_ref(const CMPIObjectPath *ref) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - const char *prop; + CMPIInstance *inst = NULL; char* classname; classname = class_base_name(CLASSNAME(ref)); @@ -54,17 +53,6 @@ static CMPIStatus validate_service_ref(c s = get_migration_service(ref, &inst, _BROKER, true); } - if (s.rc != CMPI_RC_OK) - goto out; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } - - out: free(classname); return s; @@ -75,7 +63,7 @@ static CMPIStatus service_to_host(const struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *instance; + CMPIInstance *instance = NULL; if (!match_hypervisor_prefix(ref, info)) return s; @@ -84,7 +72,7 @@ static CMPIStatus service_to_host(const if (s.rc != CMPI_RC_OK) return s; - s = get_host_cs(_BROKER, ref, &instance); + s = get_host(_BROKER, ref, &instance, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, instance); @@ -96,12 +84,12 @@ static CMPIStatus host_to_service(const struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) return s; - s = validate_host_ref(_BROKER, ref); + s = get_host(_BROKER, ref, &inst, true); if (s.rc != CMPI_RC_OK) return s;

HE> fixed HD - missing braces (thanks to eagle eye kaitlin I had already applied your previous set to my tree along with Kaitlin's brace patch. I'm assuming this set is otherwise unchanged, right? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
HE> fixed HD - missing braces (thanks to eagle eye kaitlin
I had already applied your previous set to my tree along with Kaitlin's brace patch. I'm assuming this set is otherwise unchanged, right?
Yes, no problem. The result is the same. Thanks :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor
participants (2)
-
Dan Smith
-
Heidi Eckhart