qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

chardev: Use QEMUChrEvent enum in IOEventHandler typedef

The Chardev events are listed in the QEMUChrEvent enum.

By using the enum in the IOEventHandler typedef we:

- make the IOEventHandler type more explicit (this handler
process out-of-band information, while the IOReadHandler
is in-band),
- help static code analyzers.

This patch was produced with the following spatch script:

@match@
expression backend, opaque, context, set_open;
identifier fd_can_read, fd_read, fd_event, be_change;
@@
qemu_chr_fe_set_handlers(backend, fd_can_read, fd_read, fd_event,
be_change, opaque, context, set_open);

@depends on match@
identifier opaque, event;
identifier match.fd_event;
@@
static
-void fd_event(void *opaque, int event)
+void fd_event(void *opaque, QEMUChrEvent event)
{
...
}

Then the typedef was modified manually in
include/chardev/char-fe.h.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191218172009.8868-15-philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Philippe Mathieu-Daudé and committed by
Paolo Bonzini
083b266f 2fa9044a

+44 -44
+1 -1
backends/cryptodev-vhost-user.c
··· 152 152 return chr; 153 153 } 154 154 155 - static void cryptodev_vhost_user_event(void *opaque, int event) 155 + static void cryptodev_vhost_user_event(void *opaque, QEMUChrEvent event) 156 156 { 157 157 CryptoDevBackendVhostUser *s = opaque; 158 158 CryptoDevBackend *b = CRYPTODEV_BACKEND(s);
+1 -1
chardev/char-mux.c
··· 247 247 } 248 248 } 249 249 250 - static void mux_chr_event(void *opaque, int event) 250 + static void mux_chr_event(void *opaque, QEMUChrEvent event) 251 251 { 252 252 mux_chr_send_all_event(CHARDEV(opaque), event); 253 253 }
+1 -1
gdbstub.c
··· 3171 3171 } 3172 3172 } 3173 3173 3174 - static void gdb_chr_event(void *opaque, int event) 3174 + static void gdb_chr_event(void *opaque, QEMUChrEvent event) 3175 3175 { 3176 3176 int i; 3177 3177 GDBState *s = (GDBState *) opaque;
+1 -1
hw/arm/pxa2xx.c
··· 1955 1955 pxa2xx_fir_update(s); 1956 1956 } 1957 1957 1958 - static void pxa2xx_fir_event(void *opaque, int event) 1958 + static void pxa2xx_fir_event(void *opaque, QEMUChrEvent event) 1959 1959 { 1960 1960 } 1961 1961
+1 -1
hw/arm/strongarm.c
··· 1093 1093 strongarm_uart_update_int_status(s); 1094 1094 } 1095 1095 1096 - static void strongarm_uart_event(void *opaque, int event) 1096 + static void strongarm_uart_event(void *opaque, QEMUChrEvent event) 1097 1097 { 1098 1098 StrongARMUARTState *s = opaque; 1099 1099 if (event == CHR_EVENT_BREAK) {
+1 -1
hw/block/vhost-user-blk.c
··· 361 361 return true; 362 362 } 363 363 364 - static void vhost_user_blk_event(void *opaque, int event) 364 + static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) 365 365 { 366 366 DeviceState *dev = opaque; 367 367 VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+1 -1
hw/char/cadence_uart.c
··· 348 348 } 349 349 } 350 350 351 - static void uart_event(void *opaque, int event) 351 + static void uart_event(void *opaque, QEMUChrEvent event) 352 352 { 353 353 CadenceUARTState *s = opaque; 354 354 uint8_t buf = '\0';
+1 -1
hw/char/digic-uart.c
··· 131 131 s->reg_rx = *buf; 132 132 } 133 133 134 - static void uart_event(void *opaque, int event) 134 + static void uart_event(void *opaque, QEMUChrEvent event) 135 135 { 136 136 } 137 137
+1 -1
hw/char/escc.c
··· 634 634 serial_receive_byte(s, buf[0]); 635 635 } 636 636 637 - static void serial_event(void *opaque, int event) 637 + static void serial_event(void *opaque, QEMUChrEvent event) 638 638 { 639 639 ESCCChannelState *s = opaque; 640 640 if (event == CHR_EVENT_BREAK)
+1 -1
hw/char/etraxfs_ser.c
··· 202 202 return sizeof(s->rx_fifo) - s->rx_fifo_len; 203 203 } 204 204 205 - static void serial_event(void *opaque, int event) 205 + static void serial_event(void *opaque, QEMUChrEvent event) 206 206 { 207 207 208 208 }
+1 -1
hw/char/exynos4210_uart.c
··· 528 528 } 529 529 530 530 531 - static void exynos4210_uart_event(void *opaque, int event) 531 + static void exynos4210_uart_event(void *opaque, QEMUChrEvent event) 532 532 { 533 533 Exynos4210UartState *s = (Exynos4210UartState *)opaque; 534 534
+1 -1
hw/char/grlib_apbuart.c
··· 155 155 } 156 156 } 157 157 158 - static void grlib_apbuart_event(void *opaque, int event) 158 + static void grlib_apbuart_event(void *opaque, QEMUChrEvent event) 159 159 { 160 160 trace_grlib_apbuart_event(event); 161 161 }
+1 -1
hw/char/imx_serial.c
··· 323 323 imx_put_data(opaque, *buf); 324 324 } 325 325 326 - static void imx_event(void *opaque, int event) 326 + static void imx_event(void *opaque, QEMUChrEvent event) 327 327 { 328 328 if (event == CHR_EVENT_BREAK) { 329 329 imx_put_data(opaque, URXD_BRK | URXD_FRMERR | URXD_ERR);
+1 -1
hw/char/ipoctal232.c
··· 503 503 } 504 504 } 505 505 506 - static void hostdev_event(void *opaque, int event) 506 + static void hostdev_event(void *opaque, QEMUChrEvent event) 507 507 { 508 508 SCC2698Channel *ch = opaque; 509 509 switch (event) {
+1 -1
hw/char/lm32_juart.c
··· 104 104 return !(s->jrx & JRX_FULL); 105 105 } 106 106 107 - static void juart_event(void *opaque, int event) 107 + static void juart_event(void *opaque, QEMUChrEvent event) 108 108 { 109 109 } 110 110
+1 -1
hw/char/lm32_uart.c
··· 235 235 return !(s->regs[R_LSR] & LSR_DR); 236 236 } 237 237 238 - static void uart_event(void *opaque, int event) 238 + static void uart_event(void *opaque, QEMUChrEvent event) 239 239 { 240 240 } 241 241
+1 -1
hw/char/mcf_uart.c
··· 256 256 mcf_uart_update(s); 257 257 } 258 258 259 - static void mcf_uart_event(void *opaque, int event) 259 + static void mcf_uart_event(void *opaque, QEMUChrEvent event) 260 260 { 261 261 mcf_uart_state *s = (mcf_uart_state *)opaque; 262 262
+1 -1
hw/char/milkymist-uart.c
··· 180 180 return !(s->regs[R_STAT] & STAT_RX_EVT); 181 181 } 182 182 183 - static void uart_event(void *opaque, int event) 183 + static void uart_event(void *opaque, QEMUChrEvent event) 184 184 { 185 185 } 186 186
+1 -1
hw/char/nrf51_uart.c
··· 245 245 return s->rx_started ? (UART_FIFO_LENGTH - s->rx_fifo_len) : 0; 246 246 } 247 247 248 - static void uart_event(void *opaque, int event) 248 + static void uart_event(void *opaque, QEMUChrEvent event) 249 249 { 250 250 NRF51UARTState *s = NRF51_UART(opaque); 251 251
+1 -1
hw/char/pl011.c
··· 280 280 pl011_put_fifo(opaque, *buf); 281 281 } 282 282 283 - static void pl011_event(void *opaque, int event) 283 + static void pl011_event(void *opaque, QEMUChrEvent event) 284 284 { 285 285 if (event == CHR_EVENT_BREAK) 286 286 pl011_put_fifo(opaque, 0x400);
+1 -1
hw/char/serial.c
··· 634 634 serial_update_irq(s); 635 635 } 636 636 637 - static void serial_event(void *opaque, int event) 637 + static void serial_event(void *opaque, QEMUChrEvent event) 638 638 { 639 639 SerialState *s = opaque; 640 640 DPRINTF("event %x\n", event);
+1 -1
hw/char/sh_serial.c
··· 358 358 } 359 359 } 360 360 361 - static void sh_serial_event(void *opaque, int event) 361 + static void sh_serial_event(void *opaque, QEMUChrEvent event) 362 362 { 363 363 sh_serial_state *s = opaque; 364 364 if (event == CHR_EVENT_BREAK)
+1 -1
hw/char/terminal3270.c
··· 142 142 } 143 143 } 144 144 145 - static void chr_event(void *opaque, int event) 145 + static void chr_event(void *opaque, QEMUChrEvent event) 146 146 { 147 147 Terminal3270 *t = opaque; 148 148 CcwDevice *ccw_dev = CCW_DEVICE(t);
+1 -1
hw/char/virtio-console.c
··· 145 145 virtio_serial_write(port, buf, size); 146 146 } 147 147 148 - static void chr_event(void *opaque, int event) 148 + static void chr_event(void *opaque, QEMUChrEvent event) 149 149 { 150 150 VirtConsole *vcon = opaque; 151 151 VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(vcon);
+1 -1
hw/char/xilinx_uartlite.c
··· 206 206 return s->rx_fifo_len < sizeof(s->rx_fifo); 207 207 } 208 208 209 - static void uart_event(void *opaque, int event) 209 + static void uart_event(void *opaque, QEMUChrEvent event) 210 210 { 211 211 212 212 }
+1 -1
hw/ipmi/ipmi_bmc_extern.c
··· 379 379 handle_hw_op(ibe, hw_op); 380 380 } 381 381 382 - static void chr_event(void *opaque, int event) 382 + static void chr_event(void *opaque, QEMUChrEvent event) 383 383 { 384 384 IPMIBmcExtern *ibe = opaque; 385 385 IPMIInterface *s = ibe->parent.intf;
+1 -1
hw/mips/boston.c
··· 98 98 PLAT_SYS_CTL = 0x48, 99 99 }; 100 100 101 - static void boston_lcd_event(void *opaque, int event) 101 + static void boston_lcd_event(void *opaque, QEMUChrEvent event) 102 102 { 103 103 BostonState *s = opaque; 104 104 if (event == CHR_EVENT_OPENED && !s->lcd_inited) {
+1 -1
hw/mips/mips_malta.c
··· 545 545 snprintf(s->display_text, 9, " "); 546 546 } 547 547 548 - static void malta_fgpa_display_event(void *opaque, int event) 548 + static void malta_fgpa_display_event(void *opaque, QEMUChrEvent event) 549 549 { 550 550 MaltaFPGAState *s = opaque; 551 551
+1 -1
hw/riscv/riscv_htif.c
··· 96 96 * Called by the char dev to supply special events to the HTIF console. 97 97 * Not used for HTIF. 98 98 */ 99 - static void htif_event(void *opaque, int event) 99 + static void htif_event(void *opaque, QEMUChrEvent event) 100 100 { 101 101 102 102 }
+1 -1
hw/riscv/sifive_uart.c
··· 162 162 return s->rx_fifo_len < sizeof(s->rx_fifo); 163 163 } 164 164 165 - static void uart_event(void *opaque, int event) 165 + static void uart_event(void *opaque, QEMUChrEvent event) 166 166 { 167 167 } 168 168
+1 -1
hw/usb/ccid-card-passthru.c
··· 307 307 } 308 308 } 309 309 310 - static void ccid_card_vscard_event(void *opaque, int event) 310 + static void ccid_card_vscard_event(void *opaque, QEMUChrEvent event) 311 311 { 312 312 PassthruState *card = opaque; 313 313
+1 -1
hw/usb/dev-serial.c
··· 461 461 s->recv_used += size; 462 462 } 463 463 464 - static void usb_serial_event(void *opaque, int event) 464 + static void usb_serial_event(void *opaque, QEMUChrEvent event) 465 465 { 466 466 USBSerialState *s = opaque; 467 467
+1 -1
hw/usb/redirect.c
··· 1354 1354 usbredirparser_do_write(dev->parser); 1355 1355 } 1356 1356 1357 - static void usbredir_chardev_event(void *opaque, int event) 1357 + static void usbredir_chardev_event(void *opaque, QEMUChrEvent event) 1358 1358 { 1359 1359 USBRedirDevice *dev = opaque; 1360 1360
+1 -1
include/chardev/char-fe.h
··· 4 4 #include "chardev/char.h" 5 5 #include "qemu/main-loop.h" 6 6 7 - typedef void IOEventHandler(void *opaque, int event); 7 + typedef void IOEventHandler(void *opaque, QEMUChrEvent event); 8 8 typedef int BackendChangeHandler(void *opaque); 9 9 10 10 /* This is the backend as seen by frontend, the actual backend is
+1 -1
monitor/hmp.c
··· 1322 1322 cur_mon = old_mon; 1323 1323 } 1324 1324 1325 - static void monitor_event(void *opaque, int event) 1325 + static void monitor_event(void *opaque, QEMUChrEvent event) 1326 1326 { 1327 1327 Monitor *mon = opaque; 1328 1328 MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
+1 -1
monitor/qmp.c
··· 337 337 ver, cap_list); 338 338 } 339 339 340 - static void monitor_qmp_event(void *opaque, int event) 340 + static void monitor_qmp_event(void *opaque, QEMUChrEvent event) 341 341 { 342 342 QDict *data; 343 343 MonitorQMP *mon = opaque;
+1 -1
net/filter-mirror.c
··· 132 132 } 133 133 } 134 134 135 - static void redirector_chr_event(void *opaque, int event) 135 + static void redirector_chr_event(void *opaque, QEMUChrEvent event) 136 136 { 137 137 NetFilterState *nf = opaque; 138 138 MirrorState *s = FILTER_REDIRECTOR(nf);
+2 -2
net/vhost-user.c
··· 218 218 return TRUE; 219 219 } 220 220 221 - static void net_vhost_user_event(void *opaque, int event); 221 + static void net_vhost_user_event(void *opaque, QEMUChrEvent event); 222 222 223 223 static void chr_closed_bh(void *opaque) 224 224 { ··· 249 249 } 250 250 } 251 251 252 - static void net_vhost_user_event(void *opaque, int event) 252 + static void net_vhost_user_event(void *opaque, QEMUChrEvent event) 253 253 { 254 254 const char *name = opaque; 255 255 NetClientState *ncs[MAX_QUEUE_NUM];
+1 -1
qtest.c
··· 722 722 return 1024; 723 723 } 724 724 725 - static void qtest_event(void *opaque, int event) 725 + static void qtest_event(void *opaque, QEMUChrEvent event) 726 726 { 727 727 int i; 728 728
+3 -3
tests/test-char.c
··· 54 54 quit = true; 55 55 } 56 56 57 - static void fe_event(void *opaque, int event) 57 + static void fe_event(void *opaque, QEMUChrEvent event) 58 58 { 59 59 FeHandler *h = opaque; 60 60 bool new_open_state; ··· 633 633 634 634 635 635 static void 636 - char_socket_event(void *opaque, int event) 636 + char_socket_event(void *opaque, QEMUChrEvent event) 637 637 { 638 638 CharSocketTestData *data = opaque; 639 639 data->event = event; ··· 1006 1006 } 1007 1007 1008 1008 static void 1009 - count_closed_event(void *opaque, int event) 1009 + count_closed_event(void *opaque, QEMUChrEvent event) 1010 1010 { 1011 1011 int *count = opaque; 1012 1012 if (event == CHR_EVENT_CLOSED) {
+1 -1
tests/vhost-user-test.c
··· 499 499 return server; 500 500 } 501 501 502 - static void chr_event(void *opaque, int event) 502 + static void chr_event(void *opaque, QEMUChrEvent event) 503 503 { 504 504 TestServer *s = opaque; 505 505