Index: ioemu/xenstore.c
===================================================================
--- ioemu.orig/xenstore.c	2007-05-10 15:19:05.000000000 +0100
+++ ioemu/xenstore.c	2007-05-10 15:19:05.000000000 +0100
@@ -225,6 +225,34 @@
     free(vec);
 }
 
+void xenstore_write_vncport(int display)
+{
+    char *buf = NULL, *path;
+    char *portstr = NULL;
+
+    if (xsh == NULL)
+        return;
+
+    path = xs_get_domain_path(xsh, domid);
+    if (path == NULL) {
+        fprintf(logfile, "xs_get_domain_path() error\n");
+        goto out;
+    }
+
+    if (pasprintf(&buf, "%s/console/vnc-port", path) == -1)
+        goto out;
+
+    if (pasprintf(&portstr, "%d", 5900 + display) == -1)
+        goto out;
+
+    if (xs_write(xsh, XBT_NULL, buf, portstr, strlen(portstr)) == 0)
+        fprintf(logfile, "xs_write() vncport failed\n");
+
+ out:
+    free(portstr);
+    free(buf);
+}
+
 char *xenstore_vm_read(int domid, char *key, int *len)
 {
     char *buf = NULL, *path = NULL, *value = NULL;
Index: ioemu/vl.c
===================================================================
--- ioemu.orig/vl.c	2007-05-10 15:19:05.000000000 +0100
+++ ioemu/vl.c	2007-05-10 15:19:05.000000000 +0100
@@ -7605,6 +7605,7 @@
 	vnc_display_port = vnc_display_init(ds, vnc_display, vncunused);
 	if (vncviewer)
 	    vnc_start_viewer(vnc_display_port);
+	xenstore_write_vncport(vnc_display_port);
     } else {
 #if defined(CONFIG_SDL)
         sdl_display_init(ds, full_screen);
Index: ioemu/vl.h
===================================================================
--- ioemu.orig/vl.h	2007-05-10 15:19:05.000000000 +0100
+++ ioemu/vl.h	2007-05-10 15:19:05.000000000 +0100
@@ -1428,6 +1428,7 @@
 int xenstore_fd(void);
 void xenstore_process_event(void *opaque);
 void xenstore_check_new_media_present(int timeout);
+void xenstore_write_vncport(int vnc_display);
 
 int xenstore_vm_write(int domid, char *key, char *val);
 char *xenstore_vm_read(int domid, char *key, int *len);
