]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
fix VNC port reporting when vncunused is set
authorJohn Levon <john.levon@sun.com>
Thu, 29 Jan 2009 17:02:00 +0000 (17:02 +0000)
committerJohn Levon <john.levon@sun.com>
Thu, 29 Jan 2009 17:02:00 +0000 (17:02 +0000)
ChangeLog
src/util.c
src/xend_internal.c
tests/sexpr2xmltest.c

index cadf3efc4d717c64ea5e4f25d8da3ab5c4d8e75d..3838db93347d1f90e9a7232976c549a9785f57d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Thu Jan 29 16:41:07 GMT 2009 John Levon <john.levon@sun.com>
+
+       * src/util.c: allow strtol replacements for libvirt proxy
+
+       * src/xend_internal.c: fix VNC port reporting when vncunused
+       is set
+
+       * tests/sexpr2xmldata/sexpr2xml-fv-autoport.sexpr:
+       * tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml:
+       * tests/sexpr2xmltest.c: add a test
+
 Thu Jan 29 13:07:05 +0100 2009 Jim Meyering <meyering@redhat.com>
 
        * Makefile.cfg: disable some new checks
index e0499998c8a13f9d7e996acc2307649a6222e50d..aa3ae8666b59aa2f9490409e108395b951c11762 100644 (file)
@@ -1041,6 +1041,7 @@ cleanup:
     return rc;
 }
 
+#endif /* PROXY */
 
 
 /* Like strtol, but produce an "int" result, and check more carefully.
@@ -1123,7 +1124,6 @@ virStrToLong_ull(char const *s, char **end_ptr, int base, unsigned long long *re
     *result = val;
     return 0;
 }
-#endif /* PROXY */
 
 /**
  * virSkipSpaces:
index e7efcc1658ea51152d2a2944c65bea609e91f1a4..48e046afcc838c43dd8716ee1420bd481e3c7587 100644 (file)
@@ -612,7 +612,9 @@ sexpr_get(virConnectPtr xend, const char *fmt, ...)
  *
  * convenience function to lookup an int value in the S-Expression
  *
- * Returns the value found or 0 if not found (but may not be an error)
+ * Returns the value found or 0 if not found (but may not be an error).
+ * This function suffers from the flaw that zero is both a correct
+ * return value and an error indicator: careful!
  */
 static int
 sexpr_int(const struct sexpr *sexpr, const char *name)
@@ -2090,15 +2092,16 @@ xenDaemonParseSxprGraphicsNew(virConnectPtr conn,
                 port = xenStoreDomainGetVNCPort(conn, def->id);
                 xenUnifiedUnlock(priv);
 
+                // Didn't find port entry in xenstore
                 if (port == -1) {
-                    // Didn't find port entry in xenstore
-                    port = sexpr_int(node, "device/vfb/vncdisplay");
+                    const char *str = sexpr_node(node, "device/vfb/vncdisplay");
+                    int val;
+                    if (str != NULL && virStrToLong_i(str, NULL, 0, &val) == 0)
+                        port = val;
                 }
 
-                if ((unused && STREQ(unused, "1")) || port == -1) {
+                if ((unused && STREQ(unused, "1")) || port == -1)
                     graphics->data.vnc.autoport = 1;
-                    port = -1;
-                }
 
                 if (port >= 0 && port < 5900)
                     port += 5900;
index 9033d2015a3c7f20d34d8a63bbacbe1c3b505a27..09cf45a5d4263dc5c6f9bc178bcd00aa957ca74d 100644 (file)
@@ -127,6 +127,7 @@ mymain(int argc, char **argv)
     DO_TEST("pv-vfb-orig", "pv-vfb-orig", 2);
     DO_TEST("pv-vfb-new", "pv-vfb-new", 3);
     DO_TEST("pv-vfb-new-vncdisplay", "pv-vfb-new-vncdisplay", 3);
+    DO_TEST("fv-autoport", "fv-autoport", 3);
     DO_TEST("pv-bootloader", "pv-bootloader", 1);
 
     DO_TEST("disk-file", "disk-file", 2);