Commit 0a1a7fab authored by Gerd Hoffmann's avatar Gerd Hoffmann
Browse files

chardev: add pty chardev support to chardev-add (qmp)



The ptsname is returned directly, so there is no need to
use query-chardev to figure the pty device path.
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent f6bd5d6e
...@@ -3081,6 +3081,7 @@ ...@@ -3081,6 +3081,7 @@
{ 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile',
'port' : 'ChardevPort', 'port' : 'ChardevPort',
'socket' : 'ChardevSocket', 'socket' : 'ChardevSocket',
'pty' : 'ChardevDummy',
'null' : 'ChardevDummy' } } 'null' : 'ChardevDummy' } }
## ##
...@@ -3090,7 +3091,7 @@ ...@@ -3090,7 +3091,7 @@
# #
# Since: 1.4 # Since: 1.4
## ##
{ 'type' : 'ChardevReturn', 'data': { } } { 'type' : 'ChardevReturn', 'data': { '*pty' : 'str' } }
## ##
# @chardev-add: # @chardev-add:
......
...@@ -3204,6 +3204,19 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, ...@@ -3204,6 +3204,19 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
case CHARDEV_BACKEND_KIND_SOCKET: case CHARDEV_BACKEND_KIND_SOCKET:
chr = qmp_chardev_open_socket(backend->socket, errp); chr = qmp_chardev_open_socket(backend->socket, errp);
break; 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: case CHARDEV_BACKEND_KIND_NULL:
chr = qemu_chr_open_null(NULL); chr = qemu_chr_open_null(NULL);
break; break;
......
...@@ -2685,6 +2685,11 @@ Examples: ...@@ -2685,6 +2685,11 @@ Examples:
"data" : { "out" : "/tmp/bar.log" } } } } "data" : { "out" : "/tmp/bar.log" } } } }
<- { "return": {} } <- { "return": {} }
-> { "execute" : "chardev-add",
"arguments" : { "id" : "baz",
"backend" : { "type" : "pty", "data" : {} } } }
<- { "return": { "pty" : "/dev/pty/42" } }
EQMP EQMP
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment