]> xenbits.xensource.com Git - qemu-xen-4.1-testing.git/commitdiff
Add vncunused option.
authorIan Jackson <iwj@mariner.uk.xensource.com>
Thu, 29 May 2008 14:39:25 +0000 (15:39 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 29 May 2008 14:39:25 +0000 (15:39 +0100)
Remaining fragments of xen-unstable c/s
10998:bd04004865ba70a67fb797733ad1452d6b19b971

    If the port used for the requested display number is in use, try
    additional ports until a free port is found.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
console.h
monitor.c
vl.c

index 1f5637f6388f72e8464b62f3f22a717d3da0a07f..9e6ddfcf86775dbe55f68a48b6b39b70785717a2 100644 (file)
--- a/console.h
+++ b/console.h
@@ -124,7 +124,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen);
 /* vnc.c */
 void vnc_display_init(DisplayState *ds);
 void vnc_display_close(DisplayState *ds);
-int vnc_display_open(DisplayState *ds, const char *display);
+int vnc_display_open(DisplayState *ds, const char *display, int find_unused);
 int vnc_display_password(DisplayState *ds, const char *password);
 void do_info_vnc(void);
 
index 809e0f003e902799c1747bcff9ad76e05990a3d6..ce4855935710dd4c77140ca54e98a95b96c69eba 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -430,7 +430,7 @@ static void do_change_vnc(const char *target)
        if (vnc_display_password(NULL, password) < 0)
            term_printf("could not set VNC server password\n");
     } else {
-       if (vnc_display_open(NULL, target) < 0)
+       if (vnc_display_open(NULL, target, 0) < 0)
            term_printf("could not start VNC server on %s\n", target);
     }
 }
diff --git a/vl.c b/vl.c
index bb06df67a4eaae2448e11005277e6b183d85643f..94eb3c89b18ce32d93d0379bb2a0bafab2cf4b9e 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -207,6 +207,7 @@ int usb_enabled = 0;
 static VLANState *first_vlan;
 int smp_cpus = 1;
 const char *vnc_display;
+int vncunused;
 #if defined(TARGET_SPARC)
 #define MAX_CPUS 16
 #elif defined(TARGET_I386)
@@ -5598,6 +5599,11 @@ int qemu_set_fd_handler2(int fd,
             if (ioh->fd == fd) {
                 ioh->deleted = 1;
                 break;
+            case QEMU_OPTION_vncunused:
+                vncunused++;
+                if (vnc_display == -1)
+                    vnc_display = -2;
+                break;
             }
             pioh = &ioh->next;
         }
@@ -7301,6 +7307,7 @@ static void help(int exitcode)
            "-no-shutdown    stop before shutdown\n"
            "-loadvm [tag|id]  start right away with a saved state (loadvm in monitor)\n"
           "-vnc display    start a VNC server on display\n"
+           "-vncunused      bind the VNC server to an unused port\n"
 #ifndef _WIN32
           "-daemonize      daemonize QEMU after initializing\n"
 #endif
@@ -7402,6 +7409,7 @@ enum {
     QEMU_OPTION_usbdevice,
     QEMU_OPTION_smp,
     QEMU_OPTION_vnc,
+    QEMU_OPTION_vncunused,
     QEMU_OPTION_no_acpi,
     QEMU_OPTION_curses,
     QEMU_OPTION_no_reboot,
@@ -7501,6 +7509,7 @@ const QEMUOption qemu_options[] = {
     { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
     { "smp", HAS_ARG, QEMU_OPTION_smp },
     { "vnc", HAS_ARG, QEMU_OPTION_vnc },
+    { "vncunused", 0, QEMU_OPTION_vncunused },
 #ifdef CONFIG_CURSES
     { "curses", 0, QEMU_OPTION_curses },
 #endif
@@ -8576,7 +8585,8 @@ int main(int argc, char **argv)
         dumb_display_init(ds);
     } else if (vnc_display != NULL) {
         vnc_display_init(ds);
-        if (vnc_display_open(ds, vnc_display) < 0)
+        vnc_display = vnc_display_open(ds, vnc_display, vncunused);
+        if (vnc_display < 0)
             exit(1);
     } else
 #if defined(CONFIG_CURSES)