# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1199869324 -3600
# Node ID ad0ca904d4cb6184c5ae0002891fa22f336dcce0
# Parent ee811a7e50179f019cda5267e27f44faa4a1f353
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"'
Diff to #1:
- fixed style issues
- validate_host_ref() now in HostSystem provider
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r ee811a7e5017 -r ad0ca904d4cb src/Makefile.am
--- a/src/Makefile.am Wed Jan 09 10:02:02 2008 +0100
+++ b/src/Makefile.am Wed Jan 09 10:02:04 2008 +0100
@@ -135,9 +135,9 @@ libVirt_ElementAllocatedFromPool_la_SOUR
libVirt_ElementAllocatedFromPool_la_SOURCES = Virt_ElementAllocatedFromPool.c
libVirt_ElementAllocatedFromPool_la_LIBADD = -lVirt_DevicePool -lVirt_Device
-libVirt_HostedService_la_DEPENDENCIES = libVirt_VirtualSystemManagementService.la
libVirt_ResourcePoolConfigurationService.la libVirt_VSMigrationService.la
+libVirt_HostedService_la_DEPENDENCIES = libVirt_VirtualSystemManagementService.la
libVirt_ResourcePoolConfigurationService.la libVirt_VSMigrationService.la
libVirt_HostSystem.la
libVirt_HostedService_la_SOURCES = Virt_HostedService.c
-libVirt_HostedService_la_LIBADD = -lVirt_VirtualSystemManagementService
-lVirt_ResourcePoolConfigurationService -lVirt_VSMigrationService
+libVirt_HostedService_la_LIBADD = -lVirt_VirtualSystemManagementService
-lVirt_ResourcePoolConfigurationService -lVirt_VSMigrationService -lVirt_HostSystem
libVirt_ElementSettingData_la_DEPENDENCIES = libVirt_VSSD.la libVirt_RASD.la
libVirt_ElementSettingData_la_SOURCES = Virt_ElementSettingData.c
diff -r ee811a7e5017 -r ad0ca904d4cb src/Virt_HostedService.c
--- a/src/Virt_HostedService.c Wed Jan 09 10:02:02 2008 +0100
+++ b/src/Virt_HostedService.c Wed Jan 09 10:02:04 2008 +0100
@@ -37,6 +37,39 @@
const static CMPIBroker *_BROKER;
+static CMPIStatus validate_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)
+ 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;
+}
+
static CMPIStatus service_to_host(const CMPIObjectPath *ref,
struct std_assoc_info *info,
struct inst_list *list)
@@ -45,6 +78,10 @@ static CMPIStatus service_to_host(const
CMPIInstance *instance;
if (!match_hypervisor_prefix(ref, info))
+ return s;
+
+ s = validate_service_ref(ref);
+ if (s.rc != CMPI_RC_OK)
return s;
s = get_host_cs(_BROKER, ref, &instance);
@@ -62,6 +99,10 @@ static CMPIStatus host_to_service(const
CMPIInstance *inst;
if (!match_hypervisor_prefix(ref, info))
+ return s;
+
+ s = validate_host_ref(_BROKER, ref);
+ if (s.rc != CMPI_RC_OK)
return s;
s = rpcs_instance(ref, &inst, _BROKER);