[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] -nographic sometimes adds an extra chardev for stdi
From: |
Mike Day |
Subject: |
[Qemu-devel] [PATCH] -nographic sometimes adds an extra chardev for stdio |
Date: |
Mon, 28 Apr 2014 11:00:33 -0400 |
When the deprecated -nographic option is used with the -mon option in
readline mode, qemu will create a second character device for stdio
and place it over the stdio chardev put into place by the -mon
option. This causes the terminal to stop echoeing characters upon exit
from Qemu.
Fix by checking for the existing chardev before adding another.
Signed-off-by: Mike Day <address@hidden>
---
To reproduce, use -mon and -nographic together. I was able to
reproduce it using
# qemu-system-x86_64 -enable-kvm -m 1G -chardev stdio,id=mon0 \
# -mon chardev=mon0,mode=readline -nographic
---
vl.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/vl.c b/vl.c
index 236f95e..3104b20 100644
--- a/vl.c
+++ b/vl.c
@@ -93,6 +93,7 @@ int main(int argc, char **argv)
#include "sysemu/kvm.h"
#include "qapi/qmp/qjson.h"
#include "qemu/option.h"
+#include "qemu/option_int.h"
#include "qemu/config-file.h"
#include "qemu-options.h"
#include "qmp-commands.h"
@@ -524,6 +525,20 @@ static QemuOptsList qemu_mem_opts = {
},
};
+static int qemu_opts_loopfun(QemuOpts *opts, void *opaque)
+{
+ QemuOpt *opt;
+
+ if (!strncmp(((QemuOpt *)opts->list)->name, "mon", 3)) {
+ QTAILQ_FOREACH(opt, &opts->head, next) {
+ if (!strncmp(opt->name, "chardev", 7)) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
/**
* Get machine options
*
@@ -4113,6 +4128,11 @@ int main(int argc, char **argv, char **envp)
}
if (display_type == DT_NOGRAPHIC) {
+ int have_stdio = 0;
+ QemuOptsList *opts = qemu_find_opts("mon");
+ if (opts) {
+ have_stdio = qemu_opts_foreach(opts, qemu_opts_loopfun, NULL, 0);
+ }
if (default_parallel)
add_device_config(DEV_PARALLEL, "null");
if (default_serial && default_monitor) {
@@ -4122,7 +4142,7 @@ int main(int argc, char **argv, char **envp)
} else if (default_sclp && default_monitor) {
add_device_config(DEV_SCLP, "mon:stdio");
} else {
- if (default_serial)
+ if (default_serial && !have_stdio)
add_device_config(DEV_SERIAL, "stdio");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "stdio");
--
1.9.0