/* FIXME we should resubmit pending requests when the CDS reconnects. */
qemu_chr_fe_set_handlers(&s->chr, rng_egd_chr_can_read,
- rng_egd_chr_read, NULL, s, NULL);
+ rng_egd_chr_read, NULL, s, NULL, true);
}
static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
if (chr) {
qemu_chr_fe_init(&s->chr, chr, &error_abort);
qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_receive,
- gdb_chr_event, NULL, NULL);
+ gdb_chr_event, NULL, NULL, true);
}
s->state = chr ? RS_IDLE : RS_INACTIVE;
s->mon_chr = mon_chr;
PXA2xxFIrState *s = PXA2XX_FIR(dev);
qemu_chr_fe_set_handlers(&s->chr, pxa2xx_fir_is_empty,
- pxa2xx_fir_rx, pxa2xx_fir_event, s, NULL);
+ pxa2xx_fir_rx, pxa2xx_fir_event, s, NULL, true);
}
static bool pxa2xx_fir_vmstate_validate(void *opaque, int version_id)
strongarm_uart_can_receive,
strongarm_uart_receive,
strongarm_uart_event,
- s, NULL);
+ s, NULL, true);
}
static void strongarm_uart_reset(DeviceState *dev)
BCM2835AuxState *s = BCM2835_AUX(dev);
qemu_chr_fe_set_handlers(&s->chr, bcm2835_aux_can_receive,
- bcm2835_aux_receive, NULL, s, NULL);
+ bcm2835_aux_receive, NULL, s, NULL, true);
}
static Property bcm2835_aux_props[] = {
fifo_trigger_update, s);
qemu_chr_fe_set_handlers(&s->chr, uart_can_receive, uart_receive,
- uart_event, s, NULL);
+ uart_event, s, NULL, true);
}
static void cadence_uart_init(Object *obj)
return;
}
- qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, NULL, s, NULL);
+ qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, NULL, s, NULL, true);
}
static void debugcon_isa_realizefn(DeviceState *dev, Error **errp)
DigicUartState *s = DIGIC_UART(dev);
qemu_chr_fe_set_handlers(&s->chr, uart_can_rx, uart_rx,
- uart_event, s, NULL);
+ uart_event, s, NULL, true);
}
static void digic_uart_init(Object *obj)
s->chn[i].clock = s->frequency / 2;
qemu_chr_fe_set_handlers(&s->chn[i].chr, serial_can_receive,
serial_receive1, serial_event,
- &s->chn[i], NULL);
+ &s->chn[i], NULL, true);
}
}
qemu_chr_fe_set_handlers(&s->chr,
serial_can_receive, serial_receive,
- serial_event, s, NULL);
+ serial_event, s, NULL, true);
}
static void etraxfs_ser_class_init(ObjectClass *klass, void *data)
qemu_chr_fe_set_handlers(&s->chr, exynos4210_uart_can_receive,
exynos4210_uart_receive, exynos4210_uart_event,
- s, NULL);
+ s, NULL, true);
return 0;
}
grlib_apbuart_can_receive,
grlib_apbuart_receive,
grlib_apbuart_event,
- uart, NULL);
+ uart, NULL, true);
sysbus_init_irq(dev, &uart->irq);
DPRINTF("char dev for uart: %p\n", qemu_chr_fe_get_driver(&s->chr));
qemu_chr_fe_set_handlers(&s->chr, imx_can_receive, imx_receive,
- imx_event, s, NULL);
+ imx_event, s, NULL, true);
}
static void imx_serial_init(Object *obj)
/* Redirect IP-Octal channels to host character devices */
if (qemu_chr_fe_get_driver(&ch->dev)) {
qemu_chr_fe_set_handlers(&ch->dev, hostdev_can_receive,
- hostdev_receive, hostdev_event, ch, NULL);
+ hostdev_receive, hostdev_event,
+ ch, NULL, true);
DPRINTF("Redirecting channel %u to %s\n", i, ch->dev->label);
} else {
DPRINTF("Could not redirect channel %u, no chardev set\n", i);
LM32JuartState *s = LM32_JUART(dev);
qemu_chr_fe_set_handlers(&s->chr, juart_can_rx, juart_rx,
- juart_event, s, NULL);
+ juart_event, s, NULL, true);
}
static const VMStateDescription vmstate_lm32_juart = {
LM32UartState *s = LM32_UART(dev);
qemu_chr_fe_set_handlers(&s->chr, uart_can_rx, uart_rx,
- uart_event, s, NULL);
+ uart_event, s, NULL, true);
}
static const VMStateDescription vmstate_lm32_uart = {
if (chr) {
qemu_chr_fe_init(&s->chr, chr, &error_abort);
qemu_chr_fe_set_handlers(&s->chr, mcf_uart_can_receive,
- mcf_uart_receive, mcf_uart_event, s, NULL);
+ mcf_uart_receive, mcf_uart_event,
+ s, NULL, true);
}
mcf_uart_reset(s);
return s;
MilkymistUartState *s = MILKYMIST_UART(dev);
qemu_chr_fe_set_handlers(&s->chr, uart_can_rx, uart_rx,
- uart_event, s, NULL);
+ uart_event, s, NULL, true);
}
static void milkymist_uart_init(Object *obj)
PL011State *s = PL011(dev);
qemu_chr_fe_set_handlers(&s->chr, pl011_can_receive, pl011_receive,
- pl011_event, s, NULL);
+ pl011_event, s, NULL, true);
}
static void pl011_class_init(ObjectClass *oc, void *data)
console_available = true;
qemu_chr_fe_set_handlers(&scon->chr, chr_can_read,
- chr_read, NULL, scon, NULL);
+ chr_read, NULL, scon, NULL, true);
return 0;
}
}
console_available = true;
qemu_chr_fe_set_handlers(&scon->chr, chr_can_read,
- chr_read, NULL, scon, NULL);
+ chr_read, NULL, scon, NULL, true);
return 0;
}
qemu_register_reset(serial_reset, s);
qemu_chr_fe_set_handlers(&s->chr, serial_can_receive1, serial_receive1,
- serial_event, s, NULL);
+ serial_event, s, NULL, true);
fifo8_create(&s->recv_fifo, UART_FIFO_LENGTH);
fifo8_create(&s->xmit_fifo, UART_FIFO_LENGTH);
serial_reset(s);
qemu_chr_fe_init(&s->chr, chr, &error_abort);
qemu_chr_fe_set_handlers(&s->chr, sh_serial_can_receive1,
sh_serial_receive1,
- sh_serial_event, s, NULL);
+ sh_serial_event, s, NULL, true);
}
s->eri = eri_source;
}
qemu_chr_fe_set_handlers(&dev->chardev, vty_can_receive,
- vty_receive, NULL, dev, NULL);
+ vty_receive, NULL, dev, NULL, true);
}
/* Forward declaration */
STM32F2XXUsartState *s = STM32F2XX_USART(dev);
qemu_chr_fe_set_handlers(&s->chr, stm32f2xx_usart_can_receive,
- stm32f2xx_usart_receive, NULL, s, NULL);
+ stm32f2xx_usart_receive, NULL, s, NULL, true);
}
static void stm32f2xx_usart_class_init(ObjectClass *klass, void *data)
* trigger open/close of the device
*/
if (k->is_console) {
- chr->explicit_fe_open = 0;
qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read,
- NULL, vcon, NULL);
+ NULL, vcon, NULL, true);
virtio_serial_open(port);
} else {
- chr->explicit_fe_open = 1;
qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read,
- chr_event, vcon, NULL);
+ chr_event, vcon, NULL, false);
}
}
}
xen_be_bind_evtchn(&con->xendev);
qemu_chr_fe_set_handlers(&con->chr, xencons_can_receive,
- xencons_receive, NULL, con, NULL);
+ xencons_receive, NULL, con, NULL, true);
xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
con->ring_ref,
XilinxUARTLite *s = XILINX_UARTLITE(dev);
qemu_chr_fe_set_handlers(&s->chr, uart_can_rx, uart_rx,
- uart_event, s, NULL);
+ uart_event, s, NULL, true);
}
static void xilinx_uartlite_init(Object *obj)
}
qemu_chr_fe_set_handlers(&ibe->chr, can_receive, receive,
- chr_event, ibe, NULL);
+ chr_event, ibe, NULL, true);
}
static int ipmi_bmc_extern_post_migrate(void *opaque, int version_id)
chr = qemu_chr_new("fpga", "vc:320x200");
qemu_chr_fe_init(&s->display, chr, NULL);
qemu_chr_fe_set_handlers(&s->display, NULL, NULL,
- malta_fgpa_display_event, s, NULL);
+ malta_fgpa_display_event, s, NULL, true);
s->uart = serial_mm_init(address_space, base + 0x900, 3, uart_irq,
230400, uart_chr, DEVICE_NATIVE_ENDIAN);
}
qemu_chr_fe_set_handlers(&s->server_chr, ivshmem_can_receive,
- ivshmem_read, NULL, s, NULL);
+ ivshmem_read, NULL, s, NULL, true);
if (ivshmem_setup_interrupts(s) < 0) {
error_setg(errp, "failed to initialize interrupts");
qemu_chr_fe_set_handlers(&card->cs,
ccid_card_vscard_can_read,
ccid_card_vscard_read,
- ccid_card_vscard_event, card, NULL);
+ ccid_card_vscard_event, card, NULL, true);
ccid_card_vscard_send_init(card);
} else {
error_report("missing chardev");
}
qemu_chr_fe_set_handlers(&s->cs, usb_serial_can_read, usb_serial_read,
- usb_serial_event, s, NULL);
+ usb_serial_event, s, NULL, true);
usb_serial_handle_reset(dev);
if (chr->be_open && !dev->attached) {
/* Let the backend know we are ready */
qemu_chr_fe_set_handlers(&dev->cs, usbredir_chardev_can_read,
usbredir_chardev_read, usbredir_chardev_event,
- dev, NULL);
+ dev, NULL, true);
qemu_add_vm_change_state_handler(usbredir_vm_state_change, dev);
}
int logfd;
int be_open;
int fe_open;
- int explicit_fe_open;
int explicit_be_open;
int avail_connections;
int is_mux;
* @fd_event: event callback
* @opaque: an opaque pointer for the callbacks
* @context: a main loop context or NULL for the default
+ * @set_open: whether to call qemu_chr_fe_set_open() implicitely when
+ * any of the handler is non-NULL
*
* Set the front end char handlers. The front end takes the focus if
* any of the handler is non-NULL.
IOReadHandler *fd_read,
IOEventHandler *fd_event,
void *opaque,
- GMainContext *context);
+ GMainContext *context,
+ bool set_open);
/**
* @qemu_chr_fe_take_focus:
if (monitor_is_qmp(mon)) {
qemu_chr_fe_set_handlers(&mon->chr, monitor_can_read, monitor_qmp_read,
- monitor_qmp_event, mon, NULL);
+ monitor_qmp_event, mon, NULL, true);
qemu_chr_fe_set_echo(&mon->chr, true);
json_message_parser_init(&mon->qmp.parser, handle_qmp_command);
} else {
qemu_chr_fe_set_handlers(&mon->chr, monitor_can_read, monitor_read,
- monitor_event, mon, NULL);
+ monitor_event, mon, NULL, true);
}
qemu_mutex_lock(&monitor_lock);
ret = net_fill_rstate(&s->pri_rs, buf, size);
if (ret == -1) {
- qemu_chr_fe_set_handlers(&s->chr_pri_in, NULL, NULL, NULL, NULL, NULL);
+ qemu_chr_fe_set_handlers(&s->chr_pri_in, NULL, NULL, NULL,
+ NULL, NULL, true);
error_report("colo-compare primary_in error");
}
}
ret = net_fill_rstate(&s->sec_rs, buf, size);
if (ret == -1) {
- qemu_chr_fe_set_handlers(&s->chr_sec_in, NULL, NULL, NULL, NULL, NULL);
+ qemu_chr_fe_set_handlers(&s->chr_sec_in, NULL, NULL, NULL,
+ NULL, NULL, true);
error_report("colo-compare secondary_in error");
}
}
worker_context = g_main_context_new();
qemu_chr_fe_set_handlers(&s->chr_pri_in, compare_chr_can_read,
- compare_pri_chr_in, NULL, s, worker_context);
+ compare_pri_chr_in, NULL, s, worker_context, true);
qemu_chr_fe_set_handlers(&s->chr_sec_in, compare_chr_can_read,
- compare_sec_chr_in, NULL, s, worker_context);
+ compare_sec_chr_in, NULL, s, worker_context, true);
compare_loop = g_main_loop_new(worker_context, FALSE);
ret = net_fill_rstate(&s->rs, buf, size);
if (ret == -1) {
- qemu_chr_fe_set_handlers(&s->chr_in, NULL, NULL, NULL, NULL, NULL);
+ qemu_chr_fe_set_handlers(&s->chr_in, NULL, NULL, NULL,
+ NULL, NULL, true);
}
}
switch (event) {
case CHR_EVENT_CLOSED:
- qemu_chr_fe_set_handlers(&s->chr_in, NULL, NULL, NULL, NULL, NULL);
+ qemu_chr_fe_set_handlers(&s->chr_in, NULL, NULL, NULL,
+ NULL, NULL, true);
break;
default:
break;
qemu_chr_fe_set_handlers(&s->chr_in, redirector_chr_can_read,
redirector_chr_read, redirector_chr_event,
- nf, NULL);
+ nf, NULL, true);
}
if (s->outdev) {
fwd->slirp = s->slirp;
qemu_chr_fe_set_handlers(&fwd->hd, guestfwd_can_read, guestfwd_read,
- NULL, fwd, NULL);
+ NULL, fwd, NULL, true);
}
return 0;
return -1;
}
qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
- net_vhost_user_event, nc0->name, NULL);
+ net_vhost_user_event, nc0->name, NULL, true);
} while (!s->started);
assert(s->vhost_net);
mux_chr_read,
mux_chr_event,
chr,
- context);
+ context, true);
}
static void mux_set_focus(MuxDriver *d, int focus)
assert(b);
if (b->chr) {
- qemu_chr_fe_set_handlers(b, NULL, NULL, NULL, NULL, NULL);
+ qemu_chr_fe_set_handlers(b, NULL, NULL, NULL, NULL, NULL, true);
b->chr->avail_connections++;
b->chr->be = NULL;
if (b->chr->is_mux) {
IOReadHandler *fd_read,
IOEventHandler *fd_event,
void *opaque,
- GMainContext *context)
+ GMainContext *context,
+ bool set_open)
{
CharDriverState *s;
int fe_open;
s->chr_update_read_handler(s, context);
}
- if (!s->explicit_fe_open) {
+ if (set_open) {
qemu_chr_fe_set_open(b, fe_open);
}
qemu_chr_fe_init(&qtest_chr, chr, errp);
qemu_chr_fe_set_handlers(&qtest_chr, qtest_can_read, qtest_read,
- qtest_event, &qtest_chr, NULL);
+ qtest_event, &qtest_chr, NULL, true);
qemu_chr_fe_set_echo(&qtest_chr, true);
inbuf = g_string_new("");
fe_read,
fe_event,
&h1,
- NULL);
+ NULL, true);
qemu_chr_fe_init(&chr_be2, chr, &error_abort);
qemu_chr_fe_set_handlers(&chr_be2,
fe_read,
fe_event,
&h2,
- NULL);
+ NULL, true);
qemu_chr_fe_take_focus(&chr_be2);
base = qemu_chr_find("mux-label-base");
h1.read_count = 0;
/* remove first handler */
- qemu_chr_fe_set_handlers(&chr_be1, NULL, NULL, NULL, NULL, NULL);
+ qemu_chr_fe_set_handlers(&chr_be1, NULL, NULL, NULL, NULL, NULL, true);
qemu_chr_be_write(base, (void *)"hello", 6);
g_assert_cmpint(h1.read_count, ==, 0);
g_assert_cmpint(h2.read_count, ==, 0);
fe_can_read,
fe_read,
fe_event,
- NULL, NULL);
+ NULL, NULL, true);
ret = qemu_chr_fe_write(&be, (void *)"buf", 4);
g_assert_cmpint(ret, ==, 4);
qemu_chr_fe_init(&server->chr, chr, &error_abort);
qemu_chr_fe_set_handlers(&server->chr, chr_can_read, chr_read,
- chr_event, server, NULL);
+ chr_event, server, NULL, true);
}
static void test_server_listen(TestServer *server)