[Libvirt-cim] [PATCH v3 8/8] Add code and associations for ControllerPool

John Ferlan jferlan at redhat.com
Thu Mar 27 21:18:37 UTC 2014


Add the code and make adjustments to have ControllerPool support

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/Virt_DevicePool.c                            | 55 +++++++++++++++++++++++-
 src/Virt_ElementAllocatedFromPool.c              |  2 +
 src/Virt_ElementCapabilities.c                   |  4 +-
 src/Virt_HostedResourcePool.c                    |  3 +-
 src/Virt_ResourceAllocationFromPool.c            |  2 +
 src/Virt_ResourcePoolConfigurationCapabilities.c |  2 +-
 src/Virt_ResourcePoolConfigurationService.c      |  2 +
 7 files changed, 66 insertions(+), 4 deletions(-)

diff --git a/src/Virt_DevicePool.c b/src/Virt_DevicePool.c
index aae7ed4..6c61b64 100644
--- a/src/Virt_DevicePool.c
+++ b/src/Virt_DevicePool.c
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corp. 2007
+ * Copyright IBM Corp. 2007-2014
  *
  * Authors:
  *  Dan Smith <danms at us.ibm.com>
@@ -797,6 +797,8 @@ char *pool_member_of(const CMPIBroker *broker,
                 poolid = strdup("GraphicsPool/0");
         else if (type == CIM_RES_TYPE_INPUT)
                 poolid = strdup("InputPool/0");
+        else if (type == CIM_RES_TYPE_CONTROLLER)
+                poolid = strdup("ControllerPool/0");
         else
                 return NULL;
 
@@ -817,6 +819,8 @@ uint16_t res_type_from_pool_classname(const char *classname)
                 return CIM_RES_TYPE_GRAPHICS;
         else if (strstr(classname, "InputPool"))
                 return CIM_RES_TYPE_INPUT;
+        else if (strstr(classname, "ControllerPool"))
+                return CIM_RES_TYPE_CONTROLLER;
         else
                 return CIM_RES_TYPE_UNKNOWN;
 }
@@ -835,6 +839,8 @@ uint16_t res_type_from_pool_id(const char *id)
                 return CIM_RES_TYPE_GRAPHICS;
         else if (strstr(id, "InputPool"))
                 return CIM_RES_TYPE_INPUT;
+        else if (strstr(id, "ControllerPool"))
+                return CIM_RES_TYPE_CONTROLLER;
         else
                 return CIM_RES_TYPE_UNKNOWN;
 }
@@ -1502,6 +1508,43 @@ static CMPIStatus inputpool_instance(virConnectPtr conn,
         return s;
 }
 
+static CMPIStatus controllerpool_instance(virConnectPtr conn,
+                                          struct inst_list *list,
+                                          const char *ns,
+                                          const char *_id,
+                                          const CMPIBroker *broker)
+{
+        const char *id = "ControllerPool/0";
+        CMPIInstance *inst;
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+
+        if ((_id != NULL) && (!STREQC(_id, "0"))) {
+                cu_statusf(broker, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "No such controller pool `%s'", id);
+                return s;
+        }
+
+        inst = get_typed_instance(broker,
+                                  pfx_from_conn(conn),
+                                  "ControllerPool",
+                                  ns,
+                                  false);
+        if (inst == NULL) {
+                cu_statusf(broker, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Failed to get instance of %s_ControllerPool",
+                           pfx_from_conn(conn));
+                return s;
+        }
+
+        set_params(inst, CIM_RES_TYPE_CONTROLLER, id, NULL, NULL, true);
+
+        inst_list_add(list, inst);
+
+        return s;
+}
+
 static CMPIStatus _get_pools(const CMPIBroker *broker,
                              const CMPIObjectPath *reference,
                              const uint16_t type,
@@ -1563,6 +1606,14 @@ static CMPIStatus _get_pools(const CMPIBroker *broker,
                                        id,
                                        broker);
 
+        if ((type == CIM_RES_TYPE_CONTROLLER) ||
+            (type == CIM_RES_TYPE_ALL))
+                s = controllerpool_instance(conn,
+                                            list,
+                                            NAMESPACE(reference),
+                                            id,
+                                            broker);
+
         if (type == CIM_RES_TYPE_UNKNOWN)
                 cu_statusf(broker, &s,
                            CMPI_RC_ERR_NOT_FOUND,
@@ -1712,6 +1763,8 @@ CMPIInstance *parent_device_pool(const CMPIBroker *broker,
                 id = "GraphicsPool/0";
         } else if (type == CIM_RES_TYPE_INPUT) {
                 id = "InputPool/0";
+        } else if (type == CIM_RES_TYPE_CONTROLLER) {
+                id = "ControllerPool/0";
         } else {
                 cu_statusf(broker, s,
                            CMPI_RC_ERR_INVALID_PARAMETER,
diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c
index 262c9b9..a5fef12 100644
--- a/src/Virt_ElementAllocatedFromPool.c
+++ b/src/Virt_ElementAllocatedFromPool.c
@@ -253,6 +253,7 @@ static char* pool[] = {
         "KVM_DiskPool",
         "KVM_GraphicsPool",
         "KVM_InputPool",
+        "KVM_ControllerPool",
         "LXC_ProcessorPool",
         "LXC_MemoryPool",
         "LXC_NetworkPool",
@@ -317,6 +318,7 @@ static char* device_or_pool[] = {
         "KVM_DiskPool",
         "KVM_GraphicsPool",
         "KVM_InputPool",
+        "KVM_ControllerPool",
         "LXC_ProcessorPool",
         "LXC_MemoryPool",
         "LXC_NetworkPool",
diff --git a/src/Virt_ElementCapabilities.c b/src/Virt_ElementCapabilities.c
index 77aad9a..0cb3e1e 100644
--- a/src/Virt_ElementCapabilities.c
+++ b/src/Virt_ElementCapabilities.c
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corp. 2007
+ * Copyright IBM Corp. 2007-2014
  *
  * Authors:
  *  Dan Smith <danms at us.ibm.com>
@@ -416,6 +416,7 @@ static char* host_sys_and_service_and_rp[] = {
         "KVM_DiskPool",
         "KVM_GraphicsPool",
         "KVM_InputPool",
+        "KVM_ControllerPool",
         "LXC_ProcessorPool",
         "LXC_MemoryPool",
         "LXC_NetworkPool",
@@ -553,6 +554,7 @@ static char* resource_pool[] = {
         "KVM_DiskPool",
         "KVM_GraphicsPool",
         "KVM_InputPool",
+        "KVM_ControllerPool",
         "LXC_ProcessorPool",
         "LXC_MemoryPool",
         "LXC_NetworkPool",
diff --git a/src/Virt_HostedResourcePool.c b/src/Virt_HostedResourcePool.c
index 0863853..e0459c5 100644
--- a/src/Virt_HostedResourcePool.c
+++ b/src/Virt_HostedResourcePool.c
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corp. 2007
+ * Copyright IBM Corp. 2007-2014
  *
  * Authors:
  *  Dan Smith <danms at us.ibm.com>
@@ -113,6 +113,7 @@ static char* part_component[] = {
         "KVM_DiskPool",
         "KVM_GraphicsPool",
         "KVM_InputPool",
+        "KVM_ControllerPool",
         "LXC_ProcessorPool",
         "LXC_MemoryPool",
         "LXC_NetworkPool",
diff --git a/src/Virt_ResourceAllocationFromPool.c b/src/Virt_ResourceAllocationFromPool.c
index 7bee729..98bd24e 100644
--- a/src/Virt_ResourceAllocationFromPool.c
+++ b/src/Virt_ResourceAllocationFromPool.c
@@ -194,6 +194,7 @@ static char* antecedent[] = {
         "KVM_DiskPool",
         "KVM_GraphicsPool",
         "KVM_InputPool",
+        "KVM_ControllerPool",
         "LXC_ProcessorPool",
         "LXC_MemoryPool",
         "LXC_NetworkPool",
@@ -216,6 +217,7 @@ static char* dependent[] = {
         "KVM_ProcResourceAllocationSettingData",
         "KVM_GraphicsResourceAllocationSettingData",
         "KVM_InputResourceAllocationSettingData",
+        "KVM_ControllerResourceAllocationSettingData",
         "LXC_DiskResourceAllocationSettingData",
         "LXC_MemResourceAllocationSettingData",
         "LXC_NetResourceAllocationSettingData",
diff --git a/src/Virt_ResourcePoolConfigurationCapabilities.c b/src/Virt_ResourcePoolConfigurationCapabilities.c
index 63045bf..28a5de2 100644
--- a/src/Virt_ResourcePoolConfigurationCapabilities.c
+++ b/src/Virt_ResourcePoolConfigurationCapabilities.c
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corp. 2007
+ * Copyright IBM Corp. 2007-2014
  *
  * Authors:
  *  Dan Smith <danms at us.ibm.com>
diff --git a/src/Virt_ResourcePoolConfigurationService.c b/src/Virt_ResourcePoolConfigurationService.c
index 02de834..ab83beb 100644
--- a/src/Virt_ResourcePoolConfigurationService.c
+++ b/src/Virt_ResourcePoolConfigurationService.c
@@ -431,6 +431,8 @@ static char *get_pool_id(int res_type,
                 pool = "GraphicsPool";
         else if (res_type == CIM_RES_TYPE_INPUT)
                 pool = "InputPool";
+        else if (res_type == CIM_RES_TYPE_CONTROLLER)
+                pool = "ControllerPool";
         else
                 pool = "Unknown";
 
-- 
1.8.5.3




More information about the Libvirt-cim mailing list