On Mon, 7 Dec 2009 13:42:49 +0100 Gerd Hoffmann <kra...@redhat.com> wrote:
> +static int mon_init_func(QemuOpts *opts, void *opaque) > +{ > + CharDriverState *chr; > + const char *chardev; > + const char *mode; > + int flags; > + > + qemu_opts_print(opts, NULL); > + > + mode = qemu_opt_get(opts, "mode"); > + if (mode == NULL) { > + mode = "readline"; > + } > + if (strcmp(mode, "readline") == 0) { > + flags = MONITOR_USE_READLINE; > + } else if (strcmp(mode, "control") == 0) { > + flags = MONITOR_USE_CONTROL; > + } else { > + fprintf(stderr, "unknown monitor mode \"%s\"\n", mode); > + exit(1); > + } > + > + if (qemu_opt_get_bool(opts, "default", 0)) > + flags |= MONITOR_IS_DEFAULT; > + > + chardev = qemu_opt_get(opts, "chardev"); > + chr = qemu_chr_find(chardev); > + if (chardev == NULL) { > + fprintf(stderr, "chardev \"%s\" not found\n", chardev); > + exit(1); > + } We should check for NULL before calling qemu_chr_find(). Also, I'm getting a segfault when running QEMU w/o any monitor cmd-line, like: $ qemu -hda disks/fedora-11-kratos-i386.img -m 1G The reason for the segfault is that the chardev 'monitor' is not found, so qemu_chr_find() returns NULL, passing it down to: > + > + monitor_init(chr, flags); > + return 0; > +} > + Apart from that, monitor changes seem ok to me.