Skip to contentSkip to conversation

qemu-char: do not forward events through the mux until QEMU has started

PATCH In review Paolo Bonzini 2 participants 2 messages Oct 27, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-char: do not forward events through the mux until QEMU has started

Otherwise, the CHR_EVENT_OPENED event is sent twice: first when the backend (for example "stdio") is opened, and second after processing the command line.

The incorrect sending of the event prints the monitor banner when QEMU is started with "-serial mon:stdio". This includes the "(qemu)" prompt; thus the monitor seems to be dead, whereas actually the active front-end is the serial port.

---
 qemu-char.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
qemu-char.c +6 -2
index 6dd779f..2e02d95 100644
@@ -735,19 +735,23 @@ static void mux_chr_read(void *opaque, const uint8_t *buf, int size)
         }
 }
 
+static bool muxes_realized;
+
 static void mux_chr_event(void *opaque, int event)
 {
     CharDriverState *chr = opaque;
     MuxDriver *d = chr->opaque;
     int i;
 
+    if (!muxes_realized) {
+        return;
+    }
+
     /* Send the event to all registered listeners */
     for (i = 0; i < d->mux_cnt; i++)
         mux_chr_send_event(d, i, event);
 }
 
-static bool muxes_realized;
-
 /**
  * Called after processing of default and command-line-specified
  * chardevs to deliver CHR_EVENT_OPENED events to any FEs attached
Signature · 1 line
2.7.4
#1 lore raw
Quoted 11 lines · * Paolo Bonzini ([email protected]) wrote:

Otherwise, the CHR_EVENT_OPENED event is sent twice: first when the backend (for example "stdio") is opened, and second after processing the command line.

The incorrect sending of the event prints the monitor banner when QEMU is started with "-serial mon:stdio". This includes the "(qemu)" prompt; thus the monitor seems to be dead, whereas actually the active front-end is the serial port.

ok, that seems to fix the monitor; it doesn't fix slirp.

Dave

Quoted 37 lines
---
 qemu-char.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
qemu-char.c +6 -2
index 6dd779f..2e02d95 100644
@@ -735,19 +735,23 @@ static void mux_chr_read(void *opaque, const uint8_t *buf, int size)
         }
 }
 
+static bool muxes_realized;
+
 static void mux_chr_event(void *opaque, int event)
 {
     CharDriverState *chr = opaque;
     MuxDriver *d = chr->opaque;
     int i;
 
+    if (!muxes_realized) {
+        return;
+    }
+
     /* Send the event to all registered listeners */
     for (i = 0; i < d->mux_cnt; i++)
         mux_chr_send_event(d, i, event);
 }
 
-static bool muxes_realized;
-
 /**
  * Called after processing of default and command-line-specified
  * chardevs to deliver CHR_EVENT_OPENED events to any FEs attached
Signature · 1 line
2.7.4

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK