# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1197322131 28800
# Node ID 6fdfdb1a22c5f790cfd08538a3e29923ccd2237c
# Parent 70e9f11ed6d3ea63b342c4c3de68cc948d7c1cfd
Fix SDC - AllocationCapabilities - RASD returns error.
Querying SDC using an AllocationCapabilities instance returns: "Could not get
ResourceType". This is because SDC is expecting the AC ref to have the ResourceType
defined. But ResourceType isn't a key, so SDC can be queried without specifying a
value for ResourceType.
Instead of using the ResourceType attribute, get the resource type from the InstanceID.
Failing query:
wbemcli ai -ac Xen_SettingsDefineCapabilities
'http://root:elm3b41@localhost:5988/root/virt:Xen_AllocationCapabilities.InstanceID="ProcessorPool/0"'
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 70e9f11ed6d3 -r 6fdfdb1a22c5 src/Makefile.am
--- a/src/Makefile.am Mon Dec 10 08:54:08 2007 -0800
+++ b/src/Makefile.am Mon Dec 10 13:28:51 2007 -0800
@@ -102,9 +102,9 @@ libVirt_AllocationCapabilities_la_SOURCE
libVirt_AllocationCapabilities_la_SOURCES = Virt_AllocationCapabilities.c
libVirt_AllocationCapabilities_la_LIBADD = -lVirt_RASD -lVirt_DevicePool
-libVirt_SettingsDefineCapabilities_la_DEPENDENCIES = libVirt_RASD.la
libVirt_DevicePool.la
+libVirt_SettingsDefineCapabilities_la_DEPENDENCIES = libVirt_RASD.la
libVirt_DevicePool.la libVirt_Device.la
libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c
-libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD -lVirt_DevicePool
+libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD -lVirt_DevicePool
-lVirt_Device
libVirt_RegisteredProfile_la_SOURCES = Virt_RegisteredProfile.c
@@ -146,4 +146,4 @@ libVirt_ElementSettingData_la_LIBADD = -
libVirt_VSMigrationCapabilities_la_SOURCES = Virt_VSMigrationCapabilities.c
-libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c
\ No newline at end of file
+libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c
diff -r 70e9f11ed6d3 -r 6fdfdb1a22c5 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Mon Dec 10 08:54:08 2007 -0800
+++ b/src/Virt_SettingsDefineCapabilities.c Mon Dec 10 13:28:51 2007 -0800
@@ -42,6 +42,7 @@
#include "Virt_SettingsDefineCapabilities.h"
#include "Virt_DevicePool.h"
+#include "Virt_Device.h"
const static CMPIBroker *_BROKER;
@@ -778,23 +779,31 @@ static CMPIStatus alloc_cap_to_rasd(cons
struct inst_list *list)
{
CMPIStatus s = {CMPI_RC_OK};
- int ret;
uint16_t type;
+ const char *id = NULL;
if (!match_hypervisor_prefix(ref, info))
return s;
CU_DEBUG("Getting ResourceType");
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (ret != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Could not get ResourceType");
- goto out;
- }
-
+ if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Missing InstanceID");
+ goto out;
+ }
+
+ type = device_type_from_classname(id);
+
CU_DEBUG("ResourceType: %hi", type);
+
+ if (type == VIRT_DEV_UNKNOWN) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine resource type");
+ goto out;
+ }
s = sdc_rasds_for_type(ref, list, type);