# HG changeset patch
# User Wayne Xia <xiawenc(a)linux.vnet.ibm.com>
# Date 1311156234 -28800
# Node ID 0c52e4f6c421cc2e168197a82a9333d4ce369655
# Parent 3c90a88a5199a4ed931a4a76097cff8f55deae41
made the graphic structure as union
These change were made to allow SDL device properties added more
clearly, the graphic_device structure now contains a union
Signed-off-by: Wayne Xia (Wayne) <xiawenc(a)linux.vnet.ibm.com>
diff -r 3c90a88a5199 -r 0c52e4f6c421 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Mon Jul 18 11:13:40 2011 -0300
+++ b/libxkutil/device_parsing.c Wed Jul 20 18:03:54 2011 +0800
@@ -91,10 +91,10 @@
static void cleanup_graphics_device(struct graphics_device *dev)
{
free(dev->type);
- free(dev->port);
- free(dev->host);
- free(dev->keymap);
- free(dev->passwd);
+ free(dev->dev.vnc.port);
+ free(dev->dev.vnc.host);
+ free(dev->dev.vnc.keymap);
+ free(dev->dev.vnc.passwd);
}
static void cleanup_input_device(struct input_device *dev)
@@ -522,12 +522,12 @@
CU_DEBUG("graphics device type = %s", gdev->type);
if (STREQC(gdev->type, "vnc")) {
- gdev->port = get_attr_value(node, "port");
- gdev->host = get_attr_value(node, "listen");
- gdev->keymap = get_attr_value(node, "keymap");
- gdev->passwd = get_attr_value(node, "passwd");
+ gdev->dev.vnc.port = get_attr_value(node, "port");
+ gdev->dev.vnc.host = get_attr_value(node, "listen");
+ gdev->dev.vnc.keymap = get_attr_value(node, "keymap");
+ gdev->dev.vnc.passwd = get_attr_value(node, "passwd");
- if (gdev->port == NULL || gdev->host == NULL)
+ if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host ==
NULL)
goto err;
}
else if (STREQC(gdev->type, "pty")) {
@@ -542,9 +542,9 @@
for (child = node->children; child != NULL;
child = child->next) {
if (XSTREQ(child->name, "source"))
- gdev->host = get_attr_value(child, "path");
+ gdev->dev.vnc.host =
get_attr_value(child, "path");
else if (XSTREQ(child->name, "target"))
- gdev->port = get_attr_value(child, "port");
+ gdev->dev.vnc.port =
get_attr_value(child, "port");
}
}
else {
@@ -557,7 +557,7 @@
if (STREQC(gdev->type, "vnc"))
ret = asprintf(&vdev->id, "%s", gdev->type);
else
- ret = asprintf(&vdev->id, "%s:%s", gdev->type,
gdev->port);
+ ret = asprintf(&vdev->id, "%s:%s", gdev->type,
gdev->dev.vnc.port);
if (ret == -1) {
CU_DEBUG("Failed to create graphics is string");
@@ -798,9 +798,10 @@
DUP_FIELD(dev, _dev, dev.emu.path);
} 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);
- DUP_FIELD(dev, _dev, dev.graphics.keymap);
+ DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.host);
+ DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.port);
+ DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.keymap);
+ DUP_FIELD(dev, _dev, dev.graphics.dev.vnc.passwd);
} else if (dev->type == CIM_RES_TYPE_INPUT) {
DUP_FIELD(dev, _dev, dev.input.type);
DUP_FIELD(dev, _dev, dev.input.bus);
diff -r 3c90a88a5199 -r 0c52e4f6c421 libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Mon Jul 18 11:13:40 2011 -0300
+++ b/libxkutil/device_parsing.h Wed Jul 20 18:03:54 2011 +0800
@@ -83,14 +83,28 @@
char *path;
};
-struct graphics_device {
- char *type;
+//vnc_device must be larger or equal than sdl_device
+struct vnc_device {
char *port;
char *host;
char *keymap;
char *passwd;
};
+struct sdl_device {
+ char *display;
+ char *xauth;
+ char *fullscreen;
+};
+
+struct graphics_device {
+ char *type;
+ union {
+ struct vnc_device vnc;
+ struct sdl_device sdl;
+ } dev;
+};
+
struct input_device {
char *type;
char *bus;
diff -r 3c90a88a5199 -r 0c52e4f6c421 libxkutil/xml_parse_test.c
--- a/libxkutil/xml_parse_test.c Mon Jul 18 11:13:40 2011 -0300
+++ b/libxkutil/xml_parse_test.c Wed Jul 20 18:03:54 2011 +0800
@@ -116,7 +116,7 @@
FILE *d)
{
print_value(d, "Graphics Type", dev->dev.graphics.type);
- print_value(d, "Graphics Port", dev->dev.graphics.port);
+ print_value(d, "Graphics Port", dev->dev.graphics.dev.vnc.port);
}
static void print_devices(struct domain *dominfo,
diff -r 3c90a88a5199 -r 0c52e4f6c421 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Mon Jul 18 11:13:40 2011 -0300
+++ b/libxkutil/xmlgen.c Wed Jul 20 18:03:54 2011 +0800
@@ -424,22 +424,22 @@
if (STREQC(dev->type, "sdl"))
return NULL;
- if (dev->port) {
- xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
- if (STREQC(dev->port, "-1"))
+ if (dev->dev.vnc.port) {
+ xmlNewProp(tmp, BAD_CAST "port", BAD_CAST
dev->dev.vnc.port);
+ if (STREQC(dev->dev.vnc.port, "-1"))
xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST
"yes");
else
xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST
"no");
}
- if (dev->host)
- xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host);
+ if (dev->dev.vnc.host)
+ xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST
dev->dev.vnc.host);
- if (dev->passwd)
- xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->passwd);
+ if (dev->dev.vnc.passwd)
+ xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST
dev->dev.vnc.passwd);
- if (dev->keymap)
- xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap);
+ if (dev->dev.vnc.keymap)
+ xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST
dev->dev.vnc.keymap);
return NULL;
}
@@ -460,15 +460,15 @@
if (tmp == NULL)
return XML_ERROR;
- if(dev->host)
- xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host);
+ if(dev->dev.vnc.host)
+ xmlNewProp(tmp, BAD_CAST "path", BAD_CAST
dev->dev.vnc.host);
tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL);
if (tmp == NULL)
return XML_ERROR;
- if(dev->port)
- xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port);
+ if(dev->dev.vnc.port)
+ xmlNewProp(tmp, BAD_CAST "port", BAD_CAST
dev->dev.vnc.port);
return NULL;
}
diff -r 3c90a88a5199 -r 0c52e4f6c421 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Mon Jul 18 11:13:40 2011 -0300
+++ b/src/Virt_ComputerSystem.c Wed Jul 20 18:03:54 2011 +0800
@@ -104,7 +104,7 @@
"Virtual System (Console on %s://%s:%s)",
domain->dev_graphics[0].dev.graphics.type,
host,
- domain->dev_graphics[0].dev.graphics.port);
+
domain->dev_graphics[0].dev.graphics.dev.vnc.port);
else
ret = asprintf(&cap,
"Virtual System (No console)");
diff -r 3c90a88a5199 -r 0c52e4f6c421 src/Virt_Device.c
--- a/src/Virt_Device.c Mon Jul 18 11:13:40 2011 -0300
+++ b/src/Virt_Device.c Wed Jul 20 18:03:54 2011 +0800
@@ -194,8 +194,8 @@
else
rc = asprintf(&vp_str, "%s/%s:%s",
dev->type,
- dev->host,
- dev->port);
+ dev->dev.vnc.host,
+ dev->dev.vnc.port);
if (rc == -1)
return 0;
diff -r 3c90a88a5199 -r 0c52e4f6c421 src/Virt_KVMRedirectionSAP.c
--- a/src/Virt_KVMRedirectionSAP.c Mon Jul 18 11:13:40 2011 -0300
+++ b/src/Virt_KVMRedirectionSAP.c Wed Jul 20 18:03:54 2011 +0800
@@ -366,7 +366,7 @@
continue;
}
- ret = sscanf(dominfo->dev_graphics->dev.graphics.port,
+ ret =
sscanf(dominfo->dev_graphics->dev.graphics.dev.vnc.port,
"%d",
&lport);
if (ret != 1) {
diff -r 3c90a88a5199 -r 0c52e4f6c421 src/Virt_RASD.c
--- a/src/Virt_RASD.c Mon Jul 18 11:13:40 2011 -0300
+++ b/src/Virt_RASD.c Wed Jul 20 18:03:54 2011 +0800
@@ -425,8 +425,8 @@
else {
rc = asprintf(&addr_str,
"%s:%s",
- dev->dev.graphics.host,
- dev->dev.graphics.port);
+ dev->dev.graphics.dev.vnc.host,
+ dev->dev.graphics.dev.vnc.port);
}
CU_DEBUG("graphics Address = %s", addr_str);
@@ -439,7 +439,7 @@
if (STREQC(dev->dev.graphics.type, "vnc")) {
CMSetProperty(inst, "KeyMap",
- (CMPIValue *)dev->dev.graphics.keymap,
CMPI_chars);
+ (CMPIValue
*)dev->dev.graphics.dev.vnc.keymap, CMPI_chars);
conn = connect_by_classname(_BROKER, classname, &s);
if (conn == NULL)
diff -r 3c90a88a5199 -r 0c52e4f6c421
src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Mon Jul 18 11:13:40 2011
-0300
+++ b/src/Virt_VirtualSystemManagementService.c Wed Jul 20 18:03:54 2011
+0800
@@ -370,9 +370,9 @@
}
domain->dev_graphics->dev.graphics.type = strdup("vnc");
- domain->dev_graphics->dev.graphics.port = strdup("-1");
- domain->dev_graphics->dev.graphics.host = strdup("127.0.0.1");
- domain->dev_graphics->dev.graphics.keymap = strdup("en-us");
+ domain->dev_graphics->dev.graphics.dev.vnc.port = strdup("-1");
+ domain->dev_graphics->dev.graphics.dev.vnc.host =
strdup("127.0.0.1");
+ domain->dev_graphics->dev.graphics.dev.vnc.keymap =
strdup("en-us");
domain->dev_graphics_ct = 1;
return true;
@@ -1128,24 +1128,24 @@
}
ret = parse_vnc_address(val,
- &dev->dev.graphics.host,
- &dev->dev.graphics.port);
+ &dev->dev.graphics.dev.vnc.host,
+ &dev->dev.graphics.dev.vnc.port);
if (ret != 1) {
msg = "GraphicsRASD field Address not valid";
goto out;
}
if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK)
- dev->dev.graphics.keymap = strdup("en-us");
+ dev->dev.graphics.dev.vnc.keymap = strdup("en-us");
else
- dev->dev.graphics.keymap = strdup(val);
+ dev->dev.graphics.dev.vnc.keymap = strdup(val);
if (cu_get_str_prop(inst, "Password", &val) !=
CMPI_RC_OK) {
CU_DEBUG("vnc password is not set");
- dev->dev.graphics.passwd = NULL;
+ dev->dev.graphics.dev.vnc.passwd = NULL;
} else {
CU_DEBUG("vnc password is set");
- dev->dev.graphics.passwd = strdup(val);
+ dev->dev.graphics.dev.vnc.passwd = strdup(val);
}
}
else if (STREQC(dev->dev.graphics.type, "console") ||
@@ -1156,8 +1156,8 @@
}
ret = parse_console_address(val,
- &dev->dev.graphics.host,
- &dev->dev.graphics.port);
+ &dev->dev.graphics.dev.vnc.host,
+ &dev->dev.graphics.dev.vnc.port);
if (ret != 1) {
msg = "GraphicsRASD field Address not valid";
goto out;
@@ -1174,7 +1174,7 @@
ret = asprintf(&dev->id, "%s",
dev->dev.graphics.type);
else
ret = asprintf(&dev->id, "%s:%s",
- dev->dev.graphics.type,
dev->dev.graphics.port);
+ dev->dev.graphics.type,
dev->dev.graphics.dev.vnc.port);
if (ret == -1) {
msg = "Failed to create graphics is string";
@@ -1545,7 +1545,7 @@
dev = dominfo->dev_graphics;
if(dev != NULL){
- if (dev->dev.graphics.passwd != NULL)
+ if (dev->dev.graphics.dev.vnc.passwd != NULL)
infostore_set_bool(ctx, "has_vnc_passwd", true);
else
infostore_set_bool(ctx, "has_vnc_passwd", false);