This patch extends the QEMU monitor 'change' command so that it can be used to change the configuration of the VNC server. On the command line the user can use -vnc none, and then issue the 'change vnc :1' command later from the monitor. This is utilized in the next patch to let the monitor fetch a password for the server. The concept could also be extended to serial & parallel devices allowing changing of their configuration on the fly.
diff -r e85f07144b6c monitor.c --- a/monitor.c Tue Jul 31 10:53:15 2007 -0400 +++ b/monitor.c Tue Jul 31 10:55:31 2007 -0400 @@ -386,7 +386,7 @@ static void do_eject(int force, const ch eject_device(bs, force); } -static void do_change(const char *device, const char *filename) +static void do_change_block(const char *device, const char *filename) { BlockDriverState *bs; @@ -399,6 +399,21 @@ static void do_change(const char *device return; bdrv_open(bs, filename, 0); qemu_key_check(bs, filename); +} + +static void do_change_vnc(const char *target) +{ + if (vnc_display_open(NULL, target) < 0) + term_printf("could not start VNC server on %s\n", target); +} + +static void do_change(const char *device, const char *target) +{ + if (strcmp(device, "vnc") == 0) { + do_change_vnc(target); + } else { + do_change_block(device, target); + } } static void do_screen_dump(const char *filename) diff -r e85f07144b6c vnc.c --- a/vnc.c Tue Jul 31 10:53:15 2007 -0400 +++ b/vnc.c Tue Jul 31 10:55:06 2007 -0400 @@ -1208,7 +1208,7 @@ void vnc_display_init(DisplayState *ds) void vnc_display_close(DisplayState *ds) { - VncState *vs = (VncState *)ds->opaque; + VncState *vs = ds ? (VncState *)ds->opaque : vnc_state; if (vs->display) { qemu_free(vs->display); @@ -1230,7 +1230,7 @@ int vnc_display_open(DisplayState *ds, c int reuse_addr, ret; socklen_t addrlen; const char *p; - VncState *vs = (VncState *)ds->opaque; + VncState *vs = ds ? (VncState *)ds->opaque : vnc_state; vnc_display_close(ds); if (strcmp(arg, "none") == 0) -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|