]> xenbits.xensource.com Git - qemu-upstream-4.4-testing.git/commitdiff
chardev: add pty chardev support to chardev-add (qmp)
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 20 Dec 2012 13:39:13 +0000 (14:39 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 16 Jan 2013 05:58:54 +0000 (06:58 +0100)
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 <kraxel@redhat.com>
qapi-schema.json
qemu-char.c
qmp-commands.hx

index 5c3e3eb469f60d412d3b7d442b562017f30d9c9e..6d7252b9e88011d4f86e3a529566afa885385136 100644 (file)
 { 'union': 'ChardevBackend', 'data': { 'file'   : 'ChardevFile',
                                        'port'   : 'ChardevPort',
                                        'socket' : 'ChardevSocket',
+                                       'pty'    : 'ChardevDummy',
                                        'null'   : 'ChardevDummy' } }
 
 ##
 #
 # Since: 1.4
 ##
-{ 'type' : 'ChardevReturn', 'data': { } }
+{ 'type' : 'ChardevReturn', 'data': { '*pty' : 'str' } }
 
 ##
 # @chardev-add:
index 36d7e2995396969d1aedbd2953a6400c8f296844..9ba0573c6a88770dad096dfc15e502a7c154917c 100644 (file)
@@ -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;
index 4d382f4ffc944c0caee10180b7658009429f156b..cbf12804be09c04c53b802900450567f851483f2 100644 (file)
@@ -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
 
     {