]> git.proxmox.com Git - mirror_qemu.git/commitdiff
chardev: add Chardev.gcontext field
authorPeter Xu <peterx@redhat.com>
Thu, 21 Sep 2017 06:35:52 +0000 (14:35 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 22 Sep 2017 19:07:27 +0000 (21:07 +0200)
It caches the gcontext that is used to poll the chardev IO.  Before this
patch, we only passed it in via chr_update_read_handlers().  However
that may not be enough if the char backend is disconnected and
reconnected afterward.  There are chardev codes that still assumed the
context be NULL (which is the main context).  Will fix that up in
following up patches.

Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <1505975754-21555-3-git-send-email-peterx@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
chardev/char.c
include/chardev/char.h

index e090dd5a276e20a6f837cf5941a4ccbe64e10e3c..89eabea5acba53dc3c5ba0e573322728c216175d 100644 (file)
@@ -185,6 +185,7 @@ void qemu_chr_be_update_read_handlers(Chardev *s,
 {
     ChardevClass *cc = CHARDEV_GET_CLASS(s);
 
+    s->gcontext = context;
     if (cc->chr_update_read_handler) {
         cc->chr_update_read_handler(s, context);
     }
index 2068ea496d222bead7c683280b45a44fc17b2ae0..84fb7735911c5f66f084f1a3d9d1bd27c3c55a87 100644 (file)
@@ -55,6 +55,7 @@ struct Chardev {
     int logfd;
     int be_open;
     GSource *gsource;
+    GMainContext *gcontext;
     DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST);
 };