Index: ioemu/vnc.c
===================================================================
--- ioemu.orig/vnc.c	2006-09-21 19:26:38.000000000 +0100
+++ ioemu/vnc.c	2006-09-21 19:29:58.000000000 +0100
@@ -1174,3 +1174,25 @@
 
     vnc_dpy_resize(vs->ds, 640, 400);
 }
+
+int vnc_start_viewer(int port)
+{
+    int pid;
+    char s[16];
+
+    sprintf(s, ":%d", port);
+
+    switch (pid = fork()) {
+    case -1:
+	fprintf(stderr, "vncviewer failed fork\n");
+	exit(1);
+
+    case 0:	/* child */
+	execlp("vncviewer", "vncviewer", s, NULL);
+	fprintf(stderr, "vncviewer execlp failed\n");
+	exit(1);
+
+    default:
+	return pid;
+    }
+}
Index: ioemu/vl.c
===================================================================
--- ioemu.orig/vl.c	2006-09-21 19:26:24.000000000 +0100
+++ ioemu/vl.c	2006-09-21 19:29:50.000000000 +0100
@@ -120,6 +120,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';
@@ -5340,6 +5341,7 @@
 #endif
            "-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"
            "-timeoffset     time offset (in seconds) from local time\n"
            "-acpi           disable or enable ACPI of HVM domain \n"
            "\n"
@@ -5428,6 +5430,7 @@
     QEMU_OPTION_vcpus,
     QEMU_OPTION_timeoffset,
     QEMU_OPTION_acpi,
+    QEMU_OPTION_vncviewer,
 };
 
 typedef struct QEMUOption {
@@ -5502,6 +5505,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 },
@@ -5868,6 +5872,7 @@
 #endif
     snapshot = 0;
     nographic = 0;
+    vncviewer = 0;
     kernel_filename = NULL;
     kernel_cmdline = "";
 #ifdef TARGET_PPC
@@ -6262,6 +6267,9 @@
             case QEMU_OPTION_acpi:
                 acpi_enabled = 1;
                 break;
+            case QEMU_OPTION_vncviewer:
+                vncviewer++;
+                break;
             }
         }
     }
@@ -6476,6 +6484,8 @@
         dumb_display_init(ds);
     } else if (vnc_display != -1) {
 	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	2006-09-21 19:26:24.000000000 +0100
+++ ioemu/vl.h	2006-09-21 19:29:50.000000000 +0100
@@ -786,6 +786,7 @@
 
 /* vnc.c */
 void vnc_display_init(DisplayState *ds, int display);
+int vnc_start_viewer(int port);
 
 /* ide.c */
 #define MAX_DISKS 4
