# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1209053161 25200
# Node ID b0cbe4e6fd7d1b2f072d2a3b3c3e3ee99b45ef0f
# Parent c84430202e2e416c183f186a37a0c80d2fcb4896
Add the HostSystem-to-AC link with EC
This happens as part of the existing HostSystem->*Capabilities code,
but we also insert the Characteristics array into the Reference instance.
As far as I can tell, this is okay to be 2=Default for all those references.
Also, only do this for the MemoryAC at the moment, since only that profile
specifies this behavior.
The reverse direction replaces the unsupported AC-to-pool code with
bits to return the HostSystem.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r c84430202e2e -r b0cbe4e6fd7d src/Virt_ElementCapabilities.c
--- a/src/Virt_ElementCapabilities.c Thu Apr 24 08:47:26 2008 -0700
+++ b/src/Virt_ElementCapabilities.c Thu Apr 24 09:06:01 2008 -0700
@@ -41,6 +41,8 @@
#include "Virt_VSMigrationCapabilities.h"
#include "Virt_AllocationCapabilities.h"
+#include "svpc_types.h"
+
/* Associate an XXX_Capabilities to the proper XXX_ManagedElement.
*
* -- or --
@@ -143,6 +145,11 @@ static CMPIStatus sys_to_cap(const CMPIO
if (s.rc == CMPI_RC_OK)
inst_list_add(list, inst);
+ s = enum_alloc_cap_instances(_BROKER, ref, NULL, NULL, list);
+ if (s.rc != CMPI_RC_OK) {
+ CU_DEBUG("Failed to enum AC: %s",
+ CMGetCharPtr(s.msg));
+ }
out:
return s;
}
@@ -260,8 +267,32 @@ static CMPIStatus alloc_to_pool(const CM
struct std_assoc_info *info,
struct inst_list *list)
{
- /* Pool to alloc is more important. That will be done first. */
- RETURN_UNSUPPORTED();
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *host;
+ CMPIInstance *ac;
+ const char *poolid;
+
+ if (!match_hypervisor_prefix(ref, info))
+ goto out;
+
+ if (cu_get_str_path(ref, "InstanceID", &poolid) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Missing InstanceID");
+ goto out;
+ }
+
+ s = get_alloc_cap_by_id(_BROKER, ref, poolid, &ac);
+ if ((ac == NULL) || (s.rc != CMPI_RC_OK))
+ goto out;
+
+ s = get_host(_BROKER, ref, &host, false);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ inst_list_add(list, host);
+ out:
+ return s;
}
static CMPIStatus pool_to_alloc(const CMPIObjectPath *ref,
@@ -289,6 +320,37 @@ static CMPIStatus pool_to_alloc(const CM
out:
return s;
+}
+
+static CMPIInstance *make_ref_default(const CMPIObjectPath *source_ref,
+ const CMPIInstance *target_inst,
+ struct std_assoc_info *info,
+ struct std_assoc *assoc)
+{
+ CMPIInstance *ref_inst = NULL;
+ CMPIArray *array = NULL;
+ CMPIStatus s;
+ uint16_t val = CIM_EC_CHAR_DEFAULT;
+
+ ref_inst = make_reference(_BROKER,
+ source_ref,
+ target_inst,
+ info,
+ assoc);
+
+ array = CMNewArray(_BROKER, 1, CMPI_uint16, &s);
+ if ((array == NULL) || (s.rc != CMPI_RC_OK)) {
+ CU_DEBUG("Unable to allocate Characteristics array");
+ goto out;
+ }
+
+ CMSetArrayElementAt(array, 0, &val, CMPI_uint16);
+
+ CMSetProperty(ref_inst, "Characteristics",
+ (CMPIValue *)&array, CMPI_uint16A);
+
+ out:
+ return ref_inst;
}
LIBVIRT_CIM_DEFAULT_MAKEREF()
@@ -330,17 +392,30 @@ static char* virtual_system_management_c
NULL,
};
+static char *host_caps[] = {
+ "Xen_VirtualSystemManagementCapabilities",
+ "Xen_VirtualSystemMigrationCapabilities",
+ "KVM_VirtualSystemManagementCapabilities",
+ "KVM_VirtualSystemMigrationCapabilities",
+ "LXC_VirtualSystemManagementCapabilities",
+ "LXC_VirtualSystemMigrationCapabilities",
+ "Xen_MemoryAllocationCapabilities",
+ "KVM_MemoryAllocationCapabilities",
+ "LXC_MemoryAllocationCapabilities",
+ NULL,
+};
+
static struct std_assoc system_to_vsm_cap = {
.source_class = (char**)&host_system,
.source_prop = "ManagedElement",
- .target_class = (char**)&virtual_system_management_capabilities,
+ .target_class = (char**)&host_caps,
.target_prop = "Capabilities",
.assoc_class = (char**)&assoc_classname,
.handler = sys_to_cap,
- .make_ref = make_ref
+ .make_ref = make_ref_default
};
static struct std_assoc vsm_cap_to_sys_or_service = {
@@ -441,11 +516,31 @@ static char* resource_pool[] = {
NULL
};
+static char* resource_pool_and_host[] = {
+ "Xen_ProcessorPool",
+ "Xen_MemoryPool",
+ "Xen_NetworkPool",
+ "Xen_DiskPool",
+ "Xen_HostSystem",
+ "KVM_ProcessorPool",
+ "KVM_MemoryPool",
+ "KVM_NetworkPool",
+ "KVM_DiskPool",
+ "KVM_HostSystem",
+ "LXC_ProcessorPool",
+ "LXC_MemoryPool",
+ "LXC_NetworkPool",
+ "LXC_DiskPool",
+ "LXC_HostSystem",
+ NULL
+};
+
+
static struct std_assoc alloc_cap_to_resource_pool = {
.source_class = (char**)&allocation_capabilities,
.source_prop = "Capabilities",
- .target_class = (char**)&resource_pool,
+ .target_class = (char**)&resource_pool_and_host,
.target_prop = "ManagedElement",
.assoc_class = (char**)&assoc_classname,
diff -r c84430202e2e -r b0cbe4e6fd7d src/svpc_types.h
--- a/src/svpc_types.h Thu Apr 24 08:47:26 2008 -0700
+++ b/src/svpc_types.h Thu Apr 24 09:06:01 2008 -0700
@@ -47,6 +47,8 @@ const static int cim_res_types[CIM_RES_T
#define CIM_SVPC_RETURN_JOB_STARTED 4096
#define CIM_SVPC_RETURN_COMPLETED 0
+#define CIM_EC_CHAR_DEFAULT 2
+
#include <libcmpiutil/libcmpiutil.h>
#include <string.h>