[PATCH 0 of 2] Add AC-to-HS association

This set adds the association between the HostSystem and the AllocationCapabilities objects. It also sets the Characteristics array for the AC reference objects, per the MOF.

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1209052046 25200 # Node ID c84430202e2e416c183f186a37a0c80d2fcb4896 # Parent cf121ecfb0824a34b42507fa36d06bf4cb45d0bc Add get_alloc_cap_by_id() external function to AC Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r cf121ecfb082 -r c84430202e2e src/Virt_AllocationCapabilities.c --- a/src/Virt_AllocationCapabilities.c Wed Apr 23 09:00:19 2008 -0700 +++ b/src/Virt_AllocationCapabilities.c Thu Apr 24 08:47:26 2008 -0700 @@ -147,6 +147,21 @@ CMPIStatus enum_alloc_cap_instances(cons return s; } +CMPIStatus get_alloc_cap_by_id(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const char *poolid, + CMPIInstance **inst) +{ + CMPIInstance *pool; + CMPIStatus s; + + s = get_pool_by_name(broker, ref, poolid, &pool); + if ((pool == NULL) || (s.rc != CMPI_RC_OK)) + return s; + + return ac_from_pool(broker, ref, pool, inst); +} + static CMPIStatus return_alloc_cap_instances(const CMPIBroker *broker, const CMPIObjectPath *ref, const CMPIResult *results, diff -r cf121ecfb082 -r c84430202e2e src/Virt_AllocationCapabilities.h --- a/src/Virt_AllocationCapabilities.h Wed Apr 23 09:00:19 2008 -0700 +++ b/src/Virt_AllocationCapabilities.h Thu Apr 24 08:47:26 2008 -0700 @@ -40,6 +40,11 @@ CMPIStatus enum_alloc_cap_instances(cons const char *id, struct inst_list *list); +CMPIStatus get_alloc_cap_by_id(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const char *poolid, + CMPIInstance **inst); + #endif /*

# HG changeset patch # User Dan Smith <danms@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@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>

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@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@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)
Can you add a comment here that this function handles AC --> HS AC --> pool The function name is confusing (or confused me at least =)
+ +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);
It looks like the Characteristics value gets set even for the AC -> Pool case. Is this expected?
+ + out: + return ref_inst; }
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

@@ -260,8 +267,32 @@ static CMPIStatus alloc_to_pool(const CM
KR> Can you add a comment here that this function handles KR> AC --> HS KR> AC --> pool KR> The function name is confusing (or confused me at least =) I think changing the name is a good idea too. KR> It looks like the Characteristics value gets set even for the AC -> KR> Pool case. Is this expected? Technically, the ElementCapabilities association reference object has that field, and it is to be set to 2 if the association is to be interpreted as the "default" case. So, I would say: "yes" :) If others have a differing opinion, I'd certainly be open to discussion. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert