[PATCH 0 of 3] Reference SBLIM host system when possible

This patch set (eventually) makes the providers return references to the SBLIM Linux_ComputerSystem instance, if that provider is available. This makes all of the Hosted* associations (and others) correctly point to the SBLIM provider when possible. As a fallback, we continue to return our fake instances if the SBLIM provider isn't installed.

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1219180404 25200 # Node ID a55c6df52f5e8108d3e1dc978a2f3b8b32db71dc # Parent 80e6ea1a1a296d424e15b3771d6753c3f8bbc5d1 Add context pointer to get_host() and get_host_system_properties() ...and fix all the associated calls. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_ComputerSystemIndication.c Tue Aug 19 14:13:24 2008 -0700 @@ -193,6 +193,7 @@ } static void set_source_inst_props(const CMPIBroker *broker, + const CMPIContext *context, CMPIObjectPath *ref, CMPIInstance *ind) { @@ -209,7 +210,7 @@ (CMPIValue *)&str, CMPI_string); } - s = get_host_system_properties(&host, &hostccn, ref, broker); + s = get_host_system_properties(&host, &hostccn, ref, broker, context); if (s.rc != CMPI_RC_OK) { CU_DEBUG("Unable to get host properties (%s): %s", CLASSNAME(ref), CMGetCharPtr(s.msg)); @@ -276,7 +277,7 @@ break; } - set_source_inst_props(broker, affected_op, ind); + set_source_inst_props(broker, ctx, affected_op, ind); CU_DEBUG("Delivering Indication: %s", CMGetCharPtr(CMObjectPathToString(ind_op, NULL))); diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_ElementCapabilities.c Tue Aug 19 14:13:24 2008 -0700 @@ -53,7 +53,8 @@ const static CMPIBroker *_BROKER; -static CMPIStatus validate_caps_get_service(const CMPIObjectPath *ref, +static CMPIStatus validate_caps_get_service(const CMPIContext *context, + const CMPIObjectPath *ref, CMPIInstance **inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -67,13 +68,13 @@ if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; - s = get_vsms(ref, &_inst, _BROKER, false); + s = get_vsms(ref, &_inst, _BROKER, context, false); } else if (STREQC(classname, "VirtualSystemMigrationCapabilities")) { s = get_migration_caps(ref, &_inst, _BROKER, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; - s = get_migration_service(ref, &_inst, _BROKER, false); + s = get_migration_service(ref, &_inst, _BROKER, context, false); } else cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, @@ -90,7 +91,8 @@ return s; } -static CMPIStatus validate_service_get_caps(const CMPIObjectPath *ref, +static CMPIStatus validate_service_get_caps(const CMPIContext *context, + const CMPIObjectPath *ref, CMPIInstance **inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -100,13 +102,13 @@ classname = class_base_name(CLASSNAME(ref)); if (STREQC(classname, "VirtualSystemManagementService")) { - s = get_vsms(ref, &_inst, _BROKER, true); + s = get_vsms(ref, &_inst, _BROKER, context, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; s = get_vsm_cap(_BROKER, ref, &_inst, false); } else if (STREQC(classname, "VirtualSystemMigrationService")) { - s = get_migration_service(ref, &_inst, _BROKER, true); + s = get_migration_service(ref, &_inst, _BROKER, context, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; @@ -134,7 +136,7 @@ if (!match_hypervisor_prefix(ref, info)) goto out; - s = get_host(_BROKER, ref, &inst, true); + s = get_host(_BROKER, info->context, ref, &inst, true); if (s.rc != CMPI_RC_OK) goto out; @@ -165,14 +167,14 @@ if (!match_hypervisor_prefix(ref, info)) goto out; - s = validate_caps_get_service(ref, &inst); + s = validate_caps_get_service(info->context, ref, &inst); if (s.rc != CMPI_RC_OK) goto out; if (inst != NULL) inst_list_add(list, inst); - s = get_host(_BROKER, ref, &inst, false); + s = get_host(_BROKER, info->context, ref, &inst, false); if (s.rc != CMPI_RC_OK) goto out; @@ -192,7 +194,7 @@ if (!match_hypervisor_prefix(ref, info)) goto out; - s = validate_service_get_caps(ref, &inst); + s = validate_service_get_caps(info->context, ref, &inst); if (s.rc != CMPI_RC_OK) goto out; @@ -292,7 +294,7 @@ if ((ac == NULL) || (s.rc != CMPI_RC_OK)) goto out; - s = get_host(_BROKER, ref, &host, false); + s = get_host(_BROKER, info->context, ref, &host, false); if (s.rc != CMPI_RC_OK) goto out; diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_HostSystem.c Tue Aug 19 14:13:24 2008 -0700 @@ -58,6 +58,7 @@ } CMPIStatus get_host(const CMPIBroker *broker, + const CMPIContext *context, const CMPIObjectPath *reference, CMPIInstance **_inst, bool is_get_inst) @@ -103,7 +104,8 @@ return s; } -static CMPIStatus return_host(const CMPIObjectPath *reference, +static CMPIStatus return_host(const CMPIContext *context, + const CMPIObjectPath *reference, const CMPIResult *results, bool name_only, bool is_get_inst) @@ -111,7 +113,7 @@ CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - s = get_host(_BROKER, reference, &inst, is_get_inst); + s = get_host(_BROKER, context, reference, &inst, is_get_inst); if (s.rc != CMPI_RC_OK || inst == NULL) goto out; @@ -127,12 +129,13 @@ CMPIStatus get_host_system_properties(const char **name, const char **ccname, const CMPIObjectPath *ref, - const CMPIBroker *broker) + const CMPIBroker *broker, + const CMPIContext *context) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *host = NULL; - s = get_host(broker, ref, &host, false); + s = get_host(broker, context, ref, &host, false); if (s.rc != CMPI_RC_OK || host == NULL) goto out; @@ -159,7 +162,7 @@ const CMPIResult *results, const CMPIObjectPath *reference) { - return return_host(reference, results, true, false); + return return_host(context, reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -169,7 +172,7 @@ const char **properties) { - return return_host(reference, results, false, false); + return return_host(context, reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -178,7 +181,7 @@ const CMPIObjectPath *reference, const char **properties) { - return return_host(reference, results, false, true); + return return_host(context, reference, results, false, true); } DEFAULT_CI(); diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_HostSystem.h --- a/src/Virt_HostSystem.h Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_HostSystem.h Tue Aug 19 14:13:24 2008 -0700 @@ -22,6 +22,7 @@ #define __VIRT_HOSTSYSTEM_H CMPIStatus get_host(const CMPIBroker *broker, + const CMPIContext *context, const CMPIObjectPath *reference, CMPIInstance **_inst, bool is_get_inst); @@ -29,6 +30,7 @@ CMPIStatus get_host_system_properties(const char **name, const char **ccname, const CMPIObjectPath *ref, - const CMPIBroker *broker); + const CMPIBroker *broker, + const CMPIContext *context); #endif diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_HostedDependency.c Tue Aug 19 14:13:24 2008 -0700 @@ -50,7 +50,7 @@ if (s.rc != CMPI_RC_OK) goto out; - s = get_host(_BROKER, ref, &instance, false); + s = get_host(_BROKER, info->context, ref, &instance, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, instance); @@ -68,7 +68,7 @@ if (!match_hypervisor_prefix(ref, info)) goto out; - s = get_host(_BROKER, ref, &instance, true); + s = get_host(_BROKER, info->context, ref, &instance, true); if (s.rc != CMPI_RC_OK) goto out; diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_HostedResourcePool.c Tue Aug 19 14:13:24 2008 -0700 @@ -52,7 +52,7 @@ if (s.rc != CMPI_RC_OK) goto out; - s = get_host(_BROKER, ref, &inst, false); + s = get_host(_BROKER, info->context, ref, &inst, false); if (s.rc != CMPI_RC_OK) goto out; @@ -72,7 +72,7 @@ if (!match_hypervisor_prefix(ref, info)) goto out; - s = get_host(_BROKER, ref, &inst, true); + s = get_host(_BROKER, info->context, ref, &inst, true); if (s.rc != CMPI_RC_OK) goto out; diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_HostedService.c --- a/src/Virt_HostedService.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_HostedService.c Tue Aug 19 14:13:24 2008 -0700 @@ -37,7 +37,8 @@ const static CMPIBroker *_BROKER; -static CMPIStatus validate_service_ref(const CMPIObjectPath *ref) +static CMPIStatus validate_service_ref(const CMPIContext *context, + const CMPIObjectPath *ref) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; @@ -46,11 +47,11 @@ classname = class_base_name(CLASSNAME(ref)); if (STREQC(classname, "VirtualSystemManagementService")) { - s = get_vsms(ref, &inst, _BROKER, true); + s = get_vsms(ref, &inst, _BROKER, context, true); } else if (STREQC(classname, "ResourcePoolConfigurationService")) { - s = get_rpcs(ref, &inst, _BROKER, true); + s = get_rpcs(ref, &inst, _BROKER, context, true); } else if (STREQC(classname, "VirtualSystemMigrationService")) { - s = get_migration_service(ref, &inst, _BROKER, true); + s = get_migration_service(ref, &inst, _BROKER, context, true); } free(classname); @@ -68,11 +69,11 @@ if (!match_hypervisor_prefix(ref, info)) return s; - s = validate_service_ref(ref); + s = validate_service_ref(info->context, ref); if (s.rc != CMPI_RC_OK) return s; - s = get_host(_BROKER, ref, &instance, false); + s = get_host(_BROKER, info->context, ref, &instance, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, instance); @@ -89,23 +90,23 @@ if (!match_hypervisor_prefix(ref, info)) return s; - s = get_host(_BROKER, ref, &inst, true); + s = get_host(_BROKER, info->context, ref, &inst, true); if (s.rc != CMPI_RC_OK) return s; - s = get_rpcs(ref, &inst, _BROKER, false); + s = get_rpcs(ref, &inst, _BROKER, info->context, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) inst_list_add(list, inst); - s = get_vsms(ref, &inst, _BROKER, false); + s = get_vsms(ref, &inst, _BROKER, info->context, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) inst_list_add(list, inst); - s = get_migration_service(ref, &inst, _BROKER, false); + s = get_migration_service(ref, &inst, _BROKER, info->context, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_ResourcePoolConfigurationService.c Tue Aug 19 14:13:24 2008 -0700 @@ -97,6 +97,7 @@ CMPIStatus get_rpcs(const CMPIObjectPath *reference, CMPIInstance **_inst, const CMPIBroker *broker, + const CMPIContext *context, bool is_get_inst) { CMPIInstance *inst; @@ -129,7 +130,8 @@ s = get_host_system_properties(&name, &ccname, reference, - broker); + broker, + context); if (s.rc != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, @@ -160,7 +162,8 @@ return s; } -static CMPIStatus return_rpcs(const CMPIResult *results, +static CMPIStatus return_rpcs(const CMPIContext *context, + const CMPIResult *results, const CMPIObjectPath *reference, bool names_only, bool is_get_inst) @@ -168,7 +171,7 @@ CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - s = get_rpcs(reference, &inst, _BROKER, is_get_inst); + s = get_rpcs(reference, &inst, _BROKER, context, is_get_inst); if (s.rc != CMPI_RC_OK || inst == NULL) goto out; @@ -187,7 +190,7 @@ const CMPIObjectPath *reference, const char **properties) { - return return_rpcs(results, reference, false, true); + return return_rpcs(context, results, reference, false, true); } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -195,7 +198,7 @@ const CMPIResult *results, const CMPIObjectPath *reference) { - return return_rpcs(results, reference, true, false); + return return_rpcs(context, results, reference, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -204,7 +207,7 @@ const CMPIObjectPath *reference, const char **properties) { - return return_rpcs(results, reference, false, false); + return return_rpcs(context, results, reference, false, false); } diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_ResourcePoolConfigurationService.h --- a/src/Virt_ResourcePoolConfigurationService.h Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_ResourcePoolConfigurationService.h Tue Aug 19 14:13:24 2008 -0700 @@ -22,6 +22,7 @@ CMPIStatus get_rpcs(const CMPIObjectPath *reference, CMPIInstance **_inst, const CMPIBroker *broker, + const CMPIContext *context, bool is_get_inst); /* diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_VSMigrationService.c Tue Aug 19 14:13:24 2008 -0700 @@ -726,7 +726,11 @@ if ((ref == NULL) || (s.rc != CMPI_RC_OK)) { CU_DEBUG("Failed to get job reference"); } else { - s = get_host_system_properties(&host, &ccname, ref, _BROKER); + s = get_host_system_properties(&host, + &ccname, + ref, + _BROKER, + context); if (s.rc == CMPI_RC_OK) { CMSetProperty(ind, "SourceInstanceHost", (CMPIValue *)host, CMPI_chars); @@ -1510,6 +1514,7 @@ CMPIStatus get_migration_service(const CMPIObjectPath *ref, CMPIInstance **_inst, const CMPIBroker *broker, + const CMPIContext *context, bool is_get_inst) { CMPIInstance *inst; @@ -1541,7 +1546,8 @@ s = get_host_system_properties(&name, &ccname, ref, - broker); + broker, + context); if (s.rc != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, @@ -1576,7 +1582,8 @@ return s; } -static CMPIStatus return_vsms(const CMPIObjectPath *ref, +static CMPIStatus return_vsms(const CMPIContext *context, + const CMPIObjectPath *ref, const CMPIResult *results, bool name_only, bool is_get_inst) @@ -1584,7 +1591,7 @@ CMPIInstance *inst = NULL; CMPIStatus s; - s = get_migration_service(ref, &inst, _BROKER, is_get_inst); + s = get_migration_service(ref, &inst, _BROKER, context, is_get_inst); if ((s.rc != CMPI_RC_OK) || (inst == NULL)) goto out; @@ -1601,7 +1608,7 @@ const CMPIResult *results, const CMPIObjectPath *ref) { - return return_vsms(ref, results, true, false); + return return_vsms(context, ref, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -1611,7 +1618,7 @@ const char **properties) { - return return_vsms(ref, results, false, false); + return return_vsms(context, ref, results, false, false); } @@ -1621,7 +1628,7 @@ const CMPIObjectPath *ref, const char **properties) { - return return_vsms(ref, results, false, true); + return return_vsms(context, ref, results, false, true); } DEFAULT_CI(); diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_VSMigrationService.h --- a/src/Virt_VSMigrationService.h Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_VSMigrationService.h Tue Aug 19 14:13:24 2008 -0700 @@ -22,6 +22,7 @@ CMPIStatus get_migration_service(const CMPIObjectPath *reference, CMPIInstance **_inst, const CMPIBroker *broker, + const CMPIContext *context, bool is_get_inst); /* diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Tue Aug 19 14:13:24 2008 -0700 @@ -1800,6 +1800,7 @@ CMPIStatus get_vsms(const CMPIObjectPath *reference, CMPIInstance **_inst, const CMPIBroker *broker, + const CMPIContext *context, bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -1838,7 +1839,8 @@ s = get_host_system_properties(&name, &ccname, reference, - broker); + broker, + context); if (s.rc != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, @@ -1902,7 +1904,8 @@ return s; } -static CMPIStatus return_vsms(const CMPIObjectPath *reference, +static CMPIStatus return_vsms(const CMPIContext *context, + const CMPIObjectPath *reference, const CMPIResult *results, bool name_only, bool is_get_inst) @@ -1910,7 +1913,7 @@ CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - s = get_vsms(reference, &inst, _BROKER, is_get_inst); + s = get_vsms(reference, &inst, _BROKER, context, is_get_inst); if (s.rc != CMPI_RC_OK || inst == NULL) goto out; @@ -1927,7 +1930,7 @@ const CMPIResult *results, const CMPIObjectPath *reference) { - return return_vsms(reference, results, true, false); + return return_vsms(context, reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -1937,7 +1940,7 @@ const char **properties) { - return return_vsms(reference, results, false, false); + return return_vsms(context, reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -1946,7 +1949,7 @@ const CMPIObjectPath *ref, const char **properties) { - return return_vsms(ref, results, false, true); + return return_vsms(context, ref, results, false, true); } DEFAULT_CI(); diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_VirtualSystemManagementService.h --- a/src/Virt_VirtualSystemManagementService.h Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_VirtualSystemManagementService.h Tue Aug 19 14:13:24 2008 -0700 @@ -22,4 +22,5 @@ CMPIStatus get_vsms(const CMPIObjectPath *reference, CMPIInstance **_inst, const CMPIBroker *broker, + const CMPIContext *context, bool is_get_inst); diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_VirtualSystemSnapshotService.c --- a/src/Virt_VirtualSystemSnapshotService.c Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_VirtualSystemSnapshotService.c Tue Aug 19 14:13:24 2008 -0700 @@ -602,6 +602,7 @@ _BROKER, libvirt_cim_init(), handlers); static CMPIStatus set_inst_properties(const CMPIBroker *broker, + const CMPIContext *context, const CMPIObjectPath *reference, CMPIInstance *inst) { @@ -612,7 +613,8 @@ s = get_host_system_properties(&name, &ccname, reference, - broker); + broker, + context); if (s.rc != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, @@ -634,6 +636,7 @@ } CMPIStatus get_vsss(const CMPIBroker *broker, + const CMPIContext *context, const CMPIObjectPath *ref, CMPIInstance **_inst, bool is_get_inst) @@ -662,7 +665,7 @@ goto out; } - s = set_inst_properties(broker, ref, inst); + s = set_inst_properties(broker, context, ref, inst); if (is_get_inst) { s = cu_validate_ref(broker, ref, inst); @@ -677,7 +680,8 @@ return s; } -static CMPIStatus return_vsss(const CMPIObjectPath *ref, +static CMPIStatus return_vsss(const CMPIContext *context, + const CMPIObjectPath *ref, const CMPIResult *results, bool names_only, bool is_get_inst) @@ -685,7 +689,7 @@ CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - s = get_vsss(_BROKER, ref, &inst, is_get_inst); + s = get_vsss(_BROKER, context, ref, &inst, is_get_inst); if ((s.rc != CMPI_RC_OK) || (inst == NULL)) goto out; @@ -702,7 +706,7 @@ const CMPIResult *results, const CMPIObjectPath *reference) { - return return_vsss(reference, results, true, false); + return return_vsss(context, reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -712,7 +716,7 @@ const char **properties) { - return return_vsss(reference, results, false, false); + return return_vsss(context, reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -721,7 +725,7 @@ const CMPIObjectPath *reference, const char **properties) { - return return_vsss(reference, results, false, true); + return return_vsss(context, reference, results, false, true); } DEFAULT_CI(); diff -r 80e6ea1a1a29 -r a55c6df52f5e src/Virt_VirtualSystemSnapshotService.h --- a/src/Virt_VirtualSystemSnapshotService.h Mon Aug 18 11:38:38 2008 -0700 +++ b/src/Virt_VirtualSystemSnapshotService.h Tue Aug 19 14:13:24 2008 -0700 @@ -25,6 +25,7 @@ CMPIStatus vsss_delete_snapshot(const char *domname); CMPIStatus get_vsss(const CMPIBroker *broker, + const CMPIContext *context, const CMPIObjectPath *ref, CMPIInstance **_inst, bool is_get_inst);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1219180424 25200 # Node ID 304d6c3d06697f93c35b64c0b059090648de8e5e # Parent a55c6df52f5e8108d3e1dc978a2f3b8b32db71dc Make HostSystem return the SBLIM ComputerSystem, if present Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r a55c6df52f5e -r 304d6c3d0669 src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Tue Aug 19 14:13:24 2008 -0700 +++ b/src/Virt_HostSystem.c Tue Aug 19 14:13:44 2008 -0700 @@ -57,11 +57,9 @@ return 1; } -CMPIStatus get_host(const CMPIBroker *broker, - const CMPIContext *context, - const CMPIObjectPath *reference, - CMPIInstance **_inst, - bool is_get_inst) +static CMPIStatus fake_host(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; @@ -69,10 +67,9 @@ conn = connect_by_classname(broker, CLASSNAME(reference), &s); if (conn == NULL) { - if (is_get_inst) - cu_statusf(broker, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance"); + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); goto out; } @@ -89,17 +86,71 @@ } set_host_system_properties(inst); + *_inst = inst; + out: + virConnectClose(conn); - if (is_get_inst) { - s = cu_validate_ref(broker, reference, inst); - if (s.rc != CMPI_RC_OK) - goto out; + return s; +} + +static CMPIStatus sblim_host(const CMPIBroker *broker, + const CMPIContext *context, + const CMPIObjectPath *ref, + CMPIInstance **inst) +{ + CMPIObjectPath *path; + CMPIStatus s; + const char *cn = "Linux_ComputerSystem"; + char name[256]; + + if (gethostname(name, sizeof(name)) != 0) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get hostname: %m"); + return s; } - *_inst = inst; + path = CMNewObjectPath(broker, "root/cimv2", cn, &s); + if ((path == NULL) || (s.rc != CMPI_RC_OK)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to create HostSystem path"); + return s; + } - out: - virConnectClose(conn); + CMAddKey(path, "CreationClassName", cn, CMPI_chars); + CMAddKey(path, "Name", name, CMPI_chars); + + *inst = CBGetInstance(broker, context, path, NULL, &s); + + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("SBLIM: %i %s", s.rc, CMGetCharPtr(s.msg)); + } else { + CU_DEBUG("SBLIM: Returned instance"); + } + + return s; +} + +CMPIStatus get_host(const CMPIBroker *broker, + const CMPIContext *context, + const CMPIObjectPath *reference, + CMPIInstance **_inst, + bool is_get_inst) +{ + CMPIStatus s; + + s = sblim_host(broker, context, reference, _inst); + if (s.rc != CMPI_RC_OK) + s = fake_host(broker, reference, _inst); + + if (!is_get_inst && (s.rc == CMPI_RC_ERR_NOT_FOUND)) { + /* This is not an error */ + return (CMPIStatus){CMPI_RC_OK, NULL}; + } + + if ((s.rc == CMPI_RC_OK) && is_get_inst) + s = cu_validate_ref(broker, reference, *_inst); return s; }

+ + if (gethostname(name, sizeof(name)) != 0) {
The node name on my system isn't a FQDN. It looks like the sblim providers use a FQDN. So even though I have the sblim providers installed, I still get back the faked HostSystem. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> The node name on my system isn't a FQDN. It looks like the sblim KR> providers use a FQDN. So even though I have the sblim providers KR> installed, I still get back the faked HostSystem. Yeah, they actually exec /bin/dnsdomainname, which does a lookup of the hostname if it's not fully-qualified. I've sent another patch that replicates this behavior (although not the exec, of course). -- 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 1219180424 25200 # Node ID e216e19e47bcaf4dd299b10532808a8c7c994d73 # Parent 304d6c3d06697f93c35b64c0b059090648de8e5e Make the EnumInstances and GetInstance logic in HostSystem SBLIM-aware ...so that we don't return Linux_ComputerSystem instances if we found SBLIM ones Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 304d6c3d0669 -r e216e19e47bc src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Tue Aug 19 14:13:44 2008 -0700 +++ b/src/Virt_HostSystem.c Tue Aug 19 14:13:44 2008 -0700 @@ -163,9 +163,18 @@ { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; + CMPIObjectPath *path = NULL; s = get_host(_BROKER, context, reference, &inst, is_get_inst); if (s.rc != CMPI_RC_OK || inst == NULL) + goto out; + + path = CMGetObjectPath(inst, &s); + if ((path == NULL) || (s.rc != CMPI_RC_OK)) + return s; + + if (STARTS_WITH(CLASSNAME(path), "Linux_")) + /* Don't return SBLIM instances */ goto out; if (name_only)

Dan Smith wrote:
This patch set (eventually) makes the providers return references to the SBLIM Linux_ComputerSystem instance, if that provider is available. This makes all of the Hosted* associations (and others) correctly point to the SBLIM provider when possible. As a fallback, we continue to return our fake instances if the SBLIM provider isn't installed.
Nice! As the SBLIM project evolves, I suspect libvirt-cim will be able to leverage more implementations there. E.g. where SVPC models reference SMWG or SMI-S models. Jim
participants (3)
-
Dan Smith
-
Jim Fehlig
-
Kaitlin Rupert