All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, Michal Privoznik <mprivozn@redhat.com>
Subject: Re: [Qemu-devel] [PATCH RfC 0/9] chardev hotplug
Date: Fri, 21 Dec 2012 10:01:46 +0100	[thread overview]
Message-ID: <50D4257A.7050402@redhat.com> (raw)
In-Reply-To: <20121220164426.GA27510@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 490 bytes --]

  Hi,

>> pty looks like another non-trivial challenge.  How does libvirt gather
>> the pty device today?  IIRC there is some stderr parsing?  Or was it
>> info chardev?  With QMP we probably want switch to a more sane model
>> here ...
> 
> Yes, these days we use info chardev, or query-chardev as appropriate
> for the monitor mode.

So do you want continue using query-chardev, or do you prefer to get the
path returned directly, i.e. something like the attached patch?

cheers,
  Gerd


[-- Attachment #2: 0001-chardev-hotplug-qmp-pty.patch --]
[-- Type: text/plain, Size: 3013 bytes --]

From a616ae73d545a80b3a545fdc66bf141a9b3ba004 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Thu, 20 Dec 2012 14:39:13 +0100
Subject: [PATCH] chardev: hotplug, qmp, pty

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 qapi-schema.json |    7 ++++++-
 qemu-char.c      |   24 +++++++++++++++++++++---
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 39e0ab4..63c61c4 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3054,10 +3054,15 @@
 { 'union': 'ChardevBackend', 'data': { 'file'   : 'ChardevFile',
                                        'port'   : 'ChardevPort',
                                        'socket' : 'ChardevSocket',
+                                       'pty'    : 'ChardevDummy',
                                        'null'   : 'ChardevDummy' } }
 
+{ 'union': 'ChardevReturn', 'data': { 'pty'    : 'str',
+                                      'nodata' : 'ChardevDummy' } }
+
 { 'command': 'chardev-add', 'data': {'id'      : 'str',
-                                     'backend' : 'ChardevBackend' } }
+                                     'backend' : 'ChardevBackend' },
+  'returns' : 'ChardevReturn' }
 
 ##
 # @chardev-remove:
diff --git a/qemu-char.c b/qemu-char.c
index 911649a..7f65d40 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3115,9 +3115,13 @@ static CharDriverState *qmp_chardev_open_socket(ChardevSocket *sock,
                                    is_telnet, is_waitconnect, errp);
 }
 
-void qmp_chardev_add(const char *id, ChardevBackend *backend, Error **errp)
+ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
+                               Error **errp)
 {
-    CharDriverState *chr;
+    ChardevReturn *ret = g_new0(ChardevReturn, 1);
+    CharDriverState *chr = NULL;
+
+    ret->kind = CHARDEV_RETURN_KIND_NODATA;
 
     switch (backend->kind) {
     case CHARDEV_BACKEND_KIND_FILE:
@@ -3129,17 +3133,31 @@ void qmp_chardev_add(const char *id, ChardevBackend *backend, Error **errp)
     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->kind = CHARDEV_RETURN_KIND_PTY;
+        ret->pty = g_strdup(qemu_opt_get(opts, "path"));
+        qemu_opts_del(opts);
+        break;
+    }
+#endif
     case CHARDEV_BACKEND_KIND_NULL:
         chr = qemu_chr_open_null(NULL);
         break;
     default:
         error_setg(errp, "unknown chardev backend (%d)", backend->kind);
-        return;
+        break;
     }
 
     if (chr == NULL && !error_is_set(errp)) {
         error_setg(errp, "Failed to create chardev");
     }
+    return ret;
 }
 
 void qmp_chardev_remove(const char *id, Error **errp)
-- 
1.7.1


  reply	other threads:[~2012-12-21  9:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-19 15:58 [Qemu-devel] [PATCH RfC 0/9] chardev hotplug Gerd Hoffmann
2012-12-19 15:58 ` [Qemu-devel] [PATCH 1/9] chardev: add error reporting for qemu_chr_new_from_opts Gerd Hoffmann
2012-12-19 15:59 ` [Qemu-devel] [PATCH 2/9] chardev: fix QemuOpts lifecycle Gerd Hoffmann
2012-12-19 15:59 ` [Qemu-devel] [PATCH 3/9] chardev: reduce chardev ifdef mess a bit Gerd Hoffmann
2012-12-19 20:04   ` Blue Swirl
2012-12-19 15:59 ` [Qemu-devel] [PATCH 4/9] chardev: hotplug, qmp, null Gerd Hoffmann
2012-12-19 15:59 ` [Qemu-devel] [PATCH 5/9] chardev: hotplug, hmp Gerd Hoffmann
2012-12-19 15:59 ` [Qemu-devel] [PATCH 6/9] chardev: hotplug, qmp, file Gerd Hoffmann
2012-12-19 15:59 ` [Qemu-devel] [PATCH 7/9] chardev: hotplug, qmp, tty Gerd Hoffmann
2012-12-19 15:59 ` [Qemu-devel] [PATCH 8/9] chardev: hotplug, qmp, serial Gerd Hoffmann
2012-12-19 16:21   ` Paolo Bonzini
2012-12-20  7:09     ` Gerd Hoffmann
2012-12-19 15:59 ` [Qemu-devel] [PATCH 9/9] chardev: hotplug, qmp, parallel Gerd Hoffmann
2012-12-20 10:49 ` [Qemu-devel] [PATCH RfC 0/9] chardev hotplug Michal Privoznik
2012-12-20 10:56   ` Daniel P. Berrange
2012-12-20 11:10     ` Paolo Bonzini
2012-12-20 11:45       ` Gerd Hoffmann
2012-12-20 13:02         ` Gerd Hoffmann
2012-12-21 11:45           ` Gerd Hoffmann
2012-12-21 11:53             ` Paolo Bonzini
2012-12-21 12:17               ` Gerd Hoffmann
2012-12-21 12:40                 ` Paolo Bonzini
2012-12-21 14:21                   ` Gerd Hoffmann
2012-12-20 16:44         ` Daniel P. Berrange
2012-12-21  9:01           ` Gerd Hoffmann [this message]
2012-12-21  9:28             ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50D4257A.7050402@redhat.com \
    --to=kraxel@redhat.com \
    --cc=berrange@redhat.com \
    --cc=mprivozn@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.