[PATCH 0 of 5] 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.

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204286653 -3600 # Node ID b0bc7c2f51e4585b3b0f3d2548ccee6e625aa670 # Parent 2fe6a1864de83ecfabf7eaae8c9a912af39b8ecc 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 2fe6a1864de8 -r b0bc7c2f51e4 src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Thu Feb 28 14:43:44 2008 -0800 +++ b/src/Virt_HostSystem.c Fri Feb 29 13:04:13 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 2fe6a1864de8 -r b0bc7c2f51e4 src/Virt_HostSystem.h --- a/src/Virt_HostSystem.h Thu Feb 28 14:43:44 2008 -0800 +++ b/src/Virt_HostSystem.h Fri Feb 29 13:04:13 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 1204286655 -3600 # Node ID 2c8c7521952cbd89db590822bca22775f07fc8e2 # Parent b0bc7c2f51e4585b3b0f3d2548ccee6e625aa670 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 b0bc7c2f51e4 -r 2c8c7521952c src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Fri Feb 29 13:04:13 2008 +0100 +++ b/src/Virt_HostedDependency.c Fri Feb 29 13:04:15 2008 +0100 @@ -41,15 +41,20 @@ 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); + out: return s; } @@ -60,29 +65,29 @@ 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; + 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 1204286656 -3600 # Node ID a637832c90faefaf61e674740089774baca4abb9 # Parent 2c8c7521952cbd89db590822bca22775f07fc8e2 HRP: adopt HostSystem interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 2c8c7521952c -r a637832c90fa src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Fri Feb 29 13:04:15 2008 +0100 +++ b/src/Virt_HostedResourcePool.c Fri Feb 29 13:04:16 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 1204286657 -3600 # Node ID 9516232d810b1b7a0e5c9da5801ef96fdbc1775e # Parent a637832c90faefaf61e674740089774baca4abb9 EC: adopt HostSystem interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r a637832c90fa -r 9516232d810b src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Fri Feb 29 13:04:16 2008 +0100 +++ b/src/Virt_ElementCapabilities.c Fri Feb 29 13:04:17 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 1204286657 -3600 # Node ID cddf4a1cab91fa0a375dfb18c7780022e7f322b9 # Parent 9516232d810b1b7a0e5c9da5801ef96fdbc1775e HS: adopt HostSystem interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 9516232d810b -r cddf4a1cab91 src/Makefile.am --- a/src/Makefile.am Fri Feb 29 13:04:17 2008 +0100 +++ b/src/Makefile.am Fri Feb 29 13:04:17 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 9516232d810b -r cddf4a1cab91 src/Virt_HostedService.c --- a/src/Virt_HostedService.c Fri Feb 29 13:04:17 2008 +0100 +++ b/src/Virt_HostedService.c Fri Feb 29 13:04:17 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;
participants (1)
-
Heidi Eckhart