fix VNC port reporting when vncunused is set

This commit is contained in:
John Levon 2009-01-29 17:02:00 +00:00
parent a9f8c8f5f1
commit 3463c34e33
4 changed files with 22 additions and 7 deletions

View File

@ -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> Thu Jan 29 13:07:05 +0100 2009 Jim Meyering <meyering@redhat.com>
* Makefile.cfg: disable some new checks * Makefile.cfg: disable some new checks

View File

@ -1041,6 +1041,7 @@ cleanup:
return rc; return rc;
} }
#endif /* PROXY */
/* Like strtol, but produce an "int" result, and check more carefully. /* 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; *result = val;
return 0; return 0;
} }
#endif /* PROXY */
/** /**
* virSkipSpaces: * virSkipSpaces:

View File

@ -612,7 +612,9 @@ sexpr_get(virConnectPtr xend, const char *fmt, ...)
* *
* convenience function to lookup an int value in the S-Expression * 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 static int
sexpr_int(const struct sexpr *sexpr, const char *name) sexpr_int(const struct sexpr *sexpr, const char *name)
@ -2090,15 +2092,16 @@ xenDaemonParseSxprGraphicsNew(virConnectPtr conn,
port = xenStoreDomainGetVNCPort(conn, def->id); port = xenStoreDomainGetVNCPort(conn, def->id);
xenUnifiedUnlock(priv); xenUnifiedUnlock(priv);
// Didn't find port entry in xenstore
if (port == -1) { if (port == -1) {
// Didn't find port entry in xenstore const char *str = sexpr_node(node, "device/vfb/vncdisplay");
port = sexpr_int(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; graphics->data.vnc.autoport = 1;
port = -1;
}
if (port >= 0 && port < 5900) if (port >= 0 && port < 5900)
port += 5900; port += 5900;

View File

@ -127,6 +127,7 @@ mymain(int argc, char **argv)
DO_TEST("pv-vfb-orig", "pv-vfb-orig", 2); DO_TEST("pv-vfb-orig", "pv-vfb-orig", 2);
DO_TEST("pv-vfb-new", "pv-vfb-new", 3); DO_TEST("pv-vfb-new", "pv-vfb-new", 3);
DO_TEST("pv-vfb-new-vncdisplay", "pv-vfb-new-vncdisplay", 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("pv-bootloader", "pv-bootloader", 1);
DO_TEST("disk-file", "disk-file", 2); DO_TEST("disk-file", "disk-file", 2);