[PATCH] Revert "chardev: fix backend events regression with mux chardev"

Szymon Lukasz posted 1 patch 3 years, 10 months ago
Test FreeBSD passed
Test docker-quick@centos7 passed
Test checkpatch passed
Test docker-mingw@fedora passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200630120337.608326-1-noh4hss@gmail.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
chardev/char-mux.c     | 10 ----------
chardev/char.c         | 18 ++++++------------
include/chardev/char.h |  1 -
3 files changed, 6 insertions(+), 23 deletions(-)
[PATCH] Revert "chardev: fix backend events regression with mux chardev"
Posted by Szymon Lukasz 3 years, 10 months ago
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