From ace5e8fdbad269517b347cc496509ce5ff30f2fe Mon Sep 17 00:00:00 2001
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Date: Mon, 7 Oct 2013 16:02:36 +0200
Subject: [PATCH 23/60] Virt_Device: Add a device class for consoles

libvirt-cim has a very strict assumption about the presence
of a CIM_LogicalDevice class being associated to a RASD.
It is practically impossible to extend the cimtest framework
for the ConsoleRASD class without having a matching device class.
Adding a new ConsoleDisplayController class for this purpose.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 schema/DisplayController.mof          | 14 ++++++++++++++
 schema/DisplayController.registration |  3 +++
 src/Virt_Device.c                     |  6 ++++--
 src/Virt_ElementSettingData.c         |  3 +++
 src/Virt_SettingsDefineState.c        |  6 ++++++
 src/Virt_SystemDevice.c               |  3 +++
 src/Virt_VSSDComponent.c              |  3 +++
 7 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/schema/DisplayController.mof b/schema/DisplayController.mof
index b57c9cc..643b024 100644
--- a/schema/DisplayController.mof
+++ b/schema/DisplayController.mof
@@ -15,3 +15,17 @@ class LXC_DisplayController : CIM_DisplayController
 {
 };

+[ Provider("cmpi::Virt_Device") ]
+class Xen_ConsoleDisplayController : CIM_DisplayController
+{
+};
+
+[ Provider("cmpi::Virt_Device") ]
+class KVM_ConsoleDisplayController : CIM_DisplayController
+{
+};
+
+[ Provider("cmpi::Virt_Device") ]
+class LXC_ConsoleDisplayController : CIM_DisplayController
+{
+};
diff --git a/schema/DisplayController.registration b/schema/DisplayController.registration
index de8adc9..e7e9770 100644
--- a/schema/DisplayController.registration
+++ b/schema/DisplayController.registration
@@ -3,3 +3,6 @@
 Xen_DisplayController root/virt Virt_Device Virt_Device instance
 KVM_DisplayController root/virt Virt_Device Virt_Device instance
 LXC_DisplayController root/virt Virt_Device Virt_Device instance
+Xen_ConsoleDisplayController root/virt Virt_Device Virt_Device instance
+KVM_ConsoleDisplayController root/virt Virt_Device Virt_Device instance
+LXC_ConsoleDisplayController root/virt Virt_Device Virt_Device instance
diff --git a/src/Virt_Device.c b/src/Virt_Device.c
index aa47276..b93e592 100644
--- a/src/Virt_Device.c
+++ b/src/Virt_Device.c
@@ -263,12 +263,12 @@ static CMPIInstance *console_instance(const CMPIBroker *broker,
         conn = virDomainGetConnect(dom);
         inst = get_typed_instance(broker,
                                   pfx_from_conn(conn),
-                                  "DisplayController",
+                                  "ConsoleDisplayController",
                                   ns,
                                   true);

         if (inst == NULL) {
-                CU_DEBUG("Failed to get instance for DisplayController");
+                CU_DEBUG("Failed to get instance for ConsoleDisplayController");
                 return NULL;
         }

@@ -549,6 +549,8 @@ uint16_t res_type_from_device_classname(const char *classname)
                 return CIM_RES_TYPE_MEM;
         else if (strstr(classname, "Processor"))
                 return CIM_RES_TYPE_PROC;
+        else if (strstr(classname, "ConsoleDisplayController"))
+                return CIM_RES_TYPE_CONSOLE;
         else if (strstr(classname, "DisplayController"))
                 return CIM_RES_TYPE_GRAPHICS;
         else if (strstr(classname, "PointingDevice"))
diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c
index c257710..c088e49 100644
--- a/src/Virt_ElementSettingData.c
+++ b/src/Virt_ElementSettingData.c
@@ -128,18 +128,21 @@ static char* resource_allocation_setting_data[] = {
         "Xen_NetResourceAllocationSettingData",
         "Xen_ProcResourceAllocationSettingData",
         "Xen_GraphicsResourceAllocationSettingData",
+        "Xen_ConsoleResourceAllocationSettingData",
         "Xen_InputResourceAllocationSettingData",
         "KVM_DiskResourceAllocationSettingData",
         "KVM_MemResourceAllocationSettingData",
         "KVM_NetResourceAllocationSettingData",
         "KVM_ProcResourceAllocationSettingData",
         "KVM_GraphicsResourceAllocationSettingData",
+        "KVM_ConsoleResourceAllocationSettingData",
         "KVM_InputResourceAllocationSettingData",
         "LXC_DiskResourceAllocationSettingData",
         "LXC_MemResourceAllocationSettingData",
         "LXC_NetResourceAllocationSettingData",
         "LXC_ProcResourceAllocationSettingData",
         "LXC_GraphicsResourceAllocationSettingData",
+        "LXC_ConsoleResourceAllocationSettingData",
         "LXC_InputResourceAllocationSettingData",
         NULL
 };
diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c
index f30f45f..be2ded5 100644
--- a/src/Virt_SettingsDefineState.c
+++ b/src/Virt_SettingsDefineState.c
@@ -327,18 +327,21 @@ static char* logical_device[] = {
         "Xen_NetworkPort",
         "Xen_LogicalDisk",
         "Xen_DisplayController",
+        "Xen_ConsoleDisplayController",
         "Xen_PointingDevice",
         "KVM_Processor",
         "KVM_Memory",
         "KVM_NetworkPort",
         "KVM_LogicalDisk",
         "KVM_DisplayController",
+        "KVM_ConsoleDisplayController",
         "KVM_PointingDevice",
         "LXC_Processor",
         "LXC_Memory",
         "LXC_NetworkPort",
         "LXC_LogicalDisk",
         "LXC_DisplayController",
+        "LXC_ConsoleDisplayController",
         "LXC_PointingDevice",
         NULL
 };
@@ -350,18 +353,21 @@ static char* resource_allocation_setting_data[] = {
         "Xen_ProcResourceAllocationSettingData",
         "Xen_GraphicsResourceAllocationSettingData",
         "Xen_InputResourceAllocationSettingData",
+        "Xen_ConsoleResourceAllocationSettingData",
         "KVM_DiskResourceAllocationSettingData",
         "KVM_MemResourceAllocationSettingData",
         "KVM_NetResourceAllocationSettingData",
         "KVM_ProcResourceAllocationSettingData",
         "KVM_GraphicsResourceAllocationSettingData",
         "KVM_InputResourceAllocationSettingData",
+        "KVM_ConsoleResourceAllocationSettingData",
         "LXC_DiskResourceAllocationSettingData",
         "LXC_MemResourceAllocationSettingData",
         "LXC_NetResourceAllocationSettingData",
         "LXC_ProcResourceAllocationSettingData",
         "LXC_GraphicsResourceAllocationSettingData",
         "LXC_InputResourceAllocationSettingData",
+        "LXC_ConsoleResourceAllocationSettingData",
         NULL
 };

diff --git a/src/Virt_SystemDevice.c b/src/Virt_SystemDevice.c
index 3a2f7ce..d2e526d 100644
--- a/src/Virt_SystemDevice.c
+++ b/src/Virt_SystemDevice.c
@@ -135,18 +135,21 @@ static char* part_component[] = {
         "Xen_NetworkPort",
         "Xen_LogicalDisk",
         "Xen_DisplayController",
+        "Xen_ConsoleDisplayController",
         "Xen_PointingDevice",
         "KVM_Processor",
         "KVM_Memory",
         "KVM_NetworkPort",
         "KVM_LogicalDisk",
         "KVM_DisplayController",
+        "KVM_ConsoleDisplayController",
         "KVM_PointingDevice",
         "LXC_Processor",
         "LXC_Memory",
         "LXC_NetworkPort",
         "LXC_LogicalDisk",
         "LXC_DisplayController",
+        "LXC_ConsoleDisplayController",
         "LXC_PointingDevice",
         NULL
 };
diff --git a/src/Virt_VSSDComponent.c b/src/Virt_VSSDComponent.c
index 378de96..35bffde 100644
--- a/src/Virt_VSSDComponent.c
+++ b/src/Virt_VSSDComponent.c
@@ -132,6 +132,7 @@ static char* part_component[] = {
         "Xen_NetResourceAllocationSettingData",
         "Xen_ProcResourceAllocationSettingData",
         "Xen_GraphicsResourceAllocationSettingData",
+        "Xen_ConsoleResourceAllocationSettingData",
         "Xen_InputResourceAllocationSettingData",
         "KVM_DiskResourceAllocationSettingData",
         "KVM_MemResourceAllocationSettingData",
@@ -139,12 +140,14 @@ static char* part_component[] = {
         "KVM_ProcResourceAllocationSettingData",
         "KVM_GraphicsResourceAllocationSettingData",
         "KVM_InputResourceAllocationSettingData",
+        "KVM_ConsoleResourceAllocationSettingData",
         "LXC_DiskResourceAllocationSettingData",
         "LXC_MemResourceAllocationSettingData",
         "LXC_NetResourceAllocationSettingData",
         "LXC_ProcResourceAllocationSettingData",
         "LXC_GraphicsResourceAllocationSettingData",
         "LXC_InputResourceAllocationSettingData",
+        "LXC_ConsoleResourceAllocationSettingData",
         NULL
 };

--
2.1.0
