-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi,
here's a little gimmick for VNC support :-) The patch makes Qemu publish its VNC display via zeroconf if it is called with -vnc option. The patch uses the avahi-publish helper app for this, which comes with the Avahi suite (eg. in Debian and Ubuntu it's in the avahi-utils package). If avahi-publish is not installed, this patch won't do anything. With the patch applied, you can use the service-discovery-applet under Gnome to see all Qemu instances which use VNC. Under KDE, Krdc offers a list of all zeroconf-published VNC displays (choose "DNS-SD" from the listbox in the upper left corner in Krdc). Regards, Oliver -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFEZ0X5TFOM6DcNJ6cRApiCAJ0dSa115JeNvXu9PfND5R+E4TqyeQCgvDlK ROoGXIBo2gVLK104J2uKz1M= =8tDu -----END PGP SIGNATURE-----
--- qemu-0.8.1/vnc.c 2006-05-03 22:32:58.000000000 +0200 +++ qemu-0.8.1-avahi/vnc.c 2006-05-14 16:21:05.000000000 +0200 @@ -64,6 +64,11 @@ size_t read_handler_expect; }; +#ifndef _WIN32 +#include <signal.h> +pid_t mdns_publish_pid = 0; +#endif + /* TODO 1) Get the queue working for IO. 2) there is some weirdness when using the -S option (the screen is grey @@ -852,6 +857,71 @@ } } +#ifndef _WIN32 +static void vnc_unpublish_mdns(void) +{ + if (mdns_publish_pid != 0) + { + kill(mdns_publish_pid, SIGTERM); + } + return; +} +#endif + +/// Publish VNC display via mdns/zeroconf using the Avahi suite. +/// See RFC 2782 and avahi-publish(1) for more info. +void vnc_publish_mdns(int port) +{ +#ifndef _WIN32 + // Execute avahi helper program in a child process. + pid_t childPid = fork(); + switch(childPid) + { + case -1: + // fork() failed; ignore this. + break; + + case 0: + { + // New child process. + char name[250]; + char portString[10]; + char *argv[10]; + int i = 0; + + sprintf(name, "QEMU instance on port %d", port); + sprintf(portString, "%d", port); + + argv[i++] = "avahi-publish"; // avahi-publish is a helper program from Avahi that publishes DNS-SD records. + argv[i++] = "-s"; // Flag: publish a service. + argv[i++] = name; // Name of the service + argv[i++] = "_rfb._tcp"; // Service type (see http://www.dns-sd.org/ServiceTypes.html) + argv[i++] = portString; // TCP port + argv[i++] = NULL; + + // Close stdout/stderr to suppress output from avahi-publish + close(STDOUT_FILENO); + close(STDERR_FILENO); + + // Execute avahi-publish + execvp(argv[0], argv); + + // This point might be reached, eg. if avahi-publish is not installed. + exit(0); + break; + } + + default: + // Parent process. Record child pid and set exit handler. + mdns_publish_pid = childPid; + atexit(vnc_unpublish_mdns); + break; + } +#endif + + return; +} + void vnc_display_init(DisplayState *ds, int display) { struct sockaddr_in addr; @@ -918,4 +988,6 @@ memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); vnc_dpy_resize(vs->ds, 640, 400); + + vnc_publish_mdns(5900 + display); }
_______________________________________________ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel