# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1199797461 -3600
# Node ID 555126035e912e9202ebcc93483ee936be5ae998
# Parent 1bbea87ad37dcb95321f43aa5e17e6fa7ec1836d
HS: returns results for wrong object path
The client given reference was not checked for existance in both
directions (from HostSystem to Service and reverse) and the call
returned wrong results. Now NOT_FOUND is returned in case of a
wrong object path.
Examples:
wbemcli ain -ac KVM_HostedService
'http://localhost/root/virt:KVM_ResourcePoolConfigurationService.CreationClassName="wrong",wrong="wrong"'
wbemcli ain -ac KVM_HostedService
'http://localhost/root/virt:KVM_HostSystem.CreationClassName="KVM_HostSystem",Name="notthere"'
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 1bbea87ad37d -r 555126035e91 src/Virt_HostedService.c
--- a/src/Virt_HostedService.c Mon Jan 07 11:42:40 2008 -0800
+++ b/src/Virt_HostedService.c Tue Jan 08 14:04:21 2008 +0100
@@ -37,6 +37,57 @@
const static CMPIBroker *_BROKER;
+static CMPIStatus check_host_ref(const CMPIObjectPath *ref)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst;
+ const char *prop;
+
+ s = get_host_cs(_BROKER, ref, &inst);
+
+ prop = cu_compare_ref(ref, inst);
+ if (prop != NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance (%s)", prop);
+ }
+
+ return s;
+}
+
+static CMPIStatus check_service_ref(const CMPIObjectPath *ref)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst;
+ const char *prop;
+ char* classname;
+
+ classname = class_base_name(CLASSNAME(ref));
+
+ if (STREQC(classname, "VirtualSystemManagementService")) {
+ s = get_vsms(ref, &inst, _BROKER);
+ }
+ else if (STREQC(classname, "ResourcePoolConfigurationService")) {
+ s = rpcs_instance(ref, &inst, _BROKER);
+ }
+ else if (STREQC(classname, "VirtualSystemMigrationService")) {
+ s = get_migration_service(ref, &inst, _BROKER);
+ }
+ if (s.rc != CMPI_RC_OK)
+ return s;
+
+ prop = cu_compare_ref(ref, inst);
+ if (prop != NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance (%s)", prop);
+ }
+
+ free(classname);
+
+ return s;
+}
+
static CMPIStatus service_to_host(const CMPIObjectPath *ref,
struct std_assoc_info *info,
struct inst_list *list)
@@ -47,6 +98,10 @@ static CMPIStatus service_to_host(const
if (!match_hypervisor_prefix(ref, info))
return s;
+ s = check_service_ref(ref);
+ if (s.rc != CMPI_RC_OK)
+ return s;
+
s = get_host_cs(_BROKER, ref, &instance);
if (s.rc == CMPI_RC_OK)
inst_list_add(list, instance);
@@ -62,6 +117,10 @@ static CMPIStatus host_to_service(const
CMPIInstance *inst;
if (!match_hypervisor_prefix(ref, info))
+ return s;
+
+ s = check_host_ref(ref);
+ if (s.rc != CMPI_RC_OK)
return s;
s = rpcs_instance(ref, &inst, _BROKER);