From patchwork Thu Aug 27 17:51:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 32276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 99ED9B7F88 for ; Fri, 28 Aug 2009 03:56:06 +1000 (EST) Received: from localhost ([127.0.0.1]:41368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgjCc-0007Py-92 for incoming@patchwork.ozlabs.org; Thu, 27 Aug 2009 13:56:02 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mgj8A-0003be-L3 for qemu-devel@nongnu.org; Thu, 27 Aug 2009 13:51:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mgj85-0003X7-Bz for qemu-devel@nongnu.org; Thu, 27 Aug 2009 13:51:25 -0400 Received: from [199.232.76.173] (port=43370 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mgj84-0003Wr-Rb for qemu-devel@nongnu.org; Thu, 27 Aug 2009 13:51:20 -0400 Received: from thoth.sbs.de ([192.35.17.2]:24602) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mgj84-0007yO-07 for qemu-devel@nongnu.org; Thu, 27 Aug 2009 13:51:20 -0400 Received: from mail3.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n7RHpI7B031017; Thu, 27 Aug 2009 19:51:18 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id n7RHpGCV031334; Thu, 27 Aug 2009 19:51:18 +0200 Message-ID: <4A96C794.9030403@siemens.com> Date: Thu, 27 Aug 2009 19:51:16 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Anthony Liguori X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: qemu-devel Subject: [Qemu-devel] [PATCH] Support for multiple -monitor devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Rebased version of Anthony's patch: Allow to specify more than one monitor terminal via the -monitor command line switch. This is particularly useful when libvirt or some other management tool already occupies the primary monitor but you need another one for debugging. The current clumsy workaround is to multiplex such additional terminals over a qemu character device (e.g. -serial mon:). Signed-off-by: Jan Kiszka --- vl.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 46 insertions(+), 16 deletions(-) diff --git a/vl.c b/vl.c index 8b2b289..40d08e6 100644 --- a/vl.c +++ b/vl.c @@ -173,6 +173,9 @@ int main(int argc, char **argv) #define DEFAULT_RAM_SIZE 128 +/* Maximum number of monitor devices */ +#define MAX_MONITOR_DEVICES 10 + static const char *data_dir; const char *bios_name = NULL; /* Note: drives_table[MAX_DRIVES] is a dummy block driver if none available @@ -4789,8 +4792,9 @@ int main(int argc, char **argv, char **envp) QemuOpts *hda_opts = NULL, *opts; int optind; const char *r, *optarg; - CharDriverState *monitor_hd = NULL; - const char *monitor_device; + CharDriverState *monitor_hds[MAX_MONITOR_DEVICES]; + const char *monitor_devices[MAX_MONITOR_DEVICES]; + int monitor_device_index; const char *serial_devices[MAX_SERIAL_PORTS]; int serial_device_index; const char *parallel_devices[MAX_PARALLEL_PORTS]; @@ -4858,7 +4862,6 @@ int main(int argc, char **argv, char **envp) kernel_cmdline = ""; cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; - monitor_device = "vc:80Cx24C"; serial_devices[0] = "vc:80Cx24C"; for(i = 1; i < MAX_SERIAL_PORTS; i++) @@ -4874,6 +4877,12 @@ int main(int argc, char **argv, char **envp) virtio_consoles[i] = NULL; virtio_console_index = 0; + monitor_devices[0] = "vc:80Cx24C"; + for (i = 1; i < MAX_MONITOR_DEVICES; i++) { + monitor_devices[i] = NULL; + } + monitor_device_index = 0; + for (i = 0; i < MAX_NODES; i++) { node_mem[i] = 0; node_cpumask[i] = 0; @@ -5292,7 +5301,12 @@ int main(int argc, char **argv, char **envp) break; } case QEMU_OPTION_monitor: - monitor_device = optarg; + if (monitor_device_index >= MAX_MONITOR_DEVICES) { + fprintf(stderr, "qemu: too many monitor devices\n"); + exit(1); + } + monitor_devices[monitor_device_index] = optarg; + monitor_device_index++; break; case QEMU_OPTION_serial: if (serial_device_index >= MAX_SERIAL_PORTS) { @@ -5626,8 +5640,9 @@ int main(int argc, char **argv, char **envp) serial_devices[0] = "stdio"; if (parallel_device_index == 0) parallel_devices[0] = "null"; - if (strncmp(monitor_device, "vc", 2) == 0) - monitor_device = "stdio"; + if (strncmp(monitor_devices[0], "vc", 2) == 0) { + monitor_devices[0] = "stdio"; + } } #ifndef _WIN32 @@ -5795,14 +5810,14 @@ int main(int argc, char **argv, char **envp) #endif /* Maintain compatibility with multiple stdio monitors */ - if (!strcmp(monitor_device,"stdio")) { + if (!strcmp(monitor_devices[0],"stdio")) { for (i = 0; i < MAX_SERIAL_PORTS; i++) { const char *devname = serial_devices[i]; if (devname && !strcmp(devname,"mon:stdio")) { - monitor_device = NULL; + monitor_devices[0] = NULL; break; } else if (devname && !strcmp(devname,"stdio")) { - monitor_device = NULL; + monitor_devices[0] = NULL; serial_devices[i] = "mon:stdio"; break; } @@ -5861,11 +5876,21 @@ int main(int argc, char **argv, char **envp) } } - if (monitor_device) { - monitor_hd = qemu_chr_open("monitor", monitor_device, NULL); - if (!monitor_hd) { - fprintf(stderr, "qemu: could not open monitor device '%s'\n", monitor_device); - exit(1); + for (i = 0; i < MAX_MONITOR_DEVICES; i++) { + const char *devname = monitor_devices[i]; + if (devname && strcmp(devname, "none")) { + char label[32]; + if (i == 0) { + snprintf(label, sizeof(label), "monitor"); + } else { + snprintf(label, sizeof(label), "monitor%d", i); + } + monitor_hds[i] = qemu_chr_open(label, devname, NULL); + if (!monitor_hds[i]) { + fprintf(stderr, "qemu: could not open monitor device '%s'\n", + devname); + exit(1); + } } } @@ -6003,8 +6028,13 @@ int main(int argc, char **argv, char **envp) text_consoles_set_display(display_state); qemu_chr_initial_reset(); - if (monitor_device && monitor_hd) - monitor_init(monitor_hd, MONITOR_USE_READLINE | MONITOR_IS_DEFAULT); + for (i = 0; i < MAX_MONITOR_DEVICES; i++) { + if (monitor_devices[i] && monitor_hds[i]) { + monitor_init(monitor_hds[i], + MONITOR_USE_READLINE | + ((i == 0) ? MONITOR_IS_DEFAULT : 0)); + } + } for(i = 0; i < MAX_SERIAL_PORTS; i++) { const char *devname = serial_devices[i];