From patchwork Wed Jan 16 10:21:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 212492 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 8FA2C2C0040 for ; Wed, 16 Jan 2013 22:31:25 +1100 (EST) Received: from localhost ([::1]:47585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvQ8K-0008L9-Nn for incoming@patchwork.ozlabs.org; Wed, 16 Jan 2013 05:22:12 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvQ7a-0007CQ-Mw for qemu-devel@nongnu.org; Wed, 16 Jan 2013 05:21:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvQ7S-0002e7-1Z for qemu-devel@nongnu.org; Wed, 16 Jan 2013 05:21:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvQ7R-0002df-NM for qemu-devel@nongnu.org; Wed, 16 Jan 2013 05:21:17 -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 r0GALH4G016479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Jan 2013 05:21:17 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-103.ams2.redhat.com [10.36.116.103]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0GALFbc024252; Wed, 16 Jan 2013 05:21:16 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id C2A9540CD3; Wed, 16 Jan 2013 11:21:13 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 16 Jan 2013 11:21:13 +0100 Message-Id: <1358331673-6159-11-git-send-email-kraxel@redhat.com> In-Reply-To: <1358331673-6159-1-git-send-email-kraxel@redhat.com> References: <1358331673-6159-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: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 10/10] chardev: add pty chardev support to chardev-add (qmp) 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 The ptsname is returned directly, so there is no need to use query-chardev to figure the pty device path. Signed-off-by: Gerd Hoffmann --- qapi-schema.json | 3 ++- qemu-char.c | 13 +++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/qapi-schema.json b/qapi-schema.json index 5c3e3eb..6d7252b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3081,6 +3081,7 @@ { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', 'port' : 'ChardevPort', 'socket' : 'ChardevSocket', + 'pty' : 'ChardevDummy', 'null' : 'ChardevDummy' } } ## @@ -3090,7 +3091,7 @@ # # Since: 1.4 ## -{ 'type' : 'ChardevReturn', 'data': { } } +{ 'type' : 'ChardevReturn', 'data': { '*pty' : 'str' } } ## # @chardev-add: diff --git a/qemu-char.c b/qemu-char.c index 36d7e29..9ba0573 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3204,6 +3204,19 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, case CHARDEV_BACKEND_KIND_SOCKET: chr = qmp_chardev_open_socket(backend->socket, errp); break; +#ifdef HAVE_CHARDEV_TTY + case CHARDEV_BACKEND_KIND_PTY: + { + /* qemu_chr_open_pty sets "path" in opts */ + QemuOpts *opts; + opts = qemu_opts_create_nofail(qemu_find_opts("chardev")); + chr = qemu_chr_open_pty(opts); + ret->pty = g_strdup(qemu_opt_get(opts, "path")); + ret->has_pty = true; + qemu_opts_del(opts); + break; + } +#endif case CHARDEV_BACKEND_KIND_NULL: chr = qemu_chr_open_null(NULL); break; diff --git a/qmp-commands.hx b/qmp-commands.hx index 4d382f4..cbf1280 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2685,6 +2685,11 @@ Examples: "data" : { "out" : "/tmp/bar.log" } } } } <- { "return": {} } +-> { "execute" : "chardev-add", + "arguments" : { "id" : "baz", + "backend" : { "type" : "pty", "data" : {} } } } +<- { "return": { "pty" : "/dev/pty/42" } } + EQMP {