diff --git a/backends/rng-egd.c b/backends/rng-egd.c index 433f583f78fba4994d2004799708b95da3a0868b..69c04b1b26d2ea08c27e53718df1ebb58bce795d 100644 --- a/backends/rng-egd.c +++ b/backends/rng-egd.c @@ -106,7 +106,7 @@ static void rng_egd_opened(RngBackend *b, Error **errp) /* 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) diff --git a/gdbstub.c b/gdbstub.c index 59444949245579067bf59b6583ba7a8ed97da810..b2e1b79ca35b2d3e8a78524e4fdcd5041a542051 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1779,7 +1779,7 @@ int gdbserver_start(const char *device) 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; diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c index c9f4503481716e1058bc1f3ef8764861ddf0c279..42cdde0478fbca7c12581e58ca67d5e2f0aa35e0 100644 --- a/hw/arm/pxa2xx.c +++ b/hw/arm/pxa2xx.c @@ -1976,7 +1976,7 @@ static void pxa2xx_fir_realize(DeviceState *dev, Error **errp) 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) diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c index 370198a8892a2c1c6aaff504c6018e9abf0f7bcd..85db1e2813ed69561244e478204bbcf2e6284186 100644 --- a/hw/arm/strongarm.c +++ b/hw/arm/strongarm.c @@ -1241,7 +1241,7 @@ static void strongarm_uart_init(Object *obj) strongarm_uart_can_receive, strongarm_uart_receive, strongarm_uart_event, - s, NULL); + s, NULL, true); } static void strongarm_uart_reset(DeviceState *dev) diff --git a/hw/char/bcm2835_aux.c b/hw/char/bcm2835_aux.c index af329aab5077e908ba447a37630e06482232105f..4d46ad60aed22e42a924e5bd12e2d63c29a54774 100644 --- a/hw/char/bcm2835_aux.c +++ b/hw/char/bcm2835_aux.c @@ -279,7 +279,7 @@ static void bcm2835_aux_realize(DeviceState *dev, Error **errp) 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[] = { diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 291818e0e1591c121a89878ee00712be0743062a..c2b9154305de252191cc96174cbd7e57dc96e5bd 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -467,7 +467,7 @@ static void cadence_uart_realize(DeviceState *dev, Error **errp) 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) diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c index 2009c3e844b9e4d5ee74b70fdefb60339f24159b..80dce07e7f106582ad86e2535b671221bb7fb58e 100644 --- a/hw/char/debugcon.c +++ b/hw/char/debugcon.c @@ -92,7 +92,7 @@ static void debugcon_realize_core(DebugconState *s, Error **errp) 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) diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c index 2955e19f67e4b86fa479217d159c15d8b639754a..029f5bbf5eeba0fe666164a6e0dc4dfc3e453f1e 100644 --- a/hw/char/digic-uart.c +++ b/hw/char/digic-uart.c @@ -146,7 +146,7 @@ static void digic_uart_realize(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) diff --git a/hw/char/escc.c b/hw/char/escc.c index c71b0a8e56c68ca9975de6361b53018e90c1961e..d6662dc77d4e2c0ee3a10aeafdfc6c50eb075d28 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -1016,7 +1016,7 @@ static void escc_realize(DeviceState *dev, Error **errp) 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); } } diff --git a/hw/char/etraxfs_ser.c b/hw/char/etraxfs_ser.c index 18c374b95c7fe39c4b6e8ae66298cbf23a6955d9..54383878e03d9ed880e0379877d0ef4667da1aae 100644 --- a/hw/char/etraxfs_ser.c +++ b/hw/char/etraxfs_ser.c @@ -233,7 +233,7 @@ static void etraxfs_ser_realize(DeviceState *dev, Error **errp) 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) diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c index 48216b1863e1a72a8622312cb937f62d580d2a7d..571c3240047d2dc9acf7485059319d6b63db6166 100644 --- a/hw/char/exynos4210_uart.c +++ b/hw/char/exynos4210_uart.c @@ -642,7 +642,7 @@ static int exynos4210_uart_init(SysBusDevice *dev) qemu_chr_fe_set_handlers(&s->chr, exynos4210_uart_can_receive, exynos4210_uart_receive, exynos4210_uart_event, - s, NULL); + s, NULL, true); return 0; } diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c index e50d65b9f667f4542d0e7aeec91233d423264604..db686e6a6fdcdc281da4f3bc05bf43ec87706170 100644 --- a/hw/char/grlib_apbuart.c +++ b/hw/char/grlib_apbuart.c @@ -247,7 +247,7 @@ static int grlib_apbuart_init(SysBusDevice *dev) grlib_apbuart_can_receive, grlib_apbuart_receive, grlib_apbuart_event, - uart, NULL); + uart, NULL, true); sysbus_init_irq(dev, &uart->irq); diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c index 8dbb7b26e6689a036c649e1cf59a1f4a39aae3a1..99545fc359ebde673123754e63745f8051e15d49 100644 --- a/hw/char/imx_serial.c +++ b/hw/char/imx_serial.c @@ -316,7 +316,7 @@ static void imx_serial_realize(DeviceState *dev, Error **errp) 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) diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c index 6f150e09fb0ccdbf365b8f63feabb1fca437dc50..93929c2880566e1592d60dd79ccf7a2d3214af1c 100644 --- a/hw/char/ipoctal232.c +++ b/hw/char/ipoctal232.c @@ -544,7 +544,8 @@ static void ipoctal_realize(DeviceState *dev, Error **errp) /* 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); diff --git a/hw/char/lm32_juart.c b/hw/char/lm32_juart.c index febb41213f76798a7b9d307546d5bcc215f24e48..f8c1e0d076ffd5b23b35681a2021c16f20392c3c 100644 --- a/hw/char/lm32_juart.c +++ b/hw/char/lm32_juart.c @@ -119,7 +119,7 @@ static void lm32_juart_realize(DeviceState *dev, Error **errp) 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 = { diff --git a/hw/char/lm32_uart.c b/hw/char/lm32_uart.c index 1b2746f487cedba421b556199ab6da0a0ce95f31..7f3597c4b0abc83a4063500b483bdc8d1d76f001 100644 --- a/hw/char/lm32_uart.c +++ b/hw/char/lm32_uart.c @@ -266,7 +266,7 @@ static void lm32_uart_realize(DeviceState *dev, Error **errp) 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 = { diff --git a/hw/char/mcf_uart.c b/hw/char/mcf_uart.c index 456591ac2f229233cc04bf754ef8a73b3eeb8397..ecaa0911901d40b2c5d0346e4c11bdae4af1dab6 100644 --- a/hw/char/mcf_uart.c +++ b/hw/char/mcf_uart.c @@ -284,7 +284,8 @@ void *mcf_uart_init(qemu_irq irq, CharDriverState *chr) 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; diff --git a/hw/char/milkymist-uart.c b/hw/char/milkymist-uart.c index dec0a8c8df88502b9fc9922e9b30307f34a75afc..ae8e2f35546af398940bce9a134c9c89dc37397f 100644 --- a/hw/char/milkymist-uart.c +++ b/hw/char/milkymist-uart.c @@ -199,7 +199,7 @@ static void milkymist_uart_realize(DeviceState *dev, Error **errp) 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) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 900ee5db9f474544d640e687496aac2afdac3ea1..24ea9738b62b78f6465fc8db6e22d50cc72d3715 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -329,7 +329,7 @@ static void pl011_realize(DeviceState *dev, Error **errp) 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) diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index 7191717c7d8f76f1338c7bf7bdc9bacb5e714c44..07d6ebd112b974ad4711c23777fa0140d557531b 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -313,7 +313,7 @@ static int console_init(SCLPEvent *event) 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; } diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c index 27a60343d89fb16ef5d2252065ac236332451d62..b78f240a73df9d6aa244cc1c91d644f7df62774a 100644 --- a/hw/char/sclpconsole.c +++ b/hw/char/sclpconsole.c @@ -228,7 +228,7 @@ static int console_init(SCLPEvent *event) } 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; } diff --git a/hw/char/serial.c b/hw/char/serial.c index 54f80c6e915713c67559b0e518c06dd7acde9c18..ffbacd822708ea474bcd9a29d1678c7f3ee715f5 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -897,7 +897,7 @@ void serial_realize_core(SerialState *s, Error **errp) 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); diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c index 8bb45db63457aab7053c51ec19e9e8fe9540616b..9d35564bcf583343b7096a985776be88b76059d0 100644 --- a/hw/char/sh_serial.c +++ b/hw/char/sh_serial.c @@ -400,7 +400,7 @@ void sh_serial_init(MemoryRegion *sysmem, 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; diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c index 8d39d40a4d3a6e0503c363bb419dbef6af08e25f..31822fed9a21805df4b6d2fab04d78bebec5fbe2 100644 --- a/hw/char/spapr_vty.c +++ b/hw/char/spapr_vty.c @@ -75,7 +75,7 @@ static void spapr_vty_realize(VIOsPAPRDevice *sdev, Error **errp) } qemu_chr_fe_set_handlers(&dev->chardev, vty_can_receive, - vty_receive, NULL, dev, NULL); + vty_receive, NULL, dev, NULL, true); } /* Forward declaration */ diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c index 8e9852b032419db78692b9634816b72258daefbb..59872e6d3bb98a4bc44171236723e1b0633a18e6 100644 --- a/hw/char/stm32f2xx_usart.c +++ b/hw/char/stm32f2xx_usart.c @@ -207,7 +207,7 @@ static void stm32f2xx_usart_realize(DeviceState *dev, Error **errp) 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) diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index 378c1c1c4512aaa2b8f4971336cf9d5a72f23a8d..776205b4a95b6f14c5dc3949daf485209a7a1480 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -187,14 +187,12 @@ static void virtconsole_realize(DeviceState *dev, Error **errp) * 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); } } } diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index 785bf8616e1cfe2b5d641f4d12f7f67a7a78c826..86cdc529a34d8b6173d087c9972ecbfc35f95641 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -245,7 +245,7 @@ static int con_initialise(struct XenDevice *xendev) 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, diff --git a/hw/char/xilinx_uartlite.c b/hw/char/xilinx_uartlite.c index c7888f72921219cd8a445d7c1985a26a861e0a40..37d313b4295d0b6ccde88bac2705a336e06d49bf 100644 --- a/hw/char/xilinx_uartlite.c +++ b/hw/char/xilinx_uartlite.c @@ -212,7 +212,7 @@ static void xilinx_uartlite_realize(DeviceState *dev, Error **errp) 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) diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c index 5530870d1af9ff24ec0c70ed3b44fe6247a24798..4b310e5efff54c6b4fcdad287971db24b6ca7d81 100644 --- a/hw/ipmi/ipmi_bmc_extern.c +++ b/hw/ipmi/ipmi_bmc_extern.c @@ -448,7 +448,7 @@ static void ipmi_bmc_extern_realize(DeviceState *dev, Error **errp) } 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) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 273ec6d79a6c3131eea4e19e4491e65aa1bf50ae..cf9bd3eb45e1665ccaeda7b1f7e56272ede956ee 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -572,7 +572,7 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space, 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); diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index bb70704e35a94688d225a4b1cb3ba7a1e94542d3..230e51b6e057d3c4cf6b96a226d46c8b1e49dd0a 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -895,7 +895,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp) } 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"); diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index 369a8f108bf601b2216067ceec59ebe31eae9821..1faef0e35edd667539f965ce48609deb8f6522b7 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -353,7 +353,7 @@ static int passthru_initfn(CCIDCardState *base) 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"); diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index a69b9a3cc499570b28b939dfd3af631c26fa4a63..ef1e1ade60264d13624f5c8041e1899e56d93f3e 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -503,7 +503,7 @@ static void usb_serial_realize(USBDevice *dev, Error **errp) } 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) { diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 6f5ad2049c4367c506b5f1cf5b8fc99d931aa259..528081e581cfa75f265bf04ebcf1e2b66d4c9967 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1409,7 +1409,7 @@ static void usbredir_realize(USBDevice *udev, Error **errp) /* 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); } diff --git a/include/sysemu/char.h b/include/sysemu/char.h index d029d544fe5131e504c9dcc4742826fae6aeca02..ae32e1ce25fb680bdfca7cf0556a89176de06106 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -109,7 +109,6 @@ struct CharDriverState { int logfd; int be_open; int fe_open; - int explicit_fe_open; int explicit_be_open; int avail_connections; int is_mux; @@ -449,6 +448,8 @@ void qemu_chr_fe_deinit(CharBackend *b); * @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. @@ -460,7 +461,8 @@ void qemu_chr_fe_set_handlers(CharBackend *b, IOReadHandler *fd_read, IOEventHandler *fd_event, void *opaque, - GMainContext *context); + GMainContext *context, + bool set_open); /** * @qemu_chr_fe_take_focus: diff --git a/monitor.c b/monitor.c index 5c349c5bf5cb35cb904b77959dadd0aeb803e006..b73a999b22444cc832ce20182fabc73815e12cac 100644 --- a/monitor.c +++ b/monitor.c @@ -3988,12 +3988,12 @@ void monitor_init(CharDriverState *chr, int flags) 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); diff --git a/net/colo-compare.c b/net/colo-compare.c index 308368164cdf74fc38b81427497f91b53210f344..109990fd8ec85083493c2a8c0524ab97c8dec0fd 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -451,7 +451,8 @@ static void compare_pri_chr_in(void *opaque, const uint8_t *buf, int size) 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"); } } @@ -467,7 +468,8 @@ static void compare_sec_chr_in(void *opaque, const uint8_t *buf, int size) 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"); } } @@ -481,9 +483,9 @@ static void *colo_compare_thread(void *opaque) 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); diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 1864c818d5fc7a6b5bf783520f4ea94049682864..b7d645617c9759aa03cf1a177db27d6f73d6be7e 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -110,7 +110,8 @@ static void redirector_chr_read(void *opaque, const uint8_t *buf, int size) 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); } } @@ -121,7 +122,8 @@ static void redirector_chr_event(void *opaque, int event) 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; @@ -248,7 +250,7 @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp) 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) { diff --git a/net/slirp.c b/net/slirp.c index 0e675354a40a4c664fd6deb4ff27b3ff34edbb1c..64dd3255aefbd3466ff9e6c0a9be495929c0f9dd 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -775,7 +775,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, 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; diff --git a/net/vhost-user.c b/net/vhost-user.c index 140a4e0bde1e7b15651d1babb3b81ec8414498c1..7aff77ee4a8c73a161f3739e4ab9364b4217bdc9 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -266,7 +266,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, 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); diff --git a/qemu-char.c b/qemu-char.c index af060ceb64886717b372c174437677c21a4c1f64..a1517a4e4c8f825d0d4a31b8b41294d3e26ed91a 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -832,7 +832,7 @@ static void mux_chr_set_handlers(CharDriverState *chr, GMainContext *context) mux_chr_read, mux_chr_event, chr, - context); + context, true); } static void mux_set_focus(MuxDriver *d, int focus) @@ -931,7 +931,7 @@ void qemu_chr_fe_deinit(CharBackend *b) 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) { @@ -947,7 +947,8 @@ void qemu_chr_fe_set_handlers(CharBackend *b, IOReadHandler *fd_read, IOEventHandler *fd_event, void *opaque, - GMainContext *context) + GMainContext *context, + bool set_open) { CharDriverState *s; int fe_open; @@ -971,7 +972,7 @@ void qemu_chr_fe_set_handlers(CharBackend *b, s->chr_update_read_handler(s, context); } - if (!s->explicit_fe_open) { + if (set_open) { qemu_chr_fe_set_open(b, fe_open); } diff --git a/qtest.c b/qtest.c index 1a6c8b15aae24297a50c2ac9e382c702b7a9a470..46b99aed5291c827bde5ea3857d7d3cfb7cd55e4 100644 --- a/qtest.c +++ b/qtest.c @@ -688,7 +688,7 @@ void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp) 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(""); diff --git a/tests/test-char.c b/tests/test-char.c index 13c55b846c369e0a6c01cdce0eca1fbb73ba486d..241685afbb9d4dac474db122e64cbab5e2b8bae4 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -129,7 +129,7 @@ static void char_mux_test(void) fe_read, fe_event, &h1, - NULL); + NULL, true); qemu_chr_fe_init(&chr_be2, chr, &error_abort); qemu_chr_fe_set_handlers(&chr_be2, @@ -137,7 +137,7 @@ static void char_mux_test(void) fe_read, fe_event, &h2, - NULL); + NULL, true); qemu_chr_fe_take_focus(&chr_be2); base = qemu_chr_find("mux-label-base"); @@ -159,7 +159,7 @@ static void char_mux_test(void) 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); @@ -216,7 +216,7 @@ static void char_null_test(void) 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); diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 24c232315268f0d3895f1dff3afb8d13e4a651bc..a7f06291cb11b63fdf9eafb3639be382218bdc5a 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -464,7 +464,7 @@ static void test_server_create_chr(TestServer *server, const gchar *opt) 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)