From 633b34d26622c1b43c3a3f1d36a37f450b28afec Mon Sep 17 00:00:00 2001 Message-Id: <633b34d26622c1b43c3a3f1d36a37f450b28afec.1374754302.git.minovotn@redhat.com> In-Reply-To: <5d75a8513d08b33975bdf5971871c0c977167cd1.1374754301.git.minovotn@redhat.com> References: <5d75a8513d08b33975bdf5971871c0c977167cd1.1374754301.git.minovotn@redhat.com> From: Gerd Hoffmann Date: Mon, 24 Jun 2013 07:06:04 +0200 Subject: [PATCH 53/65] chardev: add stdio support to qapi RH-Author: Gerd Hoffmann Message-id: <1372057576-26450-54-git-send-email-kraxel@redhat.com> Patchwork-id: 52154 O-Subject: [RHEL-6.5 qemu-kvm PATCH v2 53/65] chardev: add stdio support to qapi Bugzilla: 676568 RH-Acked-by: Laszlo Ersek RH-Acked-by: Hans de Goede RH-Acked-by: Luiz Capitulino This patch adds 'stdio' support to qapi and also switches over the stdio chardev initialization to the new qapi code path. Signed-off-by: Gerd Hoffmann (cherry picked from commit 7c358031eac9a41c215900020acf8600d33138aa) Conflicts: qemu-char.c --- qapi-schema.json | 16 +++++++++++++++- qemu-char.c | 24 +++++++++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) Signed-off-by: Michal Novotny --- qapi-schema.json | 16 +++++++++++++++- qemu-char.c | 24 +++++++++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 7af0958..1b68510 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -467,6 +467,19 @@ { 'type': 'ChardevMux', 'data': { 'chardev' : 'str' } } ## +# @ChardevStdio: +# +# Configuration info for stdio chardevs. +# +# @signal: #optional Allow signals (such as SIGINT triggered by ^C) +# be delivered to qemu. Default: true in -nographic mode, +# false otherwise. +# +# Since: 1.5 +## +{ 'type': 'ChardevStdio', 'data': { '*signal' : 'bool' } } + +## # @ChardevBackend: # # Configuration info for the new chardev backend. @@ -483,7 +496,8 @@ 'null' : 'ChardevDummy', 'mux' : 'ChardevMux', 'msmouse': 'ChardevDummy', - 'braille': 'ChardevDummy' } } + 'braille': 'ChardevDummy', + 'stdio' : 'ChardevStdio' } } ## # @ChardevReturn: diff --git a/qemu-char.c b/qemu-char.c index b13a8e9..4076cd3 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -935,7 +935,7 @@ static void qemu_chr_close_stdio(struct CharDriverState *chr) fd_chr_close(chr); } -static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts) +static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts) { CharDriverState *chr; @@ -947,8 +947,10 @@ static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts) chr = qemu_chr_open_fd(0, 1); chr->chr_close = qemu_chr_close_stdio; chr->chr_set_echo = qemu_chr_set_echo_stdio; - stdio_allow_signal = qemu_opt_get_bool(opts, "signal", - display_type != DT_NOGRAPHIC); + stdio_allow_signal = display_type != DT_NOGRAPHIC; + if (opts->has_signal) { + stdio_allow_signal = opts->signal; + } qemu_chr_fe_set_echo(chr, false); return chr; @@ -2798,6 +2800,15 @@ static void qemu_chr_parse_file_out(QemuOpts *opts, ChardevBackend *backend, backend->file->out = g_strdup(path); } +static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend, + Error **errp) +{ + backend->stdio = g_new0(ChardevStdio, 1); + backend->stdio->has_signal = true; + backend->stdio->signal = + qemu_opt_get_bool(opts, "signal", display_type != DT_NOGRAPHIC); +} + typedef struct CharDriver { const char *name; /* old, pre qapi */ @@ -3257,6 +3268,9 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, chr = chr_baum_init(); break; #endif + case CHARDEV_BACKEND_KIND_STDIO: + chr = qemu_chr_open_stdio(backend->stdio); + break; default: error_setg(errp, "unknown chardev backend (%d)", backend->kind); break; @@ -3301,14 +3315,14 @@ static void register_types(void) register_char_driver("udp", qemu_chr_open_udp); register_char_driver_qapi("file", CHARDEV_BACKEND_KIND_FILE, qemu_chr_parse_file_out); + register_char_driver_qapi("stdio", CHARDEV_BACKEND_KIND_STDIO, + qemu_chr_parse_stdio); #ifdef _WIN32 register_char_driver("pipe", qemu_chr_open_win_pipe); register_char_driver("console", qemu_chr_open_win_con); register_char_driver("serial", qemu_chr_open_win); - register_char_driver("stdio", qemu_chr_open_win_stdio); #else register_char_driver("pipe", qemu_chr_open_pipe); - register_char_driver("stdio", qemu_chr_open_stdio); #endif #ifdef HAVE_CHARDEV_TTY register_char_driver("tty", qemu_chr_open_tty); -- 1.7.11.7