Skip to contentSkip to conversation

chardev/char-fe: Document FEWatchFunc and use G_SOURCE_CONTINUE/REMOVE

PATCH In review Philippe Mathieu-Daudé 3 participants 11 messages Jul 5, 2023 – Jul 10, 2023 Networking

lore
Share & tools
lore
#0 lore raw

cover chardev/char-fe: Document FEWatchFunc and use G_SOURCE_CONTINUE/REMOVE

Improve qio and chardev frontend documentation, have FEWatchFunc handlers return G_SOURCE_CONTINUE/REMOVE.

Philippe Mathieu-Daudé (4):
io/channel: Explicit QIOChannel doc is based on GLib's IOChannel chardev/char-fe: Clarify qemu_chr_fe_add_watch 'condition' arg is a
mask
chardev/char-fe: Document FEWatchFunc typedef
hw/char: Have FEWatchFunc handlers return G_SOURCE_CONTINUE/REMOVE

 include/chardev/char-fe.h | 18 ++++++++++++++++--
 include/io/channel.h      |  2 +-
 hw/char/cadence_uart.c    |  8 ++++----
 hw/char/cmsdk-apb-uart.c  |  6 +++---
 hw/char/ibex_uart.c       |  8 ++++----
 hw/char/nrf51_uart.c      |  4 ++--
 hw/char/serial.c          |  2 +-
 hw/char/virtio-console.c  |  2 +-
 hw/usb/redirect.c         |  2 +-
 monitor/monitor.c         |  2 +-
 net/vhost-user.c          |  2 +-
 11 files changed, 35 insertions(+), 21 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH 1/4 io/channel: Explicit QIOChannel doc is based on GLib's IOChannel

One can get lost looking for "public API docs". Explicit we are referring to GLib IOChannel documentation.

---
 include/io/channel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/io/channel.h +1 -1
index 229bf36910..998718b470 100644
@@ -97,7 +97,7 @@ struct QIOChannel {
  * The first five callbacks are mandatory to support, others
  * provide additional optional features.
  *
- * Consult the corresponding public API docs for a description
+ * Consult the corresponding GLib IOChannel public API docs for a description
  * of the semantics of each callback. io_shutdown in particular
  * must be thread-safe, terminate quickly and must not block.
  */
Signature · 1 line
2.38.1
#2 lore raw

Re: [PATCH 1/4] io/channel: Explicit QIOChannel doc is based on GLib's IOChannel

Quoted 13 lines · Philippe Mathieu-Daudé

One can get lost looking for "public API docs". Explicit we are referring to GLib IOChannel documentation.

---
 include/io/channel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/io/channel.h +0 -0
index 229bf36910..998718b470 100644

include/io/channel.h struct QIOChannel { · line 100

Quoted 5 lines
include/io/channel.h +1 -1
@@ -97,7 +97,7 @@ struct QIOChannel {
  * The first five callbacks are mandatory to support, others
  * provide additional optional features.
  *
- * Consult the corresponding public API docs for a description
+ * Consult the corresponding GLib IOChannel public API docs for a description

This is refering to the public API docs in this very file.

ie for io_writev callback, the qio_channel_io_writev docs define semantics.

Quoted 6 lines
include/io/channel.h +0 -0
  * of the semantics of each callback. io_shutdown in particular
  * must be thread-safe, terminate quickly and must not block.
  */
Signature · 1 line
2.38.1

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#3 lore raw

PATCH 2/4 chardev/char-fe: Clarify qemu_chr_fe_add_watch 'condition' arg is a mask

In reply to Philippe Mathieu-Daudé

qemu_chr_fe_add_watch() can poll for multiple conditions. It's @cond argument is a combination of all the condition bits.

---
 include/chardev/char-fe.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/chardev/char-fe.h +2 -2
index 8c420fa36e..309960046a 100644
@@ -179,8 +179,8 @@ typedef gboolean (*FEWatchFunc)(void *do_not_use, GIOCondition condition, void *
 
 /**
  * qemu_chr_fe_add_watch:
- * @cond: the condition to poll for
- * @func: the function to call when the condition happens
+ * @cond: bitwise combination of conditions to poll for
+ * @func: the function to call when the conditions are satisfied
  * @user_data: the opaque pointer to pass to @func
  *
  * If the backend is connected, create and add a #GSource that fires
Signature · 1 line
2.38.1
#4 lore raw

Re: [PATCH 2/4] chardev/char-fe: Clarify qemu_chr_fe_add_watch 'condition' arg is a mask

Quoted 15 lines · Philippe Mathieu-Daudé

qemu_chr_fe_add_watch() can poll for multiple conditions. It's @cond argument is a combination of all the condition bits.

---
 include/chardev/char-fe.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/chardev/char-fe.h +0 -0
index 8c420fa36e..309960046a 100644
@@ -179,8 +179,8 @@ typedef gboolean (*FEWatchFunc)(void *do_not_use,

GIOCondition condition, void *

Quoted 4 lines

/**
* qemu_chr_fe_add_watch:
- * @cond: the condition to poll for

- * @func: the function to call when the condition happens

Quoted 3 lines

+ * @cond: bitwise combination of conditions to poll for
+ * @func: the function to call when the conditions are satisfied

Not really worth imo, do you want to also fix all the io/ docs for @condition? and probably elsewhere...

The rewording of @func isn't much clearer either... "any of the conditions"?

Quoted 8 lines

* @user_data: the opaque pointer to pass to @func
*
* If the backend is connected, create and add a #GSource that fires
--
2.38.1

Signature · 1 line
Marc-André Lureau
#5 lore raw

Re: [PATCH 2/4] chardev/char-fe: Clarify qemu_chr_fe_add_watch 'condition' arg is a mask

Quoted 29 lines · Marc-André Lureau

On Wed, Jul 5, 2023 at 5:33 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:

qemu_chr_fe_add_watch() can poll for multiple conditions. It's @cond argument is a combination of all the condition bits.

<mailto:[email protected]>>
---
 include/chardev/char-fe.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index 8c420fa36e..309960046a 100644
--- a/include/chardev/char-fe.h
+++ b/include/chardev/char-fe.h
@@ -179,8 +179,8 @@ typedef gboolean (*FEWatchFunc)(void *do_not_use, GIOCondition condition, void *

 /**
  * qemu_chr_fe_add_watch:
- * @cond: the condition to poll for

- * @func: the function to call when the condition happens
+ * @cond: bitwise combination of conditions to poll for
+ * @func: the function to call when the conditions are satisfied

Quoted 4 lines

Not really worth imo, do you want to also fix all the io/ docs for @condition? and probably elsewhere...

The rewording of @func isn't much clearer either... "any of the conditions"?

Hmm OK I'll just drop this patch for now, thanks.

#6 lore raw

PATCH 3/4 chardev/char-fe: Document FEWatchFunc typedef

In reply to Philippe Mathieu-Daudé
---
 include/chardev/char-fe.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
include/chardev/char-fe.h +14 -0
index 309960046a..ec3f706a14 100644
@@ -175,6 +175,20 @@ void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
     G_GNUC_PRINTF(2, 3);
 
 
+/**
+ * FEWatchFunc: a #GSourceFunc called when any conditions requested by
+ *              qemu_chr_fe_add_watch() is satisfied.
+ * @do_not_use: depending on the underlying chardev, a GIOChannel or a
+ *              QIOChannel. DO NOT USE!
+ * @cond: bitwise combination of conditions watched and satisfied
+ *              before calling this callback.
+ * @data: user data passed at creation to qemu_chr_fe_add_watch(). Can
+ *              be NULL.
+ *
+ * Returns: G_SOURCE_REMOVE if the GSource should be removed from the
+ *              main loop, or G_SOURCE_CONTINUE to leave the GSource in
+ *              the main loop.
+ */
 typedef gboolean (*FEWatchFunc)(void *do_not_use, GIOCondition condition, void *data);
 
 /**
Signature · 1 line
2.38.1
Acked-by on v1 3/4
#7 lore raw

Re: [PATCH 3/4] chardev/char-fe: Document FEWatchFunc typedef

Hi

Quoted 31 lines · Philippe Mathieu-Daudé
---
 include/chardev/char-fe.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
include/chardev/char-fe.h +14 -0
index 309960046a..ec3f706a14 100644
@@ -175,6 +175,20 @@ void qemu_chr_fe_printf(CharBackend *be, const char
 *fmt, ...)
     G_GNUC_PRINTF(2, 3);
 
 
+/**
+ * FEWatchFunc: a #GSourceFunc called when any conditions requested by
+ *              qemu_chr_fe_add_watch() is satisfied.
+ * @do_not_use: depending on the underlying chardev, a GIOChannel or a
+ *              QIOChannel. DO NOT USE!
+ * @cond: bitwise combination of conditions watched and satisfied
+ *              before calling this callback.
+ * @data: user data passed at creation to qemu_chr_fe_add_watch(). Can
+ *              be NULL.
+ *
+ * Returns: G_SOURCE_REMOVE if the GSource should be removed from the
+ *              main loop, or G_SOURCE_CONTINUE to leave the GSource in
+ *              the main loop.
+ */
 typedef gboolean (*FEWatchFunc)(void *do_not_use, GIOCondition condition,
 void *data);
Quoted 6 lines

/**
--
2.38.1

Signature · 1 line
Marc-André Lureau
#8 lore raw

PATCH 4/4 hw/char: Have FEWatchFunc handlers return G_SOURCE_CONTINUE/REMOVE

In reply to Philippe Mathieu-Daudé

GLib recommend to use G_SOURCE_REMOVE / G_SOURCE_CONTINUE for GSourceFunc callbacks. Our FEWatchFunc is a GSourceFunc returning such value. Use such definitions which are "more memorable" [*].

[*] https://docs.gtk.org/glib/callback.SourceFunc.html#return-value

---
 hw/char/cadence_uart.c   | 8 ++++----
 hw/char/cmsdk-apb-uart.c | 6 +++---
 hw/char/ibex_uart.c      | 8 ++++----
 hw/char/nrf51_uart.c     | 4 ++--
 hw/char/serial.c         | 2 +-
 hw/char/virtio-console.c | 2 +-
 hw/usb/redirect.c        | 2 +-
 monitor/monitor.c        | 2 +-
 net/vhost-user.c         | 2 +-
 9 files changed, 18 insertions(+), 18 deletions(-)
hw/char/cadence_uart.c +4 -4
index 807e398541..eff0304a18 100644
@@ -307,11 +307,11 @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond,
     /* instant drain the fifo when there's no back-end */
     if (!qemu_chr_fe_backend_connected(&s->chr)) {
         s->tx_count = 0;
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
     if (!s->tx_count) {
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
     ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_count);
@@ -326,12 +326,12 @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond,
                                         cadence_uart_xmit, s);
         if (!r) {
             s->tx_count = 0;
-            return FALSE;
+            return G_SOURCE_REMOVE;
         }
     }
 
     uart_update_status(s);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 static void uart_write_tx_fifo(CadenceUARTState *s, const uint8_t *buf,
hw/char/cmsdk-apb-uart.c +3 -3
index f8dc89ee3d..d466cd93de 100644
@@ -199,7 +199,7 @@ static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
     s->watch_tag = 0;
 
     if (!(s->ctrl & R_CTRL_TX_EN_MASK) || !(s->state & R_STATE_TXFULL_MASK)) {
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
     ret = qemu_chr_fe_write(&s->chr, &s->txbuf, 1);
@@ -215,7 +215,7 @@ static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
         }
         /* Transmit pending */
         trace_cmsdk_apb_uart_tx_pending();
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
 buffer_drained:
@@ -227,7 +227,7 @@ buffer_drained:
         s->intstatus |= R_INTSTATUS_TX_MASK;
     }
     cmsdk_apb_uart_update(s);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 static void uart_cancel_transmit(CMSDKAPBUART *s)
hw/char/ibex_uart.c +4 -4
index f70adb5308..51708c0836 100644
@@ -147,7 +147,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
     /* instant drain the fifo when there's no back-end */
     if (!qemu_chr_fe_backend_connected(&s->chr)) {
         s->tx_level = 0;
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
     if (!s->tx_level) {
@@ -156,7 +156,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
         s->uart_intr_state |= R_INTR_STATE_TX_EMPTY_MASK;
         s->uart_intr_state &= ~R_INTR_STATE_TX_WATERMARK_MASK;
         ibex_uart_update_irqs(s);
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
     ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_level);
@@ -171,7 +171,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
                                         ibex_uart_xmit, s);
         if (!r) {
             s->tx_level = 0;
-            return FALSE;
+            return G_SOURCE_REMOVE;
         }
     }
 
@@ -192,7 +192,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
     }
 
     ibex_uart_update_irqs(s);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 static void uart_write_tx_fifo(IbexUartState *s, const uint8_t *buf,
hw/char/nrf51_uart.c +2 -2
index 3c6f982de9..dfe2276d71 100644
@@ -93,13 +93,13 @@ static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
              */
             goto buffer_drained;
         }
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
 buffer_drained:
     s->reg[R_UART_TXDRDY] = 1;
     s->pending_tx_byte = false;
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 static void uart_cancel_transmit(NRF51UARTState *s)
hw/char/serial.c +1 -1
index 270e1b1094..f3094f860f 100644
@@ -226,7 +226,7 @@ static gboolean serial_watch_cb(void *do_not_use, GIOCondition cond,
     SerialState *s = opaque;
     s->watch_tag = 0;
     serial_xmit(s);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 static void serial_xmit(SerialState *s)
hw/char/virtio-console.c +1 -1
index dd5a02e339..dbe0b28e60 100644
@@ -45,7 +45,7 @@ static gboolean chr_write_unblocked(void *do_not_use, GIOCondition cond,
 
     vcon->watch = 0;
     virtio_serial_throttle_port(VIRTIO_SERIAL_PORT(vcon), false);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 /* Callback function that's called when the guest sends us data */
hw/usb/redirect.c +1 -1
index 39fbaaab16..4bbf8afb33 100644
@@ -278,7 +278,7 @@ static gboolean usbredir_write_unblocked(void *do_not_use, GIOCondition cond,
     dev->watch = 0;
     usbredirparser_do_write(dev->parser);
 
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 static int usbredir_write(void *priv, uint8_t *data, int count)
monitor/monitor.c +1 -1
index dc352f9e9d..941f87815a 100644
@@ -144,7 +144,7 @@ static gboolean monitor_unblocked(void *do_not_use, GIOCondition cond,
     QEMU_LOCK_GUARD(&mon->mon_lock);
     mon->out_watch = 0;
     monitor_flush_locked(mon);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 /* Caller must hold mon->mon_lock */
net/vhost-user.c +1 -1
index 5993e4afca..12555518e8 100644
@@ -239,7 +239,7 @@ static gboolean net_vhost_user_watch(void *do_not_use, GIOCondition cond,
 
     qemu_chr_fe_disconnect(&s->chr);
 
-    return TRUE;
+    return G_SOURCE_CONTINUE;
 }
 
 static void net_vhost_user_event(void *opaque, QEMUChrEvent event);
Signature · 1 line
2.38.1
Reviewed-by on v1 4/4
#9 lore raw

Re: [PATCH 4/4] hw/char: Have FEWatchFunc handlers return G_SOURCE_CONTINUE/REMOVE

Quoted 9 lines · Philippe Mathieu-Daudé

GLib recommend to use G_SOURCE_REMOVE / G_SOURCE_CONTINUE for GSourceFunc callbacks. Our FEWatchFunc is a GSourceFunc returning such value. Use such definitions which are "more memorable" [*].

[*] https://docs.gtk.org/glib/callback.SourceFunc.html#return-value

Quoted 221 lines
---
 hw/char/cadence_uart.c   | 8 ++++----
 hw/char/cmsdk-apb-uart.c | 6 +++---
 hw/char/ibex_uart.c      | 8 ++++----
 hw/char/nrf51_uart.c     | 4 ++--
 hw/char/serial.c         | 2 +-
 hw/char/virtio-console.c | 2 +-
 hw/usb/redirect.c        | 2 +-
 monitor/monitor.c        | 2 +-
 net/vhost-user.c         | 2 +-
 9 files changed, 18 insertions(+), 18 deletions(-)
hw/char/cadence_uart.c +2 -2
index 807e398541..eff0304a18 100644
@@ -307,11 +307,11 @@ static gboolean cadence_uart_xmit(void *do_not_use,
 GIOCondition cond,
     /* instant drain the fifo when there's no back-end */
     if (!qemu_chr_fe_backend_connected(&s->chr)) {
         s->tx_count = 0;
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
     if (!s->tx_count) {
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
     ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_count);
hw/char/cadence_uart.c +2 -2
@@ -326,12 +326,12 @@ static gboolean cadence_uart_xmit(void *do_not_use,
 GIOCondition cond,
                                         cadence_uart_xmit, s);
         if (!r) {
             s->tx_count = 0;
-            return FALSE;
+            return G_SOURCE_REMOVE;
         }
     }
 
     uart_update_status(s);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 

static void uart_write_tx_fifo(CadenceUARTState *s, const uint8_t *buf,

hw/char/cmsdk-apb-uart.c +1 -1
index f8dc89ee3d..d466cd93de 100644
@@ -199,7 +199,7 @@ static gboolean uart_transmit(void *do_not_use,
 GIOCondition cond, void *opaque)
     s->watch_tag = 0;
 
     if (!(s->ctrl & R_CTRL_TX_EN_MASK) || !(s->state &
 R_STATE_TXFULL_MASK)) {
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
     ret = qemu_chr_fe_write(&s->chr, &s->txbuf, 1);
hw/char/cmsdk-apb-uart.c +1 -1
@@ -215,7 +215,7 @@ static gboolean uart_transmit(void *do_not_use,
 GIOCondition cond, void *opaque)
         }
         /* Transmit pending */
         trace_cmsdk_apb_uart_tx_pending();
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 

buffer_drained:

hw/char/cmsdk-apb-uart.c +1 -1
@@ -227,7 +227,7 @@ buffer_drained:
         s->intstatus |= R_INTSTATUS_TX_MASK;
     }
     cmsdk_apb_uart_update(s);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 static void uart_cancel_transmit(CMSDKAPBUART *s)
hw/char/ibex_uart.c +1 -1
index f70adb5308..51708c0836 100644
@@ -147,7 +147,7 @@ static gboolean ibex_uart_xmit(void *do_not_use,
 GIOCondition cond,
     /* instant drain the fifo when there's no back-end */
     if (!qemu_chr_fe_backend_connected(&s->chr)) {
         s->tx_level = 0;
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
     if (!s->tx_level) {
hw/char/ibex_uart.c +1 -1
@@ -156,7 +156,7 @@ static gboolean ibex_uart_xmit(void *do_not_use,
 GIOCondition cond,
         s->uart_intr_state |= R_INTR_STATE_TX_EMPTY_MASK;
         s->uart_intr_state &= ~R_INTR_STATE_TX_WATERMARK_MASK;
         ibex_uart_update_irqs(s);
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
     ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_level);
hw/char/ibex_uart.c +2 -2
@@ -171,7 +171,7 @@ static gboolean ibex_uart_xmit(void *do_not_use,
 GIOCondition cond,
                                         ibex_uart_xmit, s);
         if (!r) {
             s->tx_level = 0;
-            return FALSE;
+            return G_SOURCE_REMOVE;
         }
     }
@@ -192,7 +192,7 @@ static gboolean ibex_uart_xmit(void *do_not_use,
 GIOCondition cond,
     }
 
     ibex_uart_update_irqs(s);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 

static void uart_write_tx_fifo(IbexUartState *s, const uint8_t *buf,

hw/char/nrf51_uart.c +2 -2
index 3c6f982de9..dfe2276d71 100644
@@ -93,13 +93,13 @@ static gboolean uart_transmit(void *do_not_use,
 GIOCondition cond, void *opaque)
              */
             goto buffer_drained;
         }
-        return FALSE;
+        return G_SOURCE_REMOVE;
     }
 
 buffer_drained:
     s->reg[R_UART_TXDRDY] = 1;
     s->pending_tx_byte = false;
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 

static void uart_cancel_transmit(NRF51UARTState *s)

hw/char/serial.c +1 -1
index 270e1b1094..f3094f860f 100644
@@ -226,7 +226,7 @@ static gboolean serial_watch_cb(void *do_not_use,
 GIOCondition cond,
     SerialState *s = opaque;
     s->watch_tag = 0;
     serial_xmit(s);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 

static void serial_xmit(SerialState *s)

hw/char/virtio-console.c +1 -1
index dd5a02e339..dbe0b28e60 100644
@@ -45,7 +45,7 @@ static gboolean chr_write_unblocked(void *do_not_use,
 GIOCondition cond,
 
     vcon->watch = 0;
     virtio_serial_throttle_port(VIRTIO_SERIAL_PORT(vcon), false);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 

/* Callback function that's called when the guest sends us data */

hw/usb/redirect.c +1 -1
index 39fbaaab16..4bbf8afb33 100644
@@ -278,7 +278,7 @@ static gboolean usbredir_write_unblocked(void
 *do_not_use, GIOCondition cond,
     dev->watch = 0;
     usbredirparser_do_write(dev->parser);
 
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 

static int usbredir_write(void *priv, uint8_t *data, int count)

monitor/monitor.c +1 -1
index dc352f9e9d..941f87815a 100644
@@ -144,7 +144,7 @@ static gboolean monitor_unblocked(void *do_not_use,
 GIOCondition cond,
     QEMU_LOCK_GUARD(&mon->mon_lock);
     mon->out_watch = 0;
     monitor_flush_locked(mon);
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 

/* Caller must hold mon->mon_lock */

net/vhost-user.c +1 -1
index 5993e4afca..12555518e8 100644
@@ -239,7 +239,7 @@ static gboolean net_vhost_user_watch(void *do_not_use,
 GIOCondition cond,
 
     qemu_chr_fe_disconnect(&s->chr);
 
-    return TRUE;
+    return G_SOURCE_CONTINUE;
 }
 

static void net_vhost_user_event(void *opaque, QEMUChrEvent event);
--
2.38.1

Signature · 1 line
Marc-André Lureau
#10 lore raw
In reply to Philippe Mathieu-Daudé

Hi Paolo & Marc-André,

Quoted 9 lines · Philippe Mathieu-Daudé

Improve qio and chardev frontend documentation, have FEWatchFunc handlers return G_SOURCE_CONTINUE/REMOVE.

Philippe Mathieu-Daudé (4):
io/channel: Explicit QIOChannel doc is based on GLib's IOChannel chardev/char-fe: Clarify qemu_chr_fe_add_watch 'condition' arg is a
mask
chardev/char-fe: Document FEWatchFunc typedef
hw/char: Have FEWatchFunc handlers return G_SOURCE_CONTINUE/REMOVE

Could you Ack patches 2-4?