[Libvirt-cim] [PATCH 2 of 2] (#4) add sdl frame buffer support

Wayne Xia xiawenc at linux.vnet.ibm.com
Fri Jul 29 07:05:50 UTC 2011


# HG changeset patch
# User Wayne Xia <xiawenc at linux.vnet.ibm.com>
# Date 1311670971 -28800
# Node ID f170cdc0acb579c417327e8179c2f23d09b34281
# Parent  640ea61807cff06e1d15fd1885a8daaf6f2ffa3a
(#4) add sdl frame buffer support.

Now libvirt still supports sdl frame buffer, and it may take three
parameters: display,xauth,fullscreen. This patch enable the libvirt-cim
to accept these configuration and pass them in XML define to let
libvirt know about it. Exposed interface could be found in the file
ResourceAllocationSettingData.mof.

#4 removed the link in the comments.

Signed-off-by: Wayne Xia (Wayne) <xiawenc at linux.vnet.ibm.com>

diff -r 640ea61807cf -r f170cdc0acb5 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c	Mon Jul 25 19:39:08 2011 +0800
+++ b/libxkutil/device_parsing.c	Tue Jul 26 17:02:51 2011 +0800
@@ -556,6 +556,11 @@
                 if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL)
                         goto err;
         }
+        else if (STREQC(gdev->type, "sdl")) {
+                gdev->dev.sdl.display = get_attr_value(node, "display");
+                gdev->dev.sdl.xauth = get_attr_value(node, "xauth");
+                gdev->dev.sdl.fullscreen = get_attr_value(node, "fullscreen");
+        }
         else if (STREQC(gdev->type, "pty")) {
                 if (node->name == NULL)
                         goto err;
diff -r 640ea61807cf -r f170cdc0acb5 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c	Mon Jul 25 19:39:08 2011 +0800
+++ b/libxkutil/xmlgen.c	Tue Jul 26 17:02:51 2011 +0800
@@ -421,8 +421,21 @@
 
         xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type);
 
-        if (STREQC(dev->type, "sdl"))
-               return NULL;
+        if (STREQC(dev->type, "sdl")) {
+                if (dev->dev.sdl.display) {
+                        xmlNewProp(tmp, BAD_CAST "display",
+                                        BAD_CAST dev->dev.sdl.display);
+                }
+                if (dev->dev.sdl.xauth) {
+                        xmlNewProp(tmp, BAD_CAST "xauth",
+                                        BAD_CAST dev->dev.sdl.xauth);
+                }
+                if (dev->dev.sdl.fullscreen) {
+                        xmlNewProp(tmp, BAD_CAST "fullscreen",
+                                        BAD_CAST dev->dev.sdl.fullscreen);
+                }
+                return NULL;
+        }
 
         if (dev->dev.vnc.port) {
                 xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->dev.vnc.port);
diff -r 640ea61807cf -r f170cdc0acb5 schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof	Mon Jul 25 19:39:08 2011 +0800
+++ b/schema/ResourceAllocationSettingData.mof	Tue Jul 26 17:02:51 2011 +0800
@@ -219,7 +219,9 @@
       [Description ("If ResourceSubType is 'vnc', this is a VNC Address. "
        "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType "
        "is 'console', this is a character device path in "
-       "path:port format (e.g., '/dev/pts/3:0'\)")]
+       "path:port format (e.g., '/dev/pts/3:0'\) "
+       "if ResourceSubType is 'sdl', this is a combination of its params as "
+       "xauth:display (e.g., '/root/.Xauthority::0'\)")]
       string Address;
 
       [Description ("Keyboard keymapping")]
@@ -228,7 +230,8 @@
       [Description ("VNC password")]
       string Password;
 
-      [Description ("Is IPv6 only addressing is to be used")]
+      [Description ("Is IPv6 only addressing is to be used."
+      "if ResourceSubType is 'sdl', this means whether sdl is fullscreen")]
       boolean IsIPv6Only;
 };
 
diff -r 640ea61807cf -r f170cdc0acb5 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Mon Jul 25 19:39:08 2011 +0800
+++ b/src/Virt_VirtualSystemManagementService.c	Tue Jul 26 17:02:51 2011 +0800
@@ -1060,6 +1060,52 @@
         return ret;
 }
 
+static int parse_sdl_address(const char *id,
+                        char **display,
+                        char **xauth)
+{
+        int ret;
+        char *tmp_display = NULL;
+        char *tmp_xauth = NULL;
+
+        CU_DEBUG("Entering parse_sdl_address, address is %s", id);
+
+        ret = sscanf(id, "%a[^:]:%as", &tmp_xauth, &tmp_display);
+
+        if (ret <= 0) {
+                ret = sscanf(id, ":%as", &tmp_display);
+                if (ret <= 0) {
+                        if (STREQC(id, ":")) {
+                                /* do nothing, it is empty */
+                        }
+                        else {
+                                ret = 0;
+                                goto out;
+                        }
+                }
+        }
+
+        if (display) {
+                if (tmp_display == NULL)
+                    *display = NULL;
+                else
+                    *display = strdup(tmp_display);
+        }
+        if (xauth) {
+                if (tmp_xauth == NULL)
+                    *xauth = NULL;
+                else
+                    *xauth = strdup(tmp_xauth);
+        }
+        ret = 1;
+
+ out:
+        CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s",
+               *display, *xauth);
+
+        return ret;
+}
+
 static int parse_vnc_address(const char *id,
                       char **ip,
                       char **port)
@@ -1163,6 +1209,30 @@
                          msg = "GraphicsRASD field Address not valid";
                          goto out;
                 }
+        }
+        else if (STREQC(dev->dev.graphics.type, "sdl")) {
+                if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) {
+                         CU_DEBUG("sdl graphics Address empty, using default");
+                         dev->dev.graphics.dev.sdl.display = NULL;
+                         dev->dev.graphics.dev.sdl.xauth = NULL;
+                }
+                else {
+                         ret = parse_sdl_address(val,
+                                         &dev->dev.graphics.dev.sdl.display,
+                                         &dev->dev.graphics.dev.sdl.xauth);
+                         if (ret != 1) {
+                                  msg = "GraphicsRASD sdl Address not valid";
+                                  goto out;
+                         }
+                }
+                dev->dev.graphics.dev.sdl.fullscreen = NULL;
+                if (cu_get_bool_prop(inst, "IsIPV6Only", &ipv6) ==
+                                CMPI_RC_OK) {
+                                if (ipv6)
+                                        dev->dev.graphics.dev.sdl.fullscreen = strdup("yes");
+                                else
+                                        dev->dev.graphics.dev.sdl.fullscreen = strdup("no");
+                }
         } else { 
                 CU_DEBUG("Unsupported graphics type %s", 
                         dev->dev.graphics.type);
@@ -1171,7 +1241,8 @@
         }
 
         free(dev->id);
-        if (STREQC(dev->dev.graphics.type, "vnc"))
+        if ((STREQC(dev->dev.graphics.type, "vnc"))||
+                (STREQC(dev->dev.graphics.type, "sdl")))
                 ret = asprintf(&dev->id, "%s", dev->dev.graphics.type);
         else
                 ret = asprintf(&dev->id, "%s:%s",




More information about the Libvirt-cim mailing list