From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtJeY-0007co-1y for qemu-devel@nongnu.org; Thu, 10 Jan 2013 10:02:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtJeO-00018S-VV for qemu-devel@nongnu.org; Thu, 10 Jan 2013 10:02:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtJeO-00017x-M8 for qemu-devel@nongnu.org; Thu, 10 Jan 2013 10:02:36 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0AF2aLA000993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 10 Jan 2013 10:02:36 -0500 From: Gerd Hoffmann Date: Thu, 10 Jan 2013 15:23:06 +0100 Message-Id: <1357827786-14624-11-git-send-email-kraxel@redhat.com> In-Reply-To: <1357827786-14624-1-git-send-email-kraxel@redhat.com> References: <1357827786-14624-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH v2 10/10] chardev: add pty chardev support to chardev-add (qmp) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann 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 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index a654096..23b6862 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3066,6 +3066,7 @@ { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', 'port' : 'ChardevPort', 'socket' : 'ChardevSocket', + 'pty' : 'ChardevDummy', 'null' : 'ChardevDummy' } } ## @@ -3075,7 +3076,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 eb6b153..530d582 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3124,6 +3124,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 { -- 1.7.1