Index: ioemu/vnc.c
===================================================================
--- ioemu.orig/vnc.c	2007-05-03 19:49:43.000000000 +0100
+++ ioemu/vnc.c	2007-05-03 19:49:46.000000000 +0100
@@ -1364,3 +1364,31 @@
 	exit(1);
     }
 }
+
+int vnc_start_viewer(int port)
+{
+    int pid, i, open_max;
+    char s[16];
+
+    sprintf(s, ":%d", port);
+
+    switch (pid = fork()) {
+    case -1:
+	fprintf(stderr, "vncviewer failed fork\n");
+	exit(1);
+
+    case 0:	/* child */
+	open_max = sysconf(_SC_OPEN_MAX);
+	for (i = 0; i < open_max; i++)
+	    if (i != STDIN_FILENO &&
+		i != STDOUT_FILENO &&
+		i != STDERR_FILENO)
+		close(i);
+	execlp("vncviewer", "vncviewer", s, NULL);
+	fprintf(stderr, "vncviewer execlp failed\n");
+	exit(1);
+
+    default:
+	return pid;
+    }
+}
Index: ioemu/vl.c
===================================================================
--- ioemu.orig/vl.c	2007-05-03 19:46:21.000000000 +0100
+++ ioemu/vl.c	2007-05-03 19:50:04.000000000 +0100
@@ -131,6 +131,7 @@
 int bios_size;
 static DisplayState display_state;
 int nographic;
+int vncviewer;
 const char* keyboard_layout = NULL;
 int64_t ticks_per_sec;
 int boot_device = 'c';
@@ -6309,6 +6310,7 @@
            "-no-reboot      exit instead of rebooting\n"
            "-loadvm file    start right away with a saved state (loadvm in monitor)\n"
 	   "-vnc display    start a VNC server on display\n"
+           "-vncviewer      start a vncviewer process for this domain\n"
 #ifndef _WIN32
 	   "-daemonize      daemonize QEMU after initializing\n"
 #endif
@@ -6404,6 +6406,7 @@
     QEMU_OPTION_d,
     QEMU_OPTION_vcpus,
     QEMU_OPTION_acpi,
+    QEMU_OPTION_vncviewer,
 };
 
 typedef struct QEMUOption {
@@ -6482,6 +6485,7 @@
     { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
     { "smp", HAS_ARG, QEMU_OPTION_smp },
     { "vnc", HAS_ARG, QEMU_OPTION_vnc },
+    { "vncviewer", 0, QEMU_OPTION_vncviewer },
 
     /* temporary options */
     { "usb", 0, QEMU_OPTION_usb },
@@ -6848,6 +6852,7 @@
 #endif
     snapshot = 0;
     nographic = 0;
+    vncviewer = 0;
     kernel_filename = NULL;
     kernel_cmdline = "";
 #ifdef TARGET_PPC
@@ -7264,6 +7269,9 @@
             case QEMU_OPTION_acpi:
                 acpi_enabled = 1;
                 break;
+            case QEMU_OPTION_vncviewer:
+                vncviewer++;
+                break;
             }
         }
     }
@@ -7547,6 +7555,8 @@
         dumb_display_init(ds);
     } else if (vnc_display != NULL) {
 	vnc_display_init(ds, vnc_display);
+	if (vncviewer)
+	    vnc_start_viewer(vnc_display);
     } else {
 #if defined(CONFIG_SDL)
         sdl_display_init(ds, full_screen);
Index: ioemu/vl.h
===================================================================
--- ioemu.orig/vl.h	2007-05-03 19:46:21.000000000 +0100
+++ ioemu/vl.h	2007-05-03 19:50:15.000000000 +0100
@@ -930,6 +930,7 @@
 /* vnc.c */
 void vnc_display_init(DisplayState *ds, const char *display);
 void do_info_vnc(void);
+int vnc_start_viewer(int port);
 
 /* x_keymap.c */
 extern uint8_t _translate_keycode(const int key);
