s->chr_event(s->handler_opaque, event);
}
-static gboolean qemu_chr_be_generic_open_bh(gpointer opaque)
-{
- CharDriverState *s = opaque;
- qemu_chr_be_event(s, CHR_EVENT_OPENED);
- s->idle_tag = 0;
- return FALSE;
-}
-
void qemu_chr_be_generic_open(CharDriverState *s)
{
- if (s->idle_tag == 0) {
- s->idle_tag = g_idle_add(qemu_chr_be_generic_open_bh, s);
- }
+ qemu_chr_be_event(s, CHR_EVENT_OPENED);
}
int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len)
chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = null_chr_write;
+ chr->explicit_be_open = true;
return chr;
}
/* Frontend guest-open / -close notification is not support with muxes */
chr->chr_set_fe_open = NULL;
- /* Muxes are always open on creation */
- qemu_chr_be_generic_open(chr);
-
return chr;
}
chr->chr_update_read_handler = fd_chr_update_read_handler;
chr->chr_close = fd_chr_close;
- qemu_chr_be_generic_open(chr);
-
return chr;
}
chr->chr_update_read_handler = pty_chr_update_read_handler;
chr->chr_close = pty_chr_close;
chr->chr_add_watch = pty_chr_add_watch;
+ chr->explicit_be_open = true;
s->fd = io_channel_from_fd(master_fd);
s->timer_tag = 0;
chr->chr_close = pp_close;
chr->opaque = drv;
- qemu_chr_be_generic_open(chr);
-
return chr;
}
#endif /* __linux__ */
chr->opaque = (void *)(intptr_t)fd;
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
+ chr->explicit_be_open = true;
return chr;
}
#endif
g_free(chr);
return NULL;
}
- qemu_chr_be_generic_open(chr);
return chr;
}
g_free(chr);
return NULL;
}
- qemu_chr_be_generic_open(chr);
return chr;
}
s->hcom = fd_out;
chr->opaque = s;
chr->chr_write = win_chr_write;
- qemu_chr_be_generic_open(chr);
return chr;
}
chr->chr_write = udp_chr_write;
chr->chr_update_read_handler = udp_chr_update_read_handler;
chr->chr_close = udp_chr_close;
+ /* be isn't opened until we get a connection */
+ chr->explicit_be_open = true;
return chr;
}
chr->get_msgfd = tcp_get_msgfd;
chr->chr_add_client = tcp_chr_add_client;
chr->chr_add_watch = tcp_chr_add_watch;
+ /* be isn't opened until we get a connection */
+ chr->explicit_be_open = true;
if (is_listen) {
s->listen_fd = fd;
if (!chr->filename)
chr->filename = g_strdup(qemu_opt_get(opts, "backend"));
chr->init = init;
+ /* if we didn't create the chardev via qmp_chardev_add, we
+ * need to send the OPENED event here
+ */
+ if (!chr->explicit_be_open) {
+ qemu_chr_be_event(chr, CHR_EVENT_OPENED);
+ }
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
if (qemu_opt_get_bool(opts, "mux", 0)) {
if (!chr->filename) {
chr->filename = g_strdup(ChardevBackendKind_lookup[backend->kind]);
}
+ if (!chr->explicit_be_open) {
+ qemu_chr_be_event(chr, CHR_EVENT_OPENED);
+ }
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
return ret;
} else {