Skip to contentSkip to conversation

Revert "chardev: fix backend events regression with mux chardev"

PATCH New Szymon Lukasz 1 participant 1 message Jun 30, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "chardev: fix backend events regression with mux chardev"

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.

---
 chardev/char-mux.c     | 10 ----------
 chardev/char.c         | 18 ++++++------------
 include/chardev/char.h |  1 -
 3 files changed, 6 insertions(+), 23 deletions(-)
chardev/char-mux.c +0 -10
index 46c44af67c..30196d6e91 100644
@@ -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;
 }
chardev/char.c +6 -12
index e3051295ac..1041bcc368 100644
@@ -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)
include/chardev/char.h +0 -1
index 00589a6025..d77341605f 100644
@@ -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;
Signature · 1 line
2.27.0