[Libvir] virsh vncdisplay fix

John Levon levon at movementarian.org
Tue Jan 15 03:47:58 UTC 2008


I have an old HVM guest defined in 3.0.4, and now I'm running 3.1.2 and
libvirt 0.4.0. The config looks like this:

(domain
 (image
  (hvm
   (vnc 1)
   (vncdisplay 0)
 (device
  (vfb
   (location localhost:5900)
   (vncdisplay 0)
   (uuid ...)

The libvirt code looks like this:

1757     /* Graphics device (HVM <= 3.0.4, or PV <= 3.0.3) vnc config */
1758     if ((hvm && xendConfigVersion < 4) ||
1759         (!hvm && xendConfigVersion < 3)) {
1760         tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux");

So we don't see the 'vnc 1' at the top. But the code to parse device/vfb doesn't
expect this config either:

1685             tmp = sexpr_node(node, "device/vfb/type");

The patch below replaces the later version check with something that
copes correctly with the "upgrade" case.

regards
john

2008-01-15 John Levon <levon at movementarian.org>

        * src/xend_internal.c: fix VNC parsing of old Xen domains on
          newer Xen versions.

diff -prauN libvirt-0.4.0/src/xend_internal.c libvirt-new/src/xend_internal.c
--- libvirt-0.4.0/src/xend_internal.c	2007-12-17 15:05:27.000000000 -0800
+++ libvirt-new/src/xend_internal.c	2008-01-14 18:42:08.895060570 -0800
@@ -1371,6 +1371,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
     unsigned char uuid[VIR_UUID_BUFLEN];
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     int vif_index = 0;
+    int found_graphics = 0;
 
     if (root == NULL) {
         /* ERROR */
@@ -1683,6 +1684,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
             if (tmp && !strcmp(tmp, "sdl")) {
                 virBufferVSprintf(&buf, "    <input type='mouse' bus='%s'/>\n", hvm ? "ps2": "xen");
                 virBufferAdd(&buf, "    <graphics type='sdl'/>\n", 27);
+                found_graphics = 1;
             } else if (tmp && !strcmp(tmp, "vnc")) {
                 int port = xenStoreDomainGetVNCPort(conn, domid);
                 const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten");
@@ -1700,6 +1702,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
                 if (keymap)
                     virBufferVSprintf(&buf, " keymap='%s'", keymap);
                 virBufferAdd(&buf, "/>\n", 3);
+                found_graphics = 1;
             }
         }
     }
@@ -1751,8 +1754,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
     }
 
     /* Graphics device (HVM <= 3.0.4, or PV <= 3.0.3) vnc config */
-    if ((hvm && xendConfigVersion < 4) ||
-        (!hvm && xendConfigVersion < 3)) {
+    if (!found_graphics) {
         tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux");
         if (tmp != NULL) {
             if (tmp[0] == '1') {
@@ -1780,6 +1782,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
                 if (keymap)
                     virBufferVSprintf(&buf, " keymap='%s'", keymap);
                 virBufferAdd(&buf, "/>\n", 3);
+                found_graphics = 1;
             }
         }
 
@@ -1789,6 +1792,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
             if (tmp[0] == '1') {
                 virBufferVSprintf(&buf, "    <input type='mouse' bus='%s'/>\n", hvm ? "ps2" : "xen");
                 virBufferAdd(&buf, "    <graphics type='sdl'/>\n", 27 );
+                found_graphics = 1;
             }
         }
     }




More information about the libvir-list mailing list