]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fixed handling of -nographics. Added VNC listen support
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 24 Jul 2007 14:30:05 +0000 (14:30 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 24 Jul 2007 14:30:05 +0000 (14:30 +0000)
20 files changed:
ChangeLog
src/qemu_conf.c
src/qemu_conf.h
tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args
tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args
tests/qemuxml2argvdata/qemuxml2argv-boot-network.args
tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args
tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args
tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args
tests/qemuxml2argvdata/qemuxml2argv-disk-many.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args
tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args
tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args
tests/qemuxml2argvdata/qemuxml2argv-minimal.args
tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args
tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args
tests/qemuxml2argvdata/qemuxml2argv-net-user.args
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c

index 40cdb705dad6324e9db5f955889474e0696619b8..c0226c3a9a6534c4cbceaeb773e6ea4feeefc496 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Tue Jul 24 10:29:11 EST 2007 Daniel P. Berrange <berrange@redhat.com>
+
+       * src/qemu_conf.c, src/qemu_conf.h: Added support for the VNC
+       'listen' parameter in XML. Move -nographics flag to start of
+       command line to avoid issues with QEMU default monitor settings.
+       * tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Re-enable
+       VNC & SDL tests now they are working correctly
+       * tests/qemudxml2argvdata/*.args: Move -nographics arg to new
+       location due to qemu_conf.c changes
+
 Tue Jul 24 10:24:11 EST 2007 Daniel P. Berrange <berrange@redhat.com>
 
        * src/qemu_driver.c: Fixed crash when cleaning up after failed
index 4c4d2c2b9bba76de605a1f2b1f172c82782924da..6a112daebf824672f8f644ee43a9cc470b6db6e4 100644 (file)
@@ -1197,14 +1197,23 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
         def->graphicsType = QEMUD_GRAPHICS_NONE;
     } else if ((prop = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "type"))) {
         if (!strcmp((char *)prop, "vnc")) {
+            xmlChar *vncport, *vnclisten;
             def->graphicsType = QEMUD_GRAPHICS_VNC;
-            prop = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "port");
-            if (prop) {
+            vncport = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "port");
+            if (vncport) {
                 conv = NULL;
-                def->vncPort = strtoll((const char*)prop, &conv, 10);
+                def->vncPort = strtoll((const char*)vncport, &conv, 10);
             } else {
                 def->vncPort = -1;
             }
+            vnclisten = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "listen");
+            if (vnclisten && *vnclisten)
+                strncpy(def->vncListen, (char *)vnclisten, BR_INET_ADDR_MAXLEN-1);
+            else
+                strcpy(def->vncListen, "127.0.0.1");
+            def->vncListen[BR_INET_ADDR_MAXLEN-1] = '\0';
+            xmlFree(vncport);
+            xmlFree(vnclisten);
         } else if (!strcmp((char *)prop, "sdl")) {
             def->graphicsType = QEMUD_GRAPHICS_SDL;
         } else {
@@ -1511,6 +1520,18 @@ int qemudBuildCommandLine(virConnectPtr conn,
     if (!((*argv)[++n] = strdup(vcpus)))
         goto no_memory;
 
+    /*
+     * NB, -nographic *MUST* come before any serial, or monitor
+     * or parallel port flags due to QEMU craziness, where it
+     * decides to change the serial port & monitor to be on stdout
+     * if you ask for nographic. So we have to make sure we override
+     * these defaults ourselves...
+     */
+    if (vm->def->graphicsType == QEMUD_GRAPHICS_NONE) {
+        if (!((*argv)[++n] = strdup("-nographic")))
+            goto no_memory;
+    }
+
     if (!((*argv)[++n] = strdup("-monitor")))
         goto no_memory;
     if (!((*argv)[++n] = strdup("pty")))
@@ -1700,22 +1721,24 @@ int qemudBuildCommandLine(virConnectPtr conn,
     }
 
     if (vm->def->graphicsType == QEMUD_GRAPHICS_VNC) {
-        char port[10];
+        char vncdisplay[BR_INET_ADDR_MAXLEN+20];
         int ret;
-        ret = snprintf(port, sizeof(port),
-                       ((driver->qemuCmdFlags & QEMUD_CMD_FLAG_VNC_COLON) ?
-                        ":%d" : "%d"),
-                       vm->def->vncActivePort - 5900);
-        if (ret < 0 || ret >= (int)sizeof(port))
+        if (driver->qemuCmdFlags & QEMUD_CMD_FLAG_VNC_COLON)
+            ret = snprintf(vncdisplay, sizeof(vncdisplay), "%s:%d",
+                           vm->def->vncListen,
+                           vm->def->vncActivePort - 5900);
+        else
+            ret = snprintf(vncdisplay, sizeof(vncdisplay), "%d",
+                           vm->def->vncActivePort - 5900);
+        if (ret < 0 || ret >= (int)sizeof(vncdisplay))
             goto error;
 
         if (!((*argv)[++n] = strdup("-vnc")))
             goto no_memory;
-        if (!((*argv)[++n] = strdup(port)))
+        if (!((*argv)[++n] = strdup(vncdisplay)))
             goto no_memory;
     } else if (vm->def->graphicsType == QEMUD_GRAPHICS_NONE) {
-        if (!((*argv)[++n] = strdup("-nographic")))
-            goto no_memory;
+        /* Nada - we added -nographic earlier in this function */
     } else {
         /* SDL is the default. no args needed */
     }
@@ -2931,6 +2954,11 @@ char *qemudGenerateXML(virConnectPtr conn,
                               qemudIsActiveVM(vm) && live ? def->vncActivePort : def->vncPort) < 0)
             goto no_memory;
 
+        if (def->vncListen[0] &&
+            virBufferVSprintf(buf, " listen='%s'",
+                              def->vncListen) < 0)
+            goto no_memory;
+
         if (virBufferAdd(buf, "/>\n", -1) < 0)
             goto no_memory;
         break;
index 3beb9aa433053f0e7958d7d8c5c8d615951f8aa1..ed7aba243c3c7b06fd8246ace831b569f2b56b39 100644 (file)
@@ -186,6 +186,7 @@ struct qemud_vm_def {
     int graphicsType;
     int vncPort;
     int vncActivePort;
+    char vncListen[BR_INET_ADDR_MAXLEN];
 
     int ndisks;
     struct qemud_vm_disk_def *disks;
index ed6a8655dc8af0c2179fc236af3fe251fc046f6a..cf4a92815b2c7731f61364b3a96ef4b1c87a8f86 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot d -cdrom /dev/cdrom -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot d -cdrom /dev/cdrom -net none -usb
\ No newline at end of file
index 5e387ff80527b2a541a48d42f6d7d79afba38692..70d96dee84c0de15425cf45d73270153d3cad4cd 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot a -hda /dev/HostVG/QEMUGuest1 -fda /tmp/firmware.img -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot a -hda /dev/HostVG/QEMUGuest1 -fda /tmp/firmware.img -net none -usb
\ No newline at end of file
index e1d285ac3afb0c4b08907c7cd228ab095558f32c..991f2f991739a8b6609b16c7208aecc610d70c1a 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot n -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot n -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file
index 555ce3540013574fc4a6cde071f47466550ebec1..c7ef740256a561dd5f1f87764bfd56e2b4a7069d 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -localtime -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -localtime -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file
index dc8e52b0209bdd281f7bde62650c81967e2a688c..08b55b8846410eee801328669a833b21759e01a1 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file
index 298cea8cd6c1e92e6c2a950ec6d23ef9243b4131..86964c1a07721dc74cef4d674433e897e030344c 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso -net none -usb
\ No newline at end of file
index f6dad3da00aea7fb6997ab981c45f1ee78b520a0..87c579c294430e905761efc14ccf395a4e5c0be2 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -fda /dev/fd0 -fdb /tmp/firmware.img -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -fda /dev/fd0 -fdb /tmp/firmware.img -net none -usb
\ No newline at end of file
index a6a957c4e20a208a55207a529b6d07b773484080..0534d6195ee15c8a591c838299dfa8faa851b5d8 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -hdb /dev/HostVG/QEMUGuest2 -hdc /tmp/data.img -hdd /tmp/logs.img -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -hdb /dev/HostVG/QEMUGuest2 -hdc /tmp/data.img -hdd /tmp/logs.img -net none -usb
\ No newline at end of file
index 50016c4f07cc69a4385e9ea6b2f446995d9d5ea2..6163ba6dc2e6f544b515808cb0c5c0309260ef61 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -sdl
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file
index 60b8bbedbc0e18fd5cd7d15973be1c510b688a37..0e27138ce1e39c53b7509b9a290f2b7771142df2 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice mouse -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice mouse
\ No newline at end of file
index 5f6f02cfb38e2e7a6afc0eeb389dffe66c81a6ef..2c9652b20d8cbab8fbab4b72cc99dc257962c770 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice tablet -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice tablet
\ No newline at end of file
index dc8e52b0209bdd281f7bde62650c81967e2a688c..08b55b8846410eee801328669a833b21759e01a1 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file
index 600478c0086fce8897916a8527e7a543d9fba16c..b4e8f6804cf9055e9b4bf84052ae5041f453931b 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file
index 90ade68b7265e9800a0b8b72254852c3b60176d1..0135d5e6c4e1d58988925e3d903f8a25eee552d0 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-reboot -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-reboot -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file
index bf49035d64e3c2dde7beecfbe5b945ee90d70a9d..5c218610ed01dd86b47c9bfe46a949acc631a77e 100644 (file)
@@ -1 +1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -usb -nographic
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -usb
\ No newline at end of file
index 0cb2238e6ac7423525a53bc04659ebbaab7bf3e4..6e77a21c5d512b103a3b09673c00fc0299fa1b6d 100644 (file)
@@ -146,11 +146,11 @@ main(int argc, char **argv)
                     1, testCompareXMLToArgvHelper, "disk-many") < 0)
         ret = -1;
 
-    if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC",
+    if (virtTestRun("QEMU XML-2-ARGV Graphics VNC",
                     1, testCompareXMLToArgvHelper, "graphics-vnc") < 0)
         ret = -1;
 
-    if (0 && virtTestRun("QEMU XML-2-ARGV Graphics SDL",
+    if (virtTestRun("QEMU XML-2-ARGV Graphics SDL",
                     1, testCompareXMLToArgvHelper, "graphics-sdl") < 0)
         ret = -1;
 
index fc596b334732d38c5648c18319f49060c6b45213..0895d84fe45cf0b01a4b7e75ff1b5635d2259bc5 100644 (file)
@@ -111,7 +111,7 @@ main(int argc, char **argv)
                     1, testCompareXMLToXMLHelper, "disk-many") < 0)
         ret = -1;
 
-    if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC",
+    if (virtTestRun("QEMU XML-2-ARGV Graphics VNC",
                     1, testCompareXMLToXMLHelper, "graphics-vnc") < 0)
         ret = -1;