@@ -118,6 +118,9 @@ void qemu_chr_be_event(CharDriverState *s, int event)
break;
}
+ if (s->chr_event_priv)
+ s->chr_event_priv(s, event);
+
if (!s->chr_event)
return;
s->chr_event(s->handler_opaque, event);
@@ -765,6 +768,22 @@ static void qemu_chr_close_stdio(struct CharDriverState *chr)
fd_chr_close(chr);
}
+
+static void qemu_chr_event_stdio(void *opaque, int event)
+{
+ CharDriverState *chr = opaque;
+
+ switch (event) {
+ case CHR_EVENT_OPENED:
+ qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr);
+ break;
+ case CHR_EVENT_CLOSED:
+ qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL);
+ break;
+ }
+}
+
+
static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts)
{
CharDriverState *chr;
@@ -782,7 +801,7 @@ static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts)
chr = qemu_chr_open_fd(0, 1);
chr->chr_close = qemu_chr_close_stdio;
chr->chr_set_echo = qemu_chr_set_echo_stdio;
- qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr);
+ chr->chr_event_priv = qemu_chr_event_stdio;
stdio_nb_clients++;
stdio_allow_signal = qemu_opt_get_bool(opts, "signal",
display_type != DT_NOGRAPHIC);
@@ -59,6 +59,7 @@ struct CharDriverState {
int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
int (*get_msgfd)(struct CharDriverState *s);
int (*chr_add_client)(struct CharDriverState *chr, int fd);
+ IOEventHandler *chr_event_priv;
IOEventHandler *chr_event;
IOCanReadHandler *chr_can_read;
IOReadHandler *chr_read;