From patchwork Thu Feb 28 07:49:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 223806 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CAECF2C0086 for ; Thu, 28 Feb 2013 19:10:46 +1100 (EST) Received: from localhost ([::1]:51887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAyHr-0001rc-KY for incoming@patchwork.ozlabs.org; Thu, 28 Feb 2013 02:52:19 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAyFv-0007hT-7h for qemu-devel@nongnu.org; Thu, 28 Feb 2013 02:50:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAyFs-00073z-Gt for qemu-devel@nongnu.org; Thu, 28 Feb 2013 02:50:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAyFs-00072j-7N for qemu-devel@nongnu.org; Thu, 28 Feb 2013 02:50:16 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1S7oDkC025209 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Feb 2013 02:50:13 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1S7oCuJ005336; Thu, 28 Feb 2013 02:50:12 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 6DCDF452B4; Thu, 28 Feb 2013 08:50:10 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 28 Feb 2013 08:49:59 +0100 Message-Id: <1362037809-27836-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1362037809-27836-1-git-send-email-kraxel@redhat.com> References: <1362037809-27836-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 07/17] chardev: add stdio support to qapi X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- qapi-schema.json | 16 +++++++++++++++- qemu-char.c | 26 ++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 5dcfbfe..77d4153 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3196,6 +3196,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. @@ -3212,7 +3225,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 180fffe..93ed49f 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -753,7 +753,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; @@ -776,8 +776,10 @@ static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts) chr->chr_set_echo = qemu_chr_set_echo_stdio; qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr); stdio_nb_clients++; - 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; @@ -1928,7 +1930,7 @@ static void win_stdio_close(CharDriverState *chr) stdio_nb_clients--; } -static CharDriverState *qemu_chr_open_win_stdio(QemuOpts *opts) +static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts) { CharDriverState *chr; WinStdioCharState *stdio; @@ -2959,6 +2961,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); +} + static const struct { const char *name; /* old, pre qapi */ @@ -2975,14 +2986,14 @@ static const struct { { .name = "memory", .open = qemu_chr_open_ringbuf }, { .name = "file", .kind = CHARDEV_BACKEND_KIND_FILE, .parse = qemu_chr_parse_file_out }, + { .name = "stdio", .kind = CHARDEV_BACKEND_KIND_STDIO, + .parse = qemu_chr_parse_stdio }, #ifdef _WIN32 { .name = "pipe", .open = qemu_chr_open_win_pipe }, { .name = "console", .open = qemu_chr_open_win_con }, { .name = "serial", .open = qemu_chr_open_win }, - { .name = "stdio", .open = qemu_chr_open_win_stdio }, #else { .name = "pipe", .open = qemu_chr_open_pipe }, - { .name = "stdio", .open = qemu_chr_open_stdio }, #endif { .name = "braille", .kind = CHARDEV_BACKEND_KIND_BRAILLE }, #ifdef HAVE_CHARDEV_TTY @@ -3470,6 +3481,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;