chardev: mark explicitly first argument as poisoned

Since commit 9894dc0cdc "char: convert
from GIOChannel to QIOChannel", the first argument to the watch callback
can actually be a QIOChannel, which is not a GIOChannel (but a QEMU
Object).

Even though we never used that pointer, change the callback type to warn
the users. Possibly a better fix later, we may want to store the
callback and call it from intermediary functions.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
stable-6.1
Marc-André Lureau 2021-08-04 17:01:14 +04:00
parent 30f80be34b
commit bf7b1eab25
12 changed files with 19 additions and 13 deletions

View File

@ -354,7 +354,7 @@ void qemu_chr_fe_set_open(CharBackend *be, int fe_open)
} }
guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond, guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
GIOFunc func, void *user_data) FEWatchFunc func, void *user_data)
{ {
Chardev *s = be->chr; Chardev *s = be->chr;
GSource *src; GSource *src;

View File

@ -288,7 +288,7 @@ static void uart_write_rx_fifo(void *opaque, const uint8_t *buf, int size)
uart_update_status(s); uart_update_status(s);
} }
static gboolean cadence_uart_xmit(GIOChannel *chan, GIOCondition cond, static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond,
void *opaque) void *opaque)
{ {
CadenceUARTState *s = opaque; CadenceUARTState *s = opaque;

View File

@ -191,7 +191,7 @@ static uint64_t uart_read(void *opaque, hwaddr offset, unsigned size)
/* Try to send tx data, and arrange to be called back later if /* Try to send tx data, and arrange to be called back later if
* we can't (ie the char backend is busy/blocking). * we can't (ie the char backend is busy/blocking).
*/ */
static gboolean uart_transmit(GIOChannel *chan, GIOCondition cond, void *opaque) static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
{ {
CMSDKAPBUART *s = CMSDK_APB_UART(opaque); CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
int ret; int ret;

View File

@ -135,7 +135,7 @@ static void ibex_uart_receive(void *opaque, const uint8_t *buf, int size)
ibex_uart_update_irqs(s); ibex_uart_update_irqs(s);
} }
static gboolean ibex_uart_xmit(GIOChannel *chan, GIOCondition cond, static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
void *opaque) void *opaque)
{ {
IbexUartState *s = opaque; IbexUartState *s = opaque;

View File

@ -75,7 +75,7 @@ static uint64_t uart_read(void *opaque, hwaddr addr, unsigned int size)
return r; return r;
} }
static gboolean uart_transmit(GIOChannel *chan, GIOCondition cond, void *opaque) static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
{ {
NRF51UARTState *s = NRF51_UART(opaque); NRF51UARTState *s = NRF51_UART(opaque);
int r; int r;

View File

@ -220,7 +220,7 @@ static void serial_update_msl(SerialState *s)
} }
} }
static gboolean serial_watch_cb(GIOChannel *chan, GIOCondition cond, static gboolean serial_watch_cb(void *do_not_use, GIOCondition cond,
void *opaque) void *opaque)
{ {
SerialState *s = opaque; SerialState *s = opaque;

View File

@ -38,7 +38,7 @@ struct VirtConsole {
* Callback function that's called from chardevs when backend becomes * Callback function that's called from chardevs when backend becomes
* writable. * writable.
*/ */
static gboolean chr_write_unblocked(GIOChannel *chan, GIOCondition cond, static gboolean chr_write_unblocked(void *do_not_use, GIOCondition cond,
void *opaque) void *opaque)
{ {
VirtConsole *vcon = opaque; VirtConsole *vcon = opaque;

View File

@ -270,7 +270,7 @@ static int usbredir_read(void *priv, uint8_t *data, int count)
return count; return count;
} }
static gboolean usbredir_write_unblocked(GIOChannel *chan, GIOCondition cond, static gboolean usbredir_write_unblocked(void *do_not_use, GIOCondition cond,
void *opaque) void *opaque)
{ {
USBRedirDevice *dev = opaque; USBRedirDevice *dev = opaque;

View File

@ -303,7 +303,7 @@ struct vhost_user_read_cb_data {
int ret; int ret;
}; };
static gboolean vhost_user_read_cb(GIOChannel *source, GIOCondition condition, static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
gpointer opaque) gpointer opaque)
{ {
struct vhost_user_read_cb_data *data = opaque; struct vhost_user_read_cb_data *data = opaque;

View File

@ -174,6 +174,9 @@ void qemu_chr_fe_set_open(CharBackend *be, int fe_open);
void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...) void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
GCC_FMT_ATTR(2, 3); GCC_FMT_ATTR(2, 3);
typedef gboolean (*FEWatchFunc)(void *do_not_use, GIOCondition condition, void *data);
/** /**
* qemu_chr_fe_add_watch: * qemu_chr_fe_add_watch:
* @cond: the condition to poll for * @cond: the condition to poll for
@ -188,10 +191,13 @@ void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
* Note that you are responsible to update the front-end sources if * Note that you are responsible to update the front-end sources if
* you are switching the main context with qemu_chr_fe_set_handlers(). * you are switching the main context with qemu_chr_fe_set_handlers().
* *
* Warning: DO NOT use the first callback argument (it may be either
* a GIOChannel or a QIOChannel, depending on the underlying chardev)
*
* Returns: the source tag * Returns: the source tag
*/ */
guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond, guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
GIOFunc func, void *user_data); FEWatchFunc func, void *user_data);
/** /**
* qemu_chr_fe_write: * qemu_chr_fe_write:

View File

@ -156,7 +156,7 @@ static inline bool monitor_is_hmp_non_interactive(const Monitor *mon)
static void monitor_flush_locked(Monitor *mon); static void monitor_flush_locked(Monitor *mon);
static gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond, static gboolean monitor_unblocked(void *do_not_use, GIOCondition cond,
void *opaque) void *opaque)
{ {
Monitor *mon = opaque; Monitor *mon = opaque;

View File

@ -208,8 +208,8 @@ static NetClientInfo net_vhost_user_info = {
.set_vnet_le = vhost_user_set_vnet_endianness, .set_vnet_le = vhost_user_set_vnet_endianness,
}; };
static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond, static gboolean net_vhost_user_watch(void *do_not_use, GIOCondition cond,
void *opaque) void *opaque)
{ {
NetVhostUserState *s = opaque; NetVhostUserState *s = opaque;