From a82bd0784b1dda58efdca17e0dded8cfe63ad972 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 9 Sep 2008 13:53:58 +0000 Subject: [PATCH] Fix reading vncdisplay from xend, add several test cases for xen vnc corner case s. --- ChangeLog | 13 ++++++++ src/xend_internal.c | 11 ++++++- .../sexpr2xml-pv-vfb-new-vncdisplay.sexpr | 2 ++ .../sexpr2xml-pv-vfb-new-vncdisplay.xml | 29 +++++++++++++++++ tests/sexpr2xmltest.c | 1 + .../test-paravirt-new-pvfb-vncdisplay.cfg | 12 +++++++ .../test-paravirt-new-pvfb-vncdisplay.xml | 32 +++++++++++++++++++ .../test-paravirt-old-pvfb-vncdisplay.cfg | 17 ++++++++++ .../test-paravirt-old-pvfb-vncdisplay.xml | 32 +++++++++++++++++++ tests/xmconfigtest.c | 2 ++ .../xml2sexpr-pv-vfb-new-auto.sexpr | 1 + .../xml2sexpr-pv-vfb-new-auto.xml | 23 +++++++++++++ tests/xml2sexprtest.c | 1 + 13 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.sexpr create mode 100644 tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml create mode 100644 tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.cfg create mode 100644 tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml create mode 100644 tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.cfg create mode 100644 tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.xml create mode 100644 tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.sexpr create mode 100644 tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.xml diff --git a/ChangeLog b/ChangeLog index 276cfd0b2a..f468e0765b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Tue Sep 9 09:50:00 EST 2008 Cole Robinson + + * src/xend_internal.c: fix reading vncdisplay from xend domain + * tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.sexpr + tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml, + tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.cfg, + tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml, + tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.cfg, + tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.xml, + tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.sexpr, + tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.xml: + Add tests for various xen vnc cases. + Tue Sep 9 09:42:00 EST 2008 Cole Robinson * src/qemu_conf.c : fix a segfault if no qemu emulator is passed diff --git a/src/xend_internal.c b/src/xend_internal.c index e9ea09b607..2e1a8d1d47 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -2121,13 +2121,22 @@ xenDaemonParseSxprGraphicsNew(virConnectPtr conn, goto no_memory; } else { int port = xenStoreDomainGetVNCPort(conn, def->id); + if (port == -1) { + // Didn't find port entry in xenstore + port = sexpr_int(node, "device/vfb/vncdisplay"); + } const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten"); const char *vncPasswd = sexpr_node(node, "device/vfb/vncpasswd");; const char *keymap = sexpr_node(node, "device/vfb/keymap"); const char *unused = sexpr_node(node, "device/vfb/vncunused"); - 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; graphics->data.vnc.port = port; if (listenAddr && diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.sexpr b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.sexpr new file mode 100644 index 0000000000..c0fb904c71 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.sexpr @@ -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 0)(vnclisten 0.0.0.0)(vncpasswd 123456)(keymap ja)(vncdisplay 25))))) + diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml new file mode 100644 index 0000000000..40302d0c05 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml @@ -0,0 +1,29 @@ + + pvtest + 596a5d21-71f4-8fb2-e068-e2386a5c413e + 430080 + 430080 + 2 + + linux + /var/lib/xen/vmlinuz.2Dn2YT + /var/lib/xen/initrd.img.0u-Vhq + method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os + + + destroy + destroy + destroy + + + + + + + + + + + + + diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index 27952f6ab3..d36bc72fea 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -106,6 +106,7 @@ mymain(int argc, char **argv) DO_TEST("fv-v2", "fv-v2", 2); 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("pv-bootloader", "pv-bootloader", 1); DO_TEST("disk-file", "disk-file", 2); diff --git a/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.cfg b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.cfg new file mode 100644 index 0000000000..35d5364203 --- /dev/null +++ b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.cfg @@ -0,0 +1,12 @@ +name = "XenGuest1" +uuid = "c7a5fdb0-cdaf-9455-926a-d65c16db1809" +maxmem = 579 +memory = 394 +vcpus = 1 +bootloader = "/usr/bin/pygrub" +on_poweroff = "destroy" +on_reboot = "restart" +on_crash = "restart" +vfb = [ "type=vnc,vncunused=0,vncdisplay=25,vnclisten=127.0.0.1,vncpasswd=123poi" ] +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] +vif = [ "mac=00:16:3e:66:94:9c,bridge=br0" ] diff --git a/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml new file mode 100644 index 0000000000..f4d5bd873c --- /dev/null +++ b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml @@ -0,0 +1,32 @@ + + XenGuest1 + c7a5fdb0-cdaf-9455-926a-d65c16db1809 + 592896 + 403456 + 1 + /usr/bin/pygrub + + linux + + + destroy + restart + restart + + /usr/lib/xen/bin/qemu-dm + + + + + + + + + + + + + + + + diff --git a/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.cfg b/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.cfg new file mode 100644 index 0000000000..9e7000b420 --- /dev/null +++ b/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.cfg @@ -0,0 +1,17 @@ +name = "XenGuest1" +uuid = "c7a5fdb0-cdaf-9455-926a-d65c16db1809" +maxmem = 579 +memory = 394 +vcpus = 1 +bootloader = "/usr/bin/pygrub" +on_poweroff = "destroy" +on_reboot = "restart" +on_crash = "restart" +sdl = 0 +vnc = 1 +vncunused = 0 +vncdisplay = 25 +vnclisten = "127.0.0.1" +vncpasswd = "123poi" +disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ] +vif = [ "mac=00:16:3e:66:94:9c,bridge=br0" ] diff --git a/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.xml b/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.xml new file mode 100644 index 0000000000..f4d5bd873c --- /dev/null +++ b/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.xml @@ -0,0 +1,32 @@ + + XenGuest1 + c7a5fdb0-cdaf-9455-926a-d65c16db1809 + 592896 + 403456 + 1 + /usr/bin/pygrub + + linux + + + destroy + restart + restart + + /usr/lib/xen/bin/qemu-dm + + + + + + + + + + + + + + + + diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 5c2eeb1c59..cf387f7f5a 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -215,7 +215,9 @@ mymain(int argc, char **argv) } while (0) DO_TEST("paravirt-old-pvfb", 2); + DO_TEST("paravirt-old-pvfb-vncdisplay", 2); DO_TEST("paravirt-new-pvfb", 3); + DO_TEST("paravirt-new-pvfb-vncdisplay", 3); DO_TEST("paravirt-net-e1000", 3); DO_TEST("fullvirt-old-cdrom", 1); DO_TEST("fullvirt-new-cdrom", 2); diff --git a/tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.sexpr b/tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.sexpr new file mode 100644 index 0000000000..ecec85ddc8 --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.sexpr @@ -0,0 +1 @@ +(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d21-71f4-8fb2-e068-e2386a5c413e')(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_model '/usr/lib/xen/bin/qemu-dm')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w')))(device (vkbd))(device (vfb (type vnc)(vncunused 1)(vnclisten '127.0.0.1')(vncpasswd '123456')(keymap 'ja')))) \ No newline at end of file diff --git a/tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.xml b/tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.xml new file mode 100644 index 0000000000..c17d9d5ff5 --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-pv-vfb-new-auto.xml @@ -0,0 +1,23 @@ + + pvtest + 596a5d2171f48fb2e068e2386a5c413e + + linux + /var/lib/xen/vmlinuz.2Dn2YT + /var/lib/xen/initrd.img.0u-Vhq + method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os + + 430080 + 2 + destroy + destroy + destroy + + + + + + + + + diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index 3888c8b61e..aee006a7cc 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -111,6 +111,7 @@ mymain(int argc, char **argv) DO_TEST("fv-vncunused", "fv-vncunused", "fvtest", 2); DO_TEST("pv-vfb-orig", "pv-vfb-orig", "pvtest", 2); DO_TEST("pv-vfb-new", "pv-vfb-new", "pvtest", 3); + DO_TEST("pv-vfb-new-auto", "pv-vfb-new-auto", "pvtest", 3); DO_TEST("pv-bootloader", "pv-bootloader", "pvtest", 1); DO_TEST("disk-file", "disk-file", "pvtest", 2);