From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, agraf@suse.de, lcapitulino@redhat.com
Subject: [Qemu-devel] [FOR 0.12 PATCH v3 07/21] default devices: qemu monitor.
Date: Mon, 7 Dec 2009 13:42:39 +0100 [thread overview]
Message-ID: <1260189773-20728-8-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1260189773-20728-1-git-send-email-kraxel@redhat.com>
This patch makes the monitor default device configuration work like the
default serial and parallel port devices. It adds a variable
default_monitor which says whenever a default monitor should be added.
It is enabled by default. It is cleared when qemu finds '-monitor' on
the command line.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
vl.c | 94 +++++++++++++++++++++++++++++++++++-------------------------------
1 files changed, 50 insertions(+), 44 deletions(-)
diff --git a/vl.c b/vl.c
index 50e4558..cb59c3c 100644
--- a/vl.c
+++ b/vl.c
@@ -211,6 +211,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;
@@ -273,6 +274,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;
@@ -4618,6 +4620,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;
@@ -4649,22 +4652,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;
}
@@ -4715,6 +4723,32 @@ 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 == MAX_MONITOR_DEVICES) {
+ fprintf(stderr, "qemu: too many monitor devices\n");
+ exit(1);
+ }
+ 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);
+ 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;
@@ -4730,9 +4764,6 @@ int main(int argc, char **argv, char **envp)
QemuOpts *hda_opts = NULL, *opts;
int optind;
const char *r, *optarg;
- CharDriverState *monitor_hds[MAX_MONITOR_DEVICES];
- const char *monitor_devices[MAX_MONITOR_DEVICES];
- int monitor_device_index;
const char *virtio_consoles[MAX_VIRTIO_CONSOLES];
int virtio_console_index;
const char *loadvm = NULL;
@@ -4804,12 +4835,6 @@ 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;
@@ -5223,12 +5248,8 @@ int main(int argc, char **argv, char **envp)
break;
}
case QEMU_OPTION_monitor:
- 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++;
+ add_device_config(DEV_MONITOR, optarg);
+ default_monitor = 0;
break;
case QEMU_OPTION_chardev:
opts = qemu_opts_parse(&qemu_chardev_opts, optarg, "backend");
@@ -5546,14 +5567,15 @@ int main(int argc, char **argv, char **envp)
add_device_config(DEV_SERIAL, "stdio");
if (default_parallel)
add_device_config(DEV_PARALLEL, "null");
- if (strncmp(monitor_devices[0], "vc", 2) == 0) {
- monitor_devices[0] = "stdio";
- }
+ if (default_monitor)
+ add_device_config(DEV_MONITOR, "stdio");
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "vc:80Cx24C");
if (default_parallel)
add_device_config(DEV_PARALLEL, "vc:80Cx24C");
+ if (default_monitor)
+ add_device_config(DEV_MONITOR, "vc:80Cx24C");
}
#ifndef _WIN32
@@ -5702,7 +5724,7 @@ int main(int argc, char **argv, char **envp)
ram_load, NULL);
/* Maintain compatibility with multiple stdio monitors */
- serial_monitor_mux(monitor_devices);
+ serial_monitor_mux();
if (nb_numa_nodes > 0) {
int i;
@@ -5746,24 +5768,8 @@ int main(int argc, char **argv, char **envp)
}
}
- 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);
- }
- }
- }
-
+ if (foreach_device_config(DEV_MONITOR, monitor_parse) < 0)
+ exit(1);
if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
exit(1);
if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
@@ -5887,7 +5893,7 @@ int main(int argc, char **argv, char **envp)
text_consoles_set_display(display_state);
for (i = 0; i < MAX_MONITOR_DEVICES; i++) {
- if (monitor_devices[i] && monitor_hds[i]) {
+ if (monitor_hds[i]) {
monitor_init(monitor_hds[i],
MONITOR_USE_READLINE |
((i == 0) ? MONITOR_IS_DEFAULT : 0));
--
1.6.5.2
next prev parent reply other threads:[~2009-12-07 12:44 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-07 12:42 [Qemu-devel] [FOR 0.12 PATCH v3 00/21] default devices: qdev integration Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 01/21] Revert "monitor: Command-line flag to enable control mode" Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 02/21] Revert "Set default console to virtio on S390x" Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 03/21] chardev: move greeting into vc backend Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 04/21] vc: colorize chardev title line with blue background Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 05/21] default devices: core code & serial lines Gerd Hoffmann
2009-12-07 12:52 ` [Qemu-devel] " Alexander Graf
2009-12-07 13:27 ` Gerd Hoffmann
2009-12-07 14:07 ` Alexander Graf
2009-12-07 14:39 ` Gerd Hoffmann
2009-12-07 15:12 ` Alexander Graf
2009-12-07 16:05 ` Gerd Hoffmann
2009-12-07 16:10 ` Alexander Graf
2009-12-08 9:23 ` Gerd Hoffmann
2009-12-07 12:54 ` Alexander Graf
2009-12-07 13:30 ` Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 06/21] default devices: parallel port Gerd Hoffmann
2009-12-07 12:42 ` Gerd Hoffmann [this message]
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 08/21] zap serial_monitor_mux Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 09/21] default devices: vga adapter Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 10/21] default devices: add global cmd line option Gerd Hoffmann
2009-12-08 12:46 ` [Qemu-devel] " Paolo Bonzini
2009-12-08 15:58 ` Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 11/21] default devices: network Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 12/21] default devices: drives Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 13/21] qdev: make compat stuff more generic Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 14/21] qdev: add command line option to set global defaults for properties Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 15/21] chardev: make chardevs specified in config file work Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 16/21] un-static qemu_chr_parse_compat() Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 17/21] rework -monitor handling, switch to QemuOpts Gerd Hoffmann
2009-12-07 14:59 ` [Qemu-devel] " Luiz Capitulino
2009-12-07 15:18 ` Gerd Hoffmann
2009-12-07 19:11 ` [Qemu-devel] " Anthony Liguori
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 18/21] add new -mon switch Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 19/21] add -qmp convinience switch Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 20/21] default devices: virtio consoles Gerd Hoffmann
2009-12-07 13:07 ` [Qemu-devel] " Alexander Graf
2009-12-07 13:34 ` Gerd Hoffmann
2009-12-07 12:42 ` [Qemu-devel] [FOR 0.12 PATCH v3 21/21] Set default console to virtio on S390x Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1260189773-20728-8-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=agraf@suse.de \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).