Skip to contentSkip to conversation

main-loop: document IOCanReadHandler

PATCH Applied Stefan Hajnoczi 3 participants 3 messages Jun 2, 2018 – Jun 4, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 main-loop: document IOCanReadHandler

---
 include/qemu/main-loop.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
include/qemu/main-loop.h +14 -0
index 6b4b60bf6d..721aa2416a 100644
@@ -168,6 +168,20 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
 /* async I/O support */
 
 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
+
+/**
+ * IOCanReadHandler: Return the number of bytes that #IOReadHandler can accept
+ *
+ * This function reports how many bytes #IOReadHandler is prepared to accept.
+ * #IOReadHandler may be invoked with up to this number of bytes.  If this
+ * function returns 0 then #IOReadHandler is not invoked.
+ *
+ * This function is typically called from an event loop.  If the number of
+ * bytes changes outside the event loop (e.g. because a vcpu thread drained the
+ * buffer), then it is necessary to kick the event loop so that this function
+ * is called again.  aio_notify() or qemu_notify_event() can be used to kick
+ * the event loop.
+ */
 typedef int IOCanReadHandler(void *opaque);
 
 /**
Signature · 1 line
2.17.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Stefan Hajnoczi
---
 include/qemu/main-loop.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
include/qemu/main-loop.h +7 -0
index 6b4b60bf6d..721aa2416a 100644
@@ -168,6 +168,20 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
 /* async I/O support */
 
 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
+
+/**
+ * IOCanReadHandler: Return the number of bytes that #IOReadHandler can accept
+ *
+ * This function reports how many bytes #IOReadHandler is prepared to accept.
+ * #IOReadHandler may be invoked with up to this number of bytes.  If this
+ * function returns 0 then #IOReadHandler is not invoked.

include/qemu/main-loop.h void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); · line 187

Quoted 10 lines
include/qemu/main-loop.h +7 -0
+ *
+ * This function is typically called from an event loop.  If the number of
+ * bytes changes outside the event loop (e.g. because a vcpu thread drained the
+ * buffer), then it is necessary to kick the event loop so that this function
+ * is called again.  aio_notify() or qemu_notify_event() can be used to kick
+ * the event loop.
+ */
 typedef int IOCanReadHandler(void *opaque);
 
 /**

Thanks!

#2 lore raw
In reply to Stefan Hajnoczi
Quoted 21 lines · Stefan Hajnoczi
---
 include/qemu/main-loop.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
include/qemu/main-loop.h +7 -0
index 6b4b60bf6d..721aa2416a 100644
@@ -168,6 +168,20 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
 /* async I/O support */
 
 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
+
+/**
+ * IOCanReadHandler: Return the number of bytes that #IOReadHandler can accept
+ *
+ * This function reports how many bytes #IOReadHandler is prepared to accept.
+ * #IOReadHandler may be invoked with up to this number of bytes.  If this
+ * function returns 0 then #IOReadHandler is not invoked.

include/qemu/main-loop.h void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); · line 187

Quoted 10 lines
include/qemu/main-loop.h +7 -0
+ *
+ * This function is typically called from an event loop.  If the number of
+ * bytes changes outside the event loop (e.g. because a vcpu thread drained the
+ * buffer), then it is necessary to kick the event loop so that this function
+ * is called again.  aio_notify() or qemu_notify_event() can be used to kick
+ * the event loop.
+ */
 typedef int IOCanReadHandler(void *opaque);
 
 /**

Queued, thanks.

Paolo