# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1224705263 25200
# Node ID d596bd28133bc08ff45efe70423a43a8e7ce9ea4
# Parent 3d734d8e65009230d91887b934567d3f4548d1ba
Add support for graphics device to Virt_RASD.c
Also add field for a hostname / IP address to the graphics struct. This field
is for storing the console's listen address. This will allow the user to
set a specific address to listen on, in addition to a specific port.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 3d734d8e6500 -r d596bd28133b libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Wed Oct 22 09:24:16 2008 -0700
+++ b/libxkutil/device_parsing.c Wed Oct 22 12:54:23 2008 -0700
@@ -76,6 +76,7 @@
{
free(dev->type);
free(dev->port);
+ free(dev->host);
}
static void cleanup_input_device(struct input_device *dev)
@@ -447,9 +448,13 @@
gdev->type = get_attr_value(node, "type");
gdev->port = get_attr_value(node, "port");
+ gdev->host = get_attr_value(node, "listen");
if ((gdev->type == NULL) || (gdev->port == NULL))
goto err;
+
+ if (gdev->host == NULL)
+ gdev->host = strdup("127.0.0.1");
vdev->type = CIM_RES_TYPE_GRAPHICS;
vdev->id = strdup("graphics");
@@ -665,6 +670,7 @@
} else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
DUP_FIELD(dev, _dev, dev.graphics.type);
DUP_FIELD(dev, _dev, dev.graphics.port);
+ DUP_FIELD(dev, _dev, dev.graphics.host);
} else if (dev->type == CIM_RES_TYPE_INPUT) {
DUP_FIELD(dev, _dev, dev.input.type);
DUP_FIELD(dev, _dev, dev.input.bus);
diff -r 3d734d8e6500 -r d596bd28133b libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Wed Oct 22 09:24:16 2008 -0700
+++ b/libxkutil/device_parsing.h Wed Oct 22 12:54:23 2008 -0700
@@ -62,6 +62,7 @@
struct graphics_device {
char *type;
char *port;
+ char *host;
};
struct input_device {
diff -r 3d734d8e6500 -r d596bd28133b schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof Wed Oct 22 09:24:16 2008 -0700
+++ b/schema/ResourceAllocationSettingData.mof Wed Oct 22 12:54:23 2008 -0700
@@ -115,3 +115,25 @@
class LXC_MemResourceAllocationSettingData : LXC_ResourceAllocationSettingData
{
};
+
+[Description ("Xen virtual graphics device"),
+ Provider("cmpi::Virt_RASD")
+]
+class Xen_GraphicsResourceAllocationSettingData : Xen_ResourceAllocationSettingData
+{
+};
+
+[Description ("KVM virtual graphics device"),
+ Provider("cmpi::Virt_RASD")
+]
+class KVM_GraphicsResourceAllocationSettingData : KVM_ResourceAllocationSettingData
+{
+};
+
+[Description ("LXC virtual graphics device"),
+ Provider("cmpi::Virt_RASD")
+]
+class LXC_GraphicsResourceAllocationSettingData : LXC_ResourceAllocationSettingData
+{
+};
+
diff -r 3d734d8e6500 -r d596bd28133b schema/ResourceAllocationSettingData.registration
--- a/schema/ResourceAllocationSettingData.registration Wed Oct 22 09:24:16 2008 -0700
+++ b/schema/ResourceAllocationSettingData.registration Wed Oct 22 12:54:23 2008 -0700
@@ -4,10 +4,13 @@
Xen_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance
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
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
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
diff -r 3d734d8e6500 -r d596bd28133b src/Virt_RASD.c
--- a/src/Virt_RASD.c Wed Oct 22 09:24:16 2008 -0700
+++ b/src/Virt_RASD.c Wed Oct 22 12:54:23 2008 -0700
@@ -247,6 +247,29 @@
return s;
}
+static CMPIStatus set_graphics_rasd_params(const struct virt_device *dev,
+ CMPIInstance *inst)
+{
+ int rc;
+ char *addr_str = NULL;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+
+ rc = asprintf(&addr_str,
+ "%s:%s",
+ dev->dev.graphics.host,
+ dev->dev.graphics.port);
+ if (rc == -1) {
+ goto out;
+ }
+
+ CMSetProperty(inst, "Address", (CMPIValue *)addr_str, CMPI_chars);
+
+ out:
+ free(addr_str);
+
+ return s;
+}
+
static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker,
struct virt_device *dev,
const char *host,
@@ -272,6 +295,9 @@
} else if (dev->type == CIM_RES_TYPE_MEM) {
type = CIM_RES_TYPE_MEM;
base = "MemResourceAllocationSettingData";
+ } else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
+ type = CIM_RES_TYPE_GRAPHICS;
+ base = "GraphicsResourceAllocationSettingData";
} else {
return NULL;
}
@@ -320,6 +346,8 @@
(CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64);
} else if (dev->type == CIM_RES_TYPE_PROC) {
set_proc_rasd_params(broker, ref, dev, host, inst);
+ } else if (dev->type == CIM_RES_TYPE_GRAPHICS) {
+ s = set_graphics_rasd_params(dev, inst);
}
/* FIXME: Put the HostResource in place */
@@ -441,6 +469,8 @@
*type = CIM_RES_TYPE_PROC;
else if (STREQ(base, "MemResourceAllocationSettingData"))
*type = CIM_RES_TYPE_MEM;
+ else if (STREQ(base, "GraphicsResourceAllocationSettingData"))
+ *type = CIM_RES_TYPE_GRAPHICS;
else
goto out;
@@ -468,6 +498,9 @@
break;
case CIM_RES_TYPE_DISK:
*classname = "DiskResourceAllocationSettingData";
+ break;
+ case CIM_RES_TYPE_GRAPHICS:
+ *classname = "GraphicsResourceAllocationSettingData";
break;
default:
rc = CMPI_RC_ERR_FAILED;