[PATCH] Support parsing of new SEXPR for PVFB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The paravirt framebuffer patches for Xen finally got merged into upstream
xen-devel. In doing so, however, the syntax of the SEXPR for configuring
them changed completely. The existing framebuffer suppoirt in libvirt thus
only works with the 3.0.3 tree + PVFB patches. For 3.0.4 we need to work
with the new scheme. Fortunately, in 3.0.4 the xend_config_version flag
is bumped from 2 -> 3, so we have an easy value to hook off. 

The attached patch thus adds support for parsing an SEXPR looking like

    (device
        (vfb
            (vncunused 1)
            (vnclisten 127.0.0.1)
            (vncpasswd 123456)
            (type vnc)
        )
    )

And generating the <graphics type='vnc' port='5903'/>  XML tag to match.

(A later patch will add support for the reverse direction)

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.78
diff -u -r1.78 xend_internal.c
--- src/xend_internal.c	22 Nov 2006 17:48:29 -0000	1.78
+++ src/xend_internal.c	5 Dec 2006 20:47:19 -0000
@@ -1736,6 +1736,19 @@
                                   tmp2);
 
             virBufferAdd(&buf, "    </interface>\n", 17);
+        } else if (!hvm &&
+                   sexpr_lookup(node, "device/vfb")) {
+            /* New style graphics config for PV guests only in 3.0.4 */
+            tmp = sexpr_node(node, "device/vfb/type");
+
+            if (tmp && !strcmp(tmp, "sdl")) {
+                virBufferAdd(&buf, "    <graphics type='sdl'/>\n", 27);
+            } else if (tmp && !strcmp(tmp, "vnc")) {
+                int port = xenStoreDomainGetVNCPort(conn, domid);
+                if (port == -1)
+                    port = 5900 + domid;
+                virBufferVSprintf(&buf, "    <graphics type='vnc' port='%d'/>\n", port);
+            }
         }
     }
 
@@ -1769,21 +1782,26 @@
         }
     }
 
-    /* Graphics device */
-    tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux");
-    if (tmp != NULL) {
-        if (tmp[0] == '1') {
-            int port = xenStoreDomainGetVNCPort(conn, domid);
-            if (port == -1)
-                port = 5900 + domid;
-            virBufferVSprintf(&buf, "    <graphics type='vnc' port='%d'/>\n", port);
+    /* Graphics device (HVM, or old (pre-3.0.4) style PV vnc config) */
+    if (hvm || xendConfigVersion < 3) {
+        tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux");
+        if (tmp != NULL) {
+            if (tmp[0] == '1') {
+                int port = xenStoreDomainGetVNCPort(conn, domid);
+                if (port == -1)
+                    port = 5900 + domid;
+                virBufferVSprintf(&buf, "    <graphics type='vnc' port='%d'/>\n", port);
+            }
         }
     }
 
-    tmp = sexpr_fmt_node(root, "domain/image/%s/sdl", hvm ? "hvm" : "linux");
-    if (tmp != NULL) {
-        if (tmp[0] == '1')
-            virBufferAdd(&buf, "    <graphics type='sdl'/>\n", 27 );
+    /* Graphics device (HVM, or old (pre-3.0.4) style PV sdl config) */
+    if (hvm || xendConfigVersion < 3){
+        tmp = sexpr_fmt_node(root, "domain/image/%s/sdl", hvm ? "hvm" : "linux");
+        if (tmp != NULL) {
+            if (tmp[0] == '1')
+                virBufferAdd(&buf, "    <graphics type='sdl'/>\n", 27 );
+        }
     }
 
     tty = xenStoreDomainGetConsolePath(conn, domid);
Index: tests/sexpr2xmltest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/sexpr2xmltest.c,v
retrieving revision 1.7
diff -u -r1.7 sexpr2xmltest.c
--- tests/sexpr2xmltest.c	15 Nov 2006 00:38:13 -0000	1.7
+++ tests/sexpr2xmltest.c	5 Dec 2006 20:47:19 -0000
@@ -60,6 +60,20 @@
 			  2);
 }
 
+static int testComparePVOrigVFB(void *data ATTRIBUTE_UNUSED) {
+  return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml",
+                          "sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr",
+                          2);
+}   
+
+
+static int testComparePVNewVFB(void *data ATTRIBUTE_UNUSED) {
+  return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-vfb-new.xml",
+                          "sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr",
+                          3);
+}   
+
+
 static int testCompareFVversion2(void *data ATTRIBUTE_UNUSED) {
   return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-v2.xml",
 			  "sexpr2xmldata/sexpr2xml-fv-v2.sexpr",
@@ -133,8 +147,15 @@
     if (virtTestRun("SEXPR-2-XML PV config (version 2)",
 		    1, testComparePVversion2, NULL) != 0)
 	ret = -1;
+    if (virtTestRun("SEXPR-2-XML PV config (Orig VFB)",
+                    1, testComparePVOrigVFB, NULL) != 0)
+        ret = -1;
+
+    if (virtTestRun("SEXPR-2-XML PV config (New VFB)",
+                    1, testComparePVNewVFB, NULL) != 0)
+        ret = -1;
 
-    if (virtTestRun("SEXPR-2-XML FV config  (version 2)",
+    if (virtTestRun("SEXPR-2-XML FV config (version 2)",
 		    1, testCompareFVversion2, NULL) != 0)
 	ret = -1;
 
Index: tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr
===================================================================
RCS file: tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr
diff -N tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr	5 Dec 2006 20:47:19 -0000
@@ -0,0 +1,2 @@
+(domain (domid 6)(name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os  ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w')))(device (vfb (type vnc)(vncunused 1)(vnclisten 0.0.0.0)(vncpasswd 123456)))))
+
Index: tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml
===================================================================
RCS file: tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml
diff -N tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml	5 Dec 2006 20:47:19 -0000
@@ -0,0 +1,23 @@
+<domain type='xen' id='6'>
+  <name>pvtest</name>
+  <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
+  <os>
+    <type>linux</type>
+    <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
+    <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
+    <cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os  </cmdline>
+  </os>
+  <memory>430080</memory>
+  <vcpu>2</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>destroy</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/some.img'/>
+      <target dev='xvda'/>
+    </disk>
+    <graphics type='vnc' port='5906'/>
+  </devices>
+</domain>
Index: tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr
===================================================================
RCS file: tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr
diff -N tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr	5 Dec 2006 20:47:19 -0000
@@ -0,0 +1,2 @@
+(domain (domid 6)(name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os  ')(vnc 1)(vncunused 1)(vnclisten 0.0.0.0)(vncpasswd 123456)))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
+
Index: tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml
===================================================================
RCS file: tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml
diff -N tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml	5 Dec 2006 20:47:19 -0000
@@ -0,0 +1,23 @@
+<domain type='xen' id='6'>
+  <name>pvtest</name>
+  <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
+  <os>
+    <type>linux</type>
+    <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
+    <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
+    <cmdline> method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os  </cmdline>
+  </os>
+  <memory>430080</memory>
+  <vcpu>2</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>destroy</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/some.img'/>
+      <target dev='xvda'/>
+    </disk>
+    <graphics type='vnc' port='5906'/>
+  </devices>
+</domain>

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]