From: Ian Jackson Date: Thu, 29 May 2008 14:39:25 +0000 (+0100) Subject: Add vncunused option. X-Git-Tag: xen-3.3.0-rc1~161 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7e90700420eddad9298774fc4d12ed112f0d70f2;p=qemu-xen-4.0-testing.git Add vncunused option. 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 --- diff --git a/console.h b/console.h index 1f5637f6..9e6ddfcf 100644 --- 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); diff --git a/monitor.c b/monitor.c index 809e0f00..ce485593 100644 --- 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 bb06df67..94eb3c89 100644 --- 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)