Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NBWpW-0005DP-Kv for qemu-devel@nongnu.org; Fri, 20 Nov 2009 11:59:31 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NBWpR-0005A1-6f for qemu-devel@nongnu.org; Fri, 20 Nov 2009 11:59:29 -0500 Received: from [199.232.76.173] (port=54223 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBWpQ-00059j-Uc for qemu-devel@nongnu.org; Fri, 20 Nov 2009 11:59:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56769) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NBWpQ-0008Iw-BO for qemu-devel@nongnu.org; Fri, 20 Nov 2009 11:59:24 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAKGxM5j021827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 20 Nov 2009 11:59:23 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 4/9] default devices: monitor References: <1258450699-24445-1-git-send-email-kraxel@redhat.com> <1258450699-24445-5-git-send-email-kraxel@redhat.com> Date: Fri, 20 Nov 2009 17:59:20 +0100 In-Reply-To: <1258450699-24445-5-git-send-email-kraxel@redhat.com> (Gerd Hoffmann's message of "Tue, 17 Nov 2009 10:38:14 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Gerd Hoffmann writes: > Switch over monitor to the new defaults system. Even terser. > > Signed-off-by: Gerd Hoffmann > --- > vl.c | 90 +++++++++++++++++++++++++++++++++-------------------------------- > 1 files changed, 46 insertions(+), 44 deletions(-) > > diff --git a/vl.c b/vl.c > index 739c3a7..4edc4a3 100644 > --- a/vl.c > +++ b/vl.c > @@ -210,6 +210,7 @@ int no_quit = 0; > CharDriverState *serial_hds[MAX_SERIAL_PORTS]; > CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; > CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; > +CharDriverState *monitor_hds[MAX_MONITOR_DEVICES]; > #ifdef TARGET_I386 > int win2k_install_hack = 0; > int rtc_td_hack = 0; > @@ -272,6 +273,7 @@ static void *boot_set_opaque; > > static int default_serial = 1; > static int default_parallel = 1; > +static int default_monitor = 1; > > static struct { > const char *driver; > @@ -4571,6 +4573,7 @@ struct device_config { > DEV_BT, /* -bt */ > DEV_SERIAL, /* -serial */ > DEV_PARALLEL, /* -parallel */ > + DEV_MONITOR, /* -monitor */ > } type; > const char *cmdline; > QTAILQ_ENTRY(device_config) next; > @@ -4602,22 +4605,27 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline)) > return 0; > } > > -static void serial_monitor_mux(const char *monitor_devices[]) > +static void serial_monitor_mux(void) > { > - struct device_config *serial; > + struct device_config *mon0, *serial; > const char *devname; > > - if (strcmp(monitor_devices[0],"stdio") != 0) > - return; > + QTAILQ_FOREACH(mon0, &device_configs, next) { > + if (mon0->type != DEV_MONITOR) > + continue; > + if (strcmp(mon0->cmdline,"stdio") != 0) > + return; > + break; > + } > QTAILQ_FOREACH(serial, &device_configs, next) { > if (serial->type != DEV_SERIAL) > continue; > devname = serial->cmdline; > if (devname && !strcmp(devname,"mon:stdio")) { > - monitor_devices[0] = NULL; > + QTAILQ_REMOVE(&device_configs, mon0, next); > break; > } else if (devname && !strcmp(devname,"stdio")) { > - monitor_devices[0] = NULL; > + QTAILQ_REMOVE(&device_configs, mon0, next); > serial->cmdline = "mon:stdio"; > break; > } > @@ -4668,6 +4676,28 @@ static int parallel_parse(const char *devname) > return 0; > } > > +static int monitor_parse(const char *devname) > +{ > + static int index = 0; > + char label[32]; > + > + if (strcmp(devname, "none") == 0) > + return 0; > + if (index == 0) { > + snprintf(label, sizeof(label), "monitor"); > + } else { > + snprintf(label, sizeof(label), "monitor%d", index); > + } > + monitor_hds[index] = qemu_chr_open(label, devname, NULL); Like for serial_parse(): don't you have to catch index >= MAX_MONITOR_DEVICES here? > + if (!monitor_hds[index]) { > + fprintf(stderr, "qemu: could not open monitor device '%s'\n", > + devname); > + return -1; > + } > + index++; > + return 0; > +} > + > int main(int argc, char **argv, char **envp) > { > const char *gdbstub_dev = NULL; [...]