qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Szymon Lukasz <noh4hss@gmail.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, Szymon Lukasz <noh4hss@gmail.com>,
	marcandre.lureau@redhat.com
Subject: [PATCH] Revert "chardev: fix backend events regression with mux chardev"
Date: Tue, 30 Jun 2020 14:03:37 +0200	[thread overview]
Message-ID: <20200630120337.608326-1-noh4hss@gmail.com> (raw)

This reverts commit d09c4a47874f30820b08c39ad39bcca9b8cde084.

Seems like the problem described in the above commit is also
fixed by eeaa6715050.

Basically, the current code has the following invariant:
(d->focus == -1 && chr->be == NULL) || (d->focus >= 0 && chr->be == d->backends[d->focus])

So there's no need to add the code for sending events
to the focused frontend because qemu_chr_be_event()
will do that for us.

Signed-off-by: Szymon Lukasz <noh4hss@gmail.com>
---
 chardev/char-mux.c     | 10 ----------
 chardev/char.c         | 18 ++++++------------
 include/chardev/char.h |  1 -
 3 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/chardev/char-mux.c b/chardev/char-mux.c
index 46c44af67c..30196d6e91 100644
--- a/chardev/char-mux.c
+++ b/chardev/char-mux.c
@@ -126,15 +126,6 @@ static void mux_chr_send_event(MuxChardev *d, int mux_nr, QEMUChrEvent event)
     }
 }
 
-static void mux_chr_be_event(Chardev *chr, QEMUChrEvent event)
-{
-    MuxChardev *d = MUX_CHARDEV(chr);
-
-    if (d->focus != -1) {
-        mux_chr_send_event(d, d->focus, event);
-    }
-}
-
 static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch)
 {
     if (d->term_got_escape) {
@@ -382,7 +373,6 @@ static void char_mux_class_init(ObjectClass *oc, void *data)
     cc->chr_write = mux_chr_write;
     cc->chr_accept_input = mux_chr_accept_input;
     cc->chr_add_watch = mux_chr_add_watch;
-    cc->chr_be_event = mux_chr_be_event;
     cc->chr_machine_done = open_muxes;
     cc->chr_update_read_handler = mux_chr_update_read_handlers;
 }
diff --git a/chardev/char.c b/chardev/char.c
index e3051295ac..1041bcc368 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -50,19 +50,10 @@ static Object *get_chardevs_root(void)
     return container_get(object_get_root(), "/chardevs");
 }
 
-static void chr_be_event(Chardev *s, QEMUChrEvent event)
+void qemu_chr_be_event(Chardev *s, QEMUChrEvent event)
 {
     CharBackend *be = s->be;
 
-    if (!be || !be->chr_event) {
-        return;
-    }
-
-    be->chr_event(be->opaque, event);
-}
-
-void qemu_chr_be_event(Chardev *s, QEMUChrEvent event)
-{
     /* Keep track if the char device is open */
     switch (event) {
         case CHR_EVENT_OPENED:
@@ -78,7 +69,11 @@ void qemu_chr_be_event(Chardev *s, QEMUChrEvent event)
         break;
     }
 
-    CHARDEV_GET_CLASS(s)->chr_be_event(s, event);
+    if (!be || !be->chr_event) {
+        return;
+    }
+
+    be->chr_event(be->opaque, event);
 }
 
 /* Not reporting errors from writing to logfile, as logs are
@@ -276,7 +271,6 @@ static void char_class_init(ObjectClass *oc, void *data)
     ChardevClass *cc = CHARDEV_CLASS(oc);
 
     cc->chr_write = null_chr_write;
-    cc->chr_be_event = chr_be_event;
 }
 
 static void char_finalize(Object *obj)
diff --git a/include/chardev/char.h b/include/chardev/char.h
index 00589a6025..d77341605f 100644
--- a/include/chardev/char.h
+++ b/include/chardev/char.h
@@ -273,7 +273,6 @@ typedef struct ChardevClass {
     void (*chr_accept_input)(Chardev *chr);
     void (*chr_set_echo)(Chardev *chr, bool echo);
     void (*chr_set_fe_open)(Chardev *chr, int fe_open);
-    void (*chr_be_event)(Chardev *s, QEMUChrEvent event);
     /* Return 0 if succeeded, 1 if failed */
     int (*chr_machine_done)(Chardev *chr);
 } ChardevClass;
-- 
2.27.0



                 reply	other threads:[~2020-06-30 12:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200630120337.608326-1-noh4hss@gmail.com \
    --to=noh4hss@gmail.com \
    --cc=marcandre.lureau@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).