]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh: fix IP address in vncdisplay for listen type='network'
authorLuyao Huang <lhuang@redhat.com>
Sun, 15 Feb 2015 08:49:09 +0000 (16:49 +0800)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 16 Feb 2015 10:20:43 +0000 (11:20 +0100)
Just like the fix for domdisplay in commit 1ba815.

tools/virsh-domain.c

index dc4a86344683b39afed520e9289bc692a1be75e3..2506b89a6a1154de478c7d5a00d40cbf44fcc6a3 100644 (file)
@@ -10269,6 +10269,18 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
 
     listen_addr = virXPathString("string(/domain/devices/graphics"
                                  "[@type='vnc']/@listen)", ctxt);
+    if (!listen_addr) {
+        /* The subelement address - <listen address='xyz'/> -
+         * *should* have been automatically backfilled into its
+         * parent <graphics listen='xyz'> (which we just tried to
+         * retrieve into listen_addr above) but in some cases it
+         * isn't, so we also do an explicit check for the
+         * subelement (which, by the way, doesn't exist on libvirt
+         * < 0.9.4, so we really do need to check both places)
+         */
+        listen_addr = virXPathString("string(/domain/devices/graphics"
+                                     "[@type='vnc']/listen/@address)", ctxt);
+    }
     if (listen_addr == NULL || STREQ(listen_addr, "0.0.0.0"))
         vshPrint(ctl, ":%d\n", port-5900);
     else