[Libvirt-cim] [PATCH v2 2/2] Add SDL graphic device support

Wayne Xia xiawenc at linux.vnet.ibm.com
Wed Jul 20 12:17:15 UTC 2011


# HG changeset patch
# User Wayne Xia <xiawenc at linux.vnet.ibm.com>
# Date 1311161825 -28800
# Node ID 4c47a4b500e86abe2bb6461fdaaf2fe5d2e1d861
# Parent  0c52e4f6c421cc2e168197a82a9333d4ce369655
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.
https://bugzilla.linux.ibm.com/show_bug.cgi?id=71347

diff -r 0c52e4f6c421 -r 4c47a4b500e8 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c	Wed Jul 20 18:03:54 2011 +0800
+++ b/libxkutil/device_parsing.c	Wed Jul 20 19:37:05 2011 +0800
@@ -530,6 +530,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 0c52e4f6c421 -r 4c47a4b500e8 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c	Wed Jul 20 18:03:54 2011 +0800
+++ b/libxkutil/xmlgen.c	Wed Jul 20 19:37:05 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 0c52e4f6c421 -r 4c47a4b500e8 
schema/ResourceAllocationSettingData.mof
--- a/schema/ResourceAllocationSettingData.mof	Wed Jul 20 18:03:54 2011 
+0800
+++ b/schema/ResourceAllocationSettingData.mof	Wed Jul 20 19:37:05 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 0c52e4f6c421 -r 4c47a4b500e8 
src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Wed Jul 20 18:03:54 2011 
+0800
+++ b/src/Virt_VirtualSystemManagementService.c	Wed Jul 20 19:37:05 2011 
+0800
@@ -1059,6 +1059,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)
@@ -1162,6 +1208,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);
@@ -1170,7 +1240,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