From 8a060e0d178fd88c78fa2aad147492b4949ff63b Mon Sep 17 00:00:00 2001
From: Thilo Boehm <tboehm@linux.vnet.ibm.com>
Date: Wed, 11 Sep 2013 16:45:38 +0200
Subject: [PATCH 18/60] RASD: Schema and Provider Support for Console RASDs

Representing console devices was very limited with the previous
approach using a special graphical display. For instance it
was not possible to define different target types (serial, virtio,
sclp) nor to exploit all source types (pty, file, tcp, ...)
available in libvirt.

With the following new RASD classes it is possible to define
real console resources:
    KVM_ConsoleResouceAllocationSettingData
    Xen_ConsoleResouceAllocationSettingData
    LXC_ConsoleResouceAllocationSettingData

The ResourceType of the returned instances is is '1' (Other) and the
OtherResourceType is 'console'.

Implemented CIM operations:
   enumerate instances
   enumerate instance names
   get instance

Signed-off-by: Thilo Boehm <tboehm@linux.vnet.ibm.com>
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 schema/ResourceAllocationSettingData.mof          | 246 +++++++++++++++++++++-
 schema/ResourceAllocationSettingData.registration |   5 +-
 src/Virt_RASD.c                                   | 149 ++++++++++++-
 3 files changed, 397 insertions(+), 3 deletions(-)

diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof
index 871ab04..ebc4806 100644
--- a/schema/ResourceAllocationSettingData.mof
+++ b/schema/ResourceAllocationSettingData.mof
@@ -1,4 +1,4 @@
-// Copyright IBM Corp. 2007
+// Copyright IBM Corp. 2007, 2013

 [Description ("Xen virtual disk configuration"),
  Provider("cmpi::Virt_RASD")
@@ -445,3 +445,247 @@ class KVM_StorageVolumeResourceAllocationSettingData : KVM_ResourceAllocationSet
       string AllocationUnits;
 };

+[Description ("KVM virtual character device"),
+ Provider("cmpi::Virt_RASD")
+]
+class KVM_CharacterResourceAllocationSettingData : KVM_ResourceAllocationSettingData
+{
+      [Description ("The type of resource in the source/host environment."),
+        ValueMap {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"},
+        Values {"null", "vc", "pty", "dev", "file", "pipe",
+                "stdio", "udp", "tcp", "unix", "spicevmc"},
+        ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourcePath",
+                             "KVM_CharacterResourceAllocationSettingData.ConnectURL",
+                             "KVM_CharacterResourceAllocationSettingData.BindURL"}]
+      uint16 SourceType;
+
+      [Description ("If SourceType=4 ('file'),this is the full qualified file path. "
+                    "The file is opened and all data sent to the character device "
+                    "is written to the file. "
+                    "If SourceType=2 ('pty'),this is the full qualified Pseudo TTY path. "
+                    "A Pseudo TTY is allocated using /dev/ptmx. "
+                    "If SourceType=3 ('dev'), this is the full qualified file path "
+                    "to the underlying phsical character device. The device types must "
+                    "match, eg the emulated serial port should only be connected to a "
+                    "host serial port - don't connect a serial port to a parallel port. "
+                    "If SourceType=5 ('pipe'), this is the full qualified file path "
+                    "of a named pipe."),
+        ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourceType"}]
+      string SourcePath;
+
+      [Description ("This URL describes the connection to a remote or local location "
+                    "where the character devices acts as a client."
+                    "To use a literal IPv6 address in the URI, the literal address should be "
+                    "enclosed in '[' and ']' characters. "
+                    "If SourceType=7 ('udp'), this is defines a udp remote host and port connection "
+                    "to send packages. That the character device acts as a UDP netconsole service, "
+                    "sending and receiving packets, the BindURL property must also be defined. "
+                    "This is a lossy service. "
+                    "Only 'udp' is valid for the protocol part of the URI. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. udp://0.0.0.0:2245 "
+                    "If SourceType=8 ('tcp'), this is defines a remote host and port connection. "
+                    "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. raw://[3ffe:2a00:100:7031::1]:2245 "
+                    "If SourceType=9 ('unix'), this is defined the full qualified file path "
+                    "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. "
+                    "Format of the URL: file://<full qualified file path>. "
+                    "e.g. file:///tmp/console-out"),
+        ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourceType"}]
+      string ConnectURL;
+
+      [Description ("This URL describes the connection to a remote or local location "
+                    "where the character devices acts as a server. "
+                    "To use a literal IPv6 address in the URI, the literal address should be "
+                    "enclosed in '[' and ']' characters. "
+                    "If SourceType=7 ('udp'), this is defines a udp remote host and port connection "
+                    "to receive packages. That the character device acts as a UDP netconsole service, "
+                    "sending and receiving packets, the ConnectURL property must also be defined. "
+                    "This is a lossy service. "
+                    "Only 'udp' is valid for the protocol part of the URI. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. udp://0.0.0.0:2245 "
+                    "If SourceType=8 ('tcp'), this is defines a remote host and port connection. "
+                    "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. raw://[3ffe:2a00:100:7031::1]:2245 "
+                    "If SourceType=9 ('unix'), this is defined the full qualified file path "
+                    "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. "
+                    "Format of the URL: file://<full qualified file path>. "
+                    "e.g. file:///tmp/console-in"),
+        ModelCorrespondence {"KVM_CharacterResourceAllocationSettingData.SourceType"}]
+      string BindURL;
+};
+
+
+[Description ("KVM virtual console device. It is identified by: "
+              "CIM_ResourceAllocationSettingData.ResourceType=1 ( 'Other' ) and "
+              "CIM_ResourceAllocationSettingData.OtherResourceType='console'"),
+ Provider("cmpi::Virt_RASD")
+]
+class KVM_ConsoleResourceAllocationSettingData : KVM_CharacterResourceAllocationSettingData
+{
+      [Description ("The type of the console in the target/guest environment.")]
+      string TargetType;
+};
+
+
+
+[Description ("Xen virtual character device"),
+ Provider("cmpi::Virt_RASD")
+]
+class Xen_CharacterResourceAllocationSettingData : Xen_ResourceAllocationSettingData
+{
+      [Description ("The type of resource in the source/host environment."),
+        ValueMap {"0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10"},
+        Values {"null", "vc", "pty", "dev", "file", "pipe",
+                "stdio", "udp", "tcp", "unix", "spicevmc"},
+        ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourcePath",
+                             "Xen_CharacterResourceAllocationSettingData.ConnectURL",
+                             "Xen_CharacterResourceAllocationSettingData.BindURL"}]
+      uint16 SourceType;
+
+      [Description ("If SourceType=4 ('file'),this is the full qualified file path. "
+                    "The file is opened and all data sent to the character device "
+                    "is written to the file. "
+                    "If SourceType=2 ('pty'),this is the full qualified Pseudo TTY path. "
+                    "A Pseudo TTY is allocated using /dev/ptmx. "
+                    "If SourceType=3 ('dev'), this is the full qualified file path "
+                    "to the underlying phsical character device. The device types must "
+                    "match, eg the emulated serial port should only be connected to a "
+                    "host serial port - don't connect a serial port to a parallel port. "
+                    "If SourceType=5 ('pipe'), this is the full qualified file path "
+                    "of a named pipe."),
+        ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourceType"}]
+      string SourcePath;
+
+      [Description ("This URL describes the connection to a remote or local location "
+                    "where the character devices acts as a client."
+                    "To use a literal IPv6 address in the URI, the literal address should be "
+                    "enclosed in '[' and ']' characters. "
+                    "If SourceType=7 ('udp'), this is defines a udp remote host and port connection "
+                    "to send packages. That the character device acts as a UDP netconsole service, "
+                    "sending and receiving packets, the BindURL property must also be defined. "
+                    "This is a lossy service. "
+                    "Only 'udp' is valid for the protocol part of the URI. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. udp://0.0.0.0:2245 "
+                    "If SourceType=8 ('tcp'), this is defines a remote host and port connection. "
+                    "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. raw://[3ffe:2a00:100:7031::1]:2245 "
+                    "If SourceType=9 ('unix'), this is defined the full qualified file path "
+                    "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. "
+                    "Format of the URL: file://<full qualified file path>. "
+                    "e.g. file:///tmp/console-out"),
+        ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourceType"}]
+      string ConnectURL;
+
+      [Description ("This URL describes the connection to a remote or local location "
+                    "where the character devices acts as a server. "
+                    "To use a literal IPv6 address in the URI, the literal address should be "
+                    "enclosed in '[' and ']' characters. "
+                    "If SourceType=7 ('udp'), this is defines a udp remote host and port connection "
+                    "to receive packages. That the character device acts as a UDP netconsole service, "
+                    "sending and receiving packets, the ConnectURL property must also be defined. "
+                    "This is a lossy service. "
+                    "Only 'udp' is valid for the protocol part of the URI. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. udp://0.0.0.0:2245 "
+                    "If SourceType=8 ('tcp'), this is defines a remote host and port connection. "
+                    "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. raw://[3ffe:2a00:100:7031::1]:2245 "
+                    "If SourceType=9 ('unix'), this is defined the full qualified file path "
+                    "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. "
+                    "Format of the URL: file://<full qualified file path>. "
+                    "e.g. file:///tmp/console-in"),
+        ModelCorrespondence {"Xen_CharacterResourceAllocationSettingData.SourceType"}]
+      string BindURL;
+};
+
+
+[Description ("Xen virtual console device. It is identified by: "
+              "CIM_ResourceAllocationSettingData.ResourceType=1 ( 'Other' ) and "
+              "CIM_ResourceAllocationSettingData.OtherResourceType='console'"),
+ Provider("cmpi::Virt_RASD")
+]
+class Xen_ConsoleResourceAllocationSettingData : Xen_CharacterResourceAllocationSettingData
+{
+      [Description ( "The type of the console in the target/guest environment.")]
+      string TargetType;
+};
+
+[Description ("LXC virtual character device"),
+ Provider("cmpi::Virt_RASD")
+]
+class LXC_CharacterResourceAllocationSettingData : LXC_ResourceAllocationSettingData
+{
+      [Description ("The type of resource in the source/host environment."),
+        ValueMap {"0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10"},
+        Values {"null", "vc", "pty", "dev", "file", "pipe",
+                "stdio", "udp", "tcp", "unix", "spicevmc"},
+        ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourcePath",
+                             "LXC_CharacterResourceAllocationSettingData.ConnectURL",
+                             "LXC_CharacterResourceAllocationSettingData.BindURL"}]
+      uint16 SourceType;
+
+      [Description ("If SourceType=4 ('file'),this is the full qualified file path. "
+                    "The file is opened and all data sent to the character device "
+                    "is written to the file. "
+                    "If SourceType=2 ('pty'),this is the full qualified Pseudo TTY path. "
+                    "A Pseudo TTY is allocated using /dev/ptmx. "
+                    "If SourceType=3 ('dev'), this is the full qualified file path "
+                    "to the underlying phsical character device. The device types must "
+                    "match, eg the emulated serial port should only be connected to a "
+                    "host serial port - don't connect a serial port to a parallel port. "
+                    "If SourceType=5 ('pipe'), this is the full qualified file path "
+                    "of a named pipe."),
+        ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourceType"}]
+      string SourcePath;
+
+      [Description ("This URL describes the connection to a remote or local location "
+                    "where the character devices acts as a client."
+                    "To use a literal IPv6 address in the URI, the literal address should be "
+                    "enclosed in '[' and ']' characters. "
+                    "If SourceType=7 ('udp'), this is defines a udp remote host and port connection "
+                    "to send packages. That the character device acts as a UDP netconsole service, "
+                    "sending and receiving packets, the BindURL property must also be defined. "
+                    "This is a lossy service. "
+                    "Only 'udp' is valid for the protocol part of the URI. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. udp://0.0.0.0:2245 "
+                    "If SourceType=8 ('tcp'), this is defines a remote host and port connection. "
+                    "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. raw://[3ffe:2a00:100:7031::1]:2245 "
+                    "If SourceType=9 ('unix'), this is defined the full qualified file path "
+                    "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. "
+                    "Format of the URL: file://<full qualified file path>. "
+                    "e.g. file:///tmp/console-out"),
+        ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourceType"}]
+      string ConnectURL;
+
+      [Description ("This URL describes the connection to a remote or local location "
+                    "where the character devices acts as a server. "
+                    "To use a literal IPv6 address in the URI, the literal address should be "
+                    "enclosed in '[' and ']' characters. "
+                    "If SourceType=7 ('udp'), this is defines a udp remote host and port connection "
+                    "to receive packages. That the character device acts as a UDP netconsole service, "
+                    "sending and receiving packets, the ConnectURL property must also be defined. "
+                    "This is a lossy service. "
+                    "Only 'udp' is valid for the protocol part of the URI. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. udp://0.0.0.0:2245 "
+                    "If SourceType=8 ('tcp'), this is defines a remote host and port connection. "
+                    "The protocol part of the URI can be: 'raw', 'telnet', 'telnets', 'tls'. "
+                    "Format of the URL: <protocol>://<host>:<port>. e.g. raw://[3ffe:2a00:100:7031::1]:2245 "
+                    "If SourceType=9 ('unix'), this is defined the full qualified file path "
+                    "of a Unix domain socket. Only 'file' is valid for the protocol part of the URI. "
+                    "Format of the URL: file://<full qualified file path>. "
+                    "e.g. file:///tmp/console-in"),
+        ModelCorrespondence {"LXC_CharacterResourceAllocationSettingData.SourceType"}]
+      string BindURL;
+};
+
+
+[Description ("LXC virtual console device. It is identified by: "
+              "CIM_ResourceAllocationSettingData.ResourceType=1 ( 'Other' ) and "
+              "CIM_ResourceAllocationSettingData.OtherResourceType='console'"),
+ Provider("cmpi::Virt_RASD")
+]
+class LXC_ConsoleResourceAllocationSettingData : LXC_CharacterResourceAllocationSettingData
+{
+      [Description ("The type of the console in the target/guest environment.")]
+      string TargetType;
+};
diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration
index 2747f91..b969bfe 100644
--- a/schema/ResourceAllocationSettingData.registration
+++ b/schema/ResourceAllocationSettingData.registration
@@ -1,4 +1,4 @@
-# Copyright IBM Corp. 2007
+# Copyright IBM Corp. 2007, 2013
 # Classname Namespace ProviderName ProviderModule ProviderTypes
 Xen_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
 Xen_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
@@ -6,14 +6,17 @@ 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
+Xen_ConsoleResourceAllocationSettingData 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
+KVM_ConsoleResourceAllocationSettingData 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
+LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c
index 150ccd3..e28d4e6 100644
--- a/src/Virt_RASD.c
+++ b/src/Virt_RASD.c
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corp. 2007
+ * Copyright IBM Corp. 2007, 2013
  *
  * Authors:
  *  Dan Smith <danms@us.ibm.com>
@@ -662,6 +662,143 @@ static CMPIStatus set_graphics_rasd_params(const struct virt_device *dev,
         return s;
 }

+static char* _build_console_url(const char *protocol,
+                                const char *host,
+                                const char *port)
+{
+        char* result = NULL;
+
+        if (host == NULL)
+                goto out;
+
+        if (protocol != NULL && STREQC("file", protocol)) {
+                /* The host string contains the file name.
+                   Even if the file name does not start with a '/'
+                   it is treated by libvirt as a full qualified path.
+                */
+                if (host[0] == '/') {
+                        if (asprintf(&result, "file://%s", host) < 0)
+                                result = NULL;
+                        goto out;
+                } else {
+                        if (asprintf(&result, "file:///%s", host) < 0)
+                                result = NULL;
+                        goto out;
+                }
+        }
+        /* The assumption is that the host does not contain a port.
+           If the host string contains a ':',
+           the host is treated as an IPv6 address.
+        */
+        if (strchr(host, ':') == NULL) {
+                if (port == NULL) {
+                        if (asprintf(&result,"%s://%s", protocol, host) < 0)
+                                result = NULL;
+                        goto out;
+                } else {
+                        if (asprintf(&result,"%s://%s:%s", protocol,
+                                     host,port) < 0)
+                                result = NULL;
+                        goto out;
+                }
+        }
+ out:
+        return result;
+}
+
+
+static CMPIStatus set_console_rasd_params(const struct virt_device *vdev,
+                                          CMPIInstance *inst)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        const struct console_device *cdev = NULL;
+        char* tmp = NULL;
+
+        cdev = &vdev->dev.console;
+
+        CMSetProperty(inst, "OtherResourceType", "console", CMPI_chars);
+        CMSetProperty(inst, "SourceType",
+                      (CMPIValue *)&cdev->source_type, CMPI_uint16);
+        CMSetProperty(inst, "TargetType",
+                      (CMPIValue *)cdev->target_type, CMPI_chars);
+
+        switch (cdev->source_type) {
+        case CIM_CHARDEV_SOURCE_TYPE_PTY:
+                CMSetProperty(inst, "SourcePath",
+                              (CMPIValue *)cdev->source_dev.pty.path,
+                              CMPI_chars);
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_DEV:
+                CMSetProperty(inst, "SourcePath",
+                              (CMPIValue *)cdev->source_dev.dev.path,
+                              CMPI_chars);
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_FILE:
+                CMSetProperty(inst, "SourcePath",
+                              (CMPIValue *)cdev->source_dev.file.path,
+                              CMPI_chars);
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_PIPE:
+                CMSetProperty(inst, "SourcePath",
+                              (CMPIValue *)cdev->source_dev.pipe.path,
+                              CMPI_chars);
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_UNIXSOCK:
+                tmp = _build_console_url("file",
+                                         cdev->source_dev.unixsock.path, NULL);
+                if (cdev->source_dev.unixsock.mode != NULL) {
+                        if (STREQC(cdev->source_dev.unixsock.mode, "bind"))
+                                CMSetProperty(inst, "BindURL",
+                                              (CMPIValue *)tmp, CMPI_chars);
+                        else if (STREQC(cdev->source_dev.unixsock.mode,
+                                        "connect"))
+                                CMSetProperty(inst, "ConnectURL",
+                                              (CMPIValue *)tmp, CMPI_chars);
+                }
+                free(tmp);
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_UDP:
+                tmp = _build_console_url("udp",
+                                         cdev->source_dev.udp.bind_host,
+                                         cdev->source_dev.udp.bind_service);
+                CMSetProperty(inst, "BindURL",
+                              (CMPIValue *)tmp, CMPI_chars);
+                free(tmp);
+
+                tmp = _build_console_url("udp",
+                                         cdev->source_dev.udp.connect_host,
+                                         cdev->source_dev.udp.connect_service);
+                CMSetProperty(inst, "ConnectURL", (CMPIValue *)tmp, CMPI_chars);
+                free(tmp);
+                break;
+        case CIM_CHARDEV_SOURCE_TYPE_TCP:
+                tmp = _build_console_url(cdev->source_dev.tcp.protocol,
+                                         cdev->source_dev.tcp.host,
+                                         cdev->source_dev.tcp.service);
+                if (cdev->source_dev.tcp.mode != NULL) {
+                        if (STREQC(cdev->source_dev.tcp.mode, "bind"))
+                                CMSetProperty(inst, "BindURL",
+                                              (CMPIValue *)tmp, CMPI_chars);
+                        else if (STREQC(cdev->source_dev.tcp.mode, "connect"))
+                                CMSetProperty(inst, "ConnectURL",
+                                              (CMPIValue *)tmp, CMPI_chars);
+                }
+                free(tmp);
+                break;
+
+        default:
+                /* Nothing to do for :
+                   CIM_CHARDEV_SOURCE_TYPE_STDIO
+                   CIM_CHARDEV_SOURCE_TYPE_NULL
+                   CIM_CHARDEV_SOURCE_TYPE_VC
+                   CIM_CHARDEV_SOURCE_TYPE_SPICEVMC
+                */
+                break;
+        }
+
+        return s;
+}
+
 static CMPIStatus set_input_rasd_params(const struct virt_device *dev,
                                         CMPIInstance *inst)
 {
@@ -721,6 +858,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker,
         } else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
                 type = CIM_RES_TYPE_GRAPHICS;
                 base = "GraphicsResourceAllocationSettingData";
+        } else if (dev->type == CIM_RES_TYPE_CONSOLE) {
+                type = CIM_RES_TYPE_OTHER;
+                base = "ConsoleResourceAllocationSettingData";
         } else if (dev->type == CIM_RES_TYPE_INPUT) {
                 type = CIM_RES_TYPE_INPUT;
                 base = "InputResourceAllocationSettingData";
@@ -777,6 +917,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker,
                 s = set_graphics_rasd_params(dev, inst, host, CLASSNAME(ref));
         } else if (dev->type == CIM_RES_TYPE_INPUT) {
                 s = set_input_rasd_params(dev, inst);
+        } else if (dev->type == CIM_RES_TYPE_CONSOLE) {
+                s = set_console_rasd_params(dev, inst);
         }

         /* FIXME: Put the HostResource in place */
@@ -909,6 +1051,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type)
                *type = CIM_RES_TYPE_INPUT;
        else if (STREQ(base, "StorageVolumeResourceAllocationSettingData"))
                *type = CIM_RES_TYPE_IMAGE;
+       else if (STREQ(base, "ConsoleResourceAllocationSettingData"))
+               *type = CIM_RES_TYPE_CONSOLE;
        else
                goto out;

@@ -940,6 +1084,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname)
         case CIM_RES_TYPE_GRAPHICS:
                 *classname = "GraphicsResourceAllocationSettingData";
                 break;
+        case CIM_RES_TYPE_CONSOLE:
+                *classname = "ConsoleResourceAllocationSettingData";
+                break;
         case CIM_RES_TYPE_INPUT:
                 *classname = "InputResourceAllocationSettingData";
                 break;
--
2.1.0
