[Libvirt-cim] [PATCH 4 of 5] (#2) Add support for input devices to Virt_RASD.c

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Nov 12 22:29:18 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1225839014 28800
# Node ID a3eb89f3e9af9f236fcba51edce1682bc0831056
# Parent  f08e0fd04dc6689eff62b64f903178e05d440521
(#2) Add support for input devices to Virt_RASD.c

Updates:
  -Set ResourceSubType with input type
  -Set Caption with bus type

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r f08e0fd04dc6 -r a3eb89f3e9af schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof	Wed Nov 12 14:22:48 2008 -0800
+++ b/schema/ResourceAllocationSettingData.mof	Tue Nov 04 14:50:14 2008 -0800
@@ -145,3 +145,24 @@
 {
 };
 
+[Description ("Xen virtual input device"),
+ Provider("cmpi::Virt_RASD")
+]
+class Xen_InputResourceAllocationSettingData : Xen_ResourceAllocationSettingData
+{
+};
+
+[Description ("KVM virtual input device"),
+ Provider("cmpi::Virt_RASD")
+]
+class KVM_InputResourceAllocationSettingData : KVM_ResourceAllocationSettingData
+{
+};
+
+[Description ("LXC virtual input device"),
+ Provider("cmpi::Virt_RASD")
+]
+class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData
+{
+};
+
diff -r f08e0fd04dc6 -r a3eb89f3e9af schema/ResourceAllocationSettingData.registration
--- a/schema/ResourceAllocationSettingData.registration	Wed Nov 12 14:22:48 2008 -0800
+++ b/schema/ResourceAllocationSettingData.registration	Tue Nov 04 14:50:14 2008 -0800
@@ -5,12 +5,15 @@
 Xen_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
+Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
+KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
+LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
diff -r f08e0fd04dc6 -r a3eb89f3e9af src/Makefile.am
--- a/src/Makefile.am	Wed Nov 12 14:22:48 2008 -0800
+++ b/src/Makefile.am	Tue Nov 04 14:50:14 2008 -0800
@@ -150,7 +150,9 @@
 libVirt_HostedResourcePool_la_SOURCES = Virt_HostedResourcePool.c
 libVirt_HostedResourcePool_la_LIBADD = -lVirt_DevicePool -lVirt_HostSystem
 
+libVirt_RASD_la_DEPENDENCIES = libVirt_Device.la
 libVirt_RASD_la_SOURCES = Virt_RASD.c
+libVirt_RASD_la_LIBADD = -lVirt_Device
 
 libVirt_ResourcePoolConfigurationService_la_DEPENDENCIES = libVirt_HostSystem.la
 libVirt_ResourcePoolConfigurationService_la_SOURCES = Virt_ResourcePoolConfigurationService.c
diff -r f08e0fd04dc6 -r a3eb89f3e9af src/Virt_RASD.c
--- a/src/Virt_RASD.c	Wed Nov 12 14:22:48 2008 -0800
+++ b/src/Virt_RASD.c	Tue Nov 04 14:50:14 2008 -0800
@@ -37,6 +37,7 @@
 
 #include "Virt_RASD.h"
 #include "svpc_types.h"
+#include "Virt_Device.h"
 
 const static CMPIBroker *_BROKER;
 
@@ -285,6 +286,34 @@
         return s;
 }
 
+static CMPIStatus set_input_rasd_params(const struct virt_device *dev,
+                                        CMPIInstance *inst)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        char *cap;
+        int ret;
+
+        ret = get_input_dev_caption(dev->dev.input.type, 
+                                    dev->dev.input.bus, 
+                                    &cap);
+        if (ret != 1) {
+                free(cap);
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "Unable to build input caption");
+                return s;
+        }
+
+        CMSetProperty(inst, "ResourceSubType", 
+                      (CMPIValue *)dev->dev.input.type, CMPI_chars);
+
+        CMSetProperty(inst, "Caption", (CMPIValue *)cap, CMPI_chars);
+
+        free(cap);
+
+        return s;
+}
+
 static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker,
                                     struct virt_device *dev,
                                     const char *host,
@@ -313,6 +342,9 @@
         } else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
                 type = CIM_RES_TYPE_GRAPHICS;
                 base = "GraphicsResourceAllocationSettingData";
+        } else if (dev->type == CIM_RES_TYPE_INPUT) {
+                type = CIM_RES_TYPE_INPUT;
+                base = "InputResourceAllocationSettingData";
         } else {
                 return NULL;
         }
@@ -363,6 +395,8 @@
                 set_proc_rasd_params(broker, ref, dev, host, inst);
         } else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
                 s = set_graphics_rasd_params(dev, inst);
+        } else if (dev->type == CIM_RES_TYPE_INPUT) {
+                s = set_input_rasd_params(dev, inst);
         }
 
         /* FIXME: Put the HostResource in place */
@@ -486,6 +520,8 @@
                *type = CIM_RES_TYPE_MEM;
        else if (STREQ(base, "GraphicsResourceAllocationSettingData"))
                *type = CIM_RES_TYPE_GRAPHICS;
+       else if (STREQ(base, "InputResourceAllocationSettingData"))
+               *type = CIM_RES_TYPE_INPUT;
        else
                goto out;
 
@@ -516,6 +552,9 @@
                 break;
         case CIM_RES_TYPE_GRAPHICS: 
                 *classname = "GraphicsResourceAllocationSettingData";
+                break;
+        case CIM_RES_TYPE_INPUT: 
+                *classname = "InputResourceAllocationSettingData";
                 break;
         default:
                 rc = CMPI_RC_ERR_FAILED;




More information about the Libvirt-cim mailing list