@samitouri / QOSamiQemu / commits / 12d3fd9a0a

hw/9pfs: annotate V9fsTransport callbacks as coroutine_fn

All V9fsTransport callbacks are invoked exclusively from coroutine context (the v9fs_* PDU handlers). Annotate the function pointer types in V9fsTransport and all implementations (virtio and xen backends), as well as intermediate callers in 9p.c (pdu_marshal, pdu_unmarshal, v9fs_init_qiov_from_pdu, etc.). Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Marc-André Lureau committed Jul 20, 2026 at 10:55 UTC 12d3fd9a0acaa009b927905b4cff069254ff04a1
4 files changed +64 -51
hw/9pfs/9p.c
+19 -12
@@ -55,7 +55,8 @@ enum {
55
56 P9ARRAY_DEFINE_TYPE(V9fsPath, v9fs_path_free);
57
58 -static ssize_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
58 +static ssize_t coroutine_fn
59 +pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
60 {
61 ssize_t ret;
62 va_list ap;
@@ -67,7 +68,8 @@ static ssize_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
68 return ret;
69 }
70
70 -static ssize_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
71 +static ssize_t coroutine_fn
72 +pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
73 {
74 ssize_t ret;
75 va_list ap;
@@ -1841,7 +1843,8 @@ out_nofid:
1843 pdu_complete(pdu, err);
1844 }
1845
1844 -static int v9fs_walk_marshal(V9fsPDU *pdu, uint16_t nwnames, V9fsQID *qids)
1846 +static int coroutine_fn
1847 +v9fs_walk_marshal(V9fsPDU *pdu, uint16_t nwnames, V9fsQID *qids)
1848 {
1849 int i;
1850 ssize_t err;
@@ -2363,9 +2366,10 @@ out_nofid:
2366 * The resulting QEMUIOVector has heap-allocated iovecs and must be cleaned up
2367 * with qemu_iovec_destroy().
2368 */
2366 -static void v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu,
2367 - size_t skip, size_t size,
2368 - bool is_write)
2369 +static void coroutine_fn
2370 +v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu,
2371 + size_t skip, size_t size,
2372 + bool is_write)
2373 {
2374 QEMUIOVector elem;
2375 struct iovec *iov;
@@ -2382,8 +2386,9 @@ static void v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu,
2386 qemu_iovec_concat(qiov, &elem, skip, size);
2387 }
2388
2385 -static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
2386 - uint64_t off, uint32_t max_count)
2389 +static int coroutine_fn
2390 +v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
2391 + uint64_t off, uint32_t max_count)
2392 {
2393 ssize_t err;
2394 size_t offset = 7;
@@ -2793,9 +2798,10 @@ out_nofid:
2798 pdu_complete(pdu, retval);
2799 }
2800
2796 -static int v9fs_xattr_write(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
2797 - uint64_t off, uint32_t count,
2798 - struct iovec *sg, int cnt)
2801 +static int coroutine_fn
2802 +v9fs_xattr_write(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
2803 + uint64_t off, uint32_t count,
2804 + struct iovec *sg, int cnt)
2805 {
2806 int i, to_copy;
2807 ssize_t err = 0;
@@ -3729,7 +3735,8 @@ out_nofid:
3735 pdu_complete(pdu, err);
3736 }
3737
3732 -static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf)
3738 +static int coroutine_fn
3739 +v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf)
3740 {
3741 uint32_t f_type;
3742 uint32_t f_bsize;
hw/9pfs/9p.h
+15 -11
@@ -472,17 +472,21 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr);
472 void v9fs_reset(V9fsState *s);
473
474 struct V9fsTransport {
475 - ssize_t (*pdu_vmarshal)(V9fsPDU *pdu, size_t offset, const char *fmt,
476 - va_list ap);
477 - ssize_t (*pdu_vunmarshal)(V9fsPDU *pdu, size_t offset, const char *fmt,
478 - va_list ap);
479 - void (*init_in_iov_from_pdu)(V9fsPDU *pdu, struct iovec **piov,
480 - unsigned int *pniov, size_t size);
481 - void (*init_out_iov_from_pdu)(V9fsPDU *pdu, struct iovec **piov,
482 - unsigned int *pniov, size_t size);
483 - void (*push_and_notify)(V9fsPDU *pdu);
484 - size_t (*msize_limit)(V9fsState *s);
485 - size_t (*response_buffer_size)(V9fsPDU *pdu);
475 + ssize_t coroutine_fn (*pdu_vmarshal)(V9fsPDU *pdu, size_t offset,
476 + const char *fmt, va_list ap);
477 + ssize_t coroutine_fn (*pdu_vunmarshal)(V9fsPDU *pdu, size_t offset,
478 + const char *fmt, va_list ap);
479 + void coroutine_fn (*init_in_iov_from_pdu)(V9fsPDU *pdu,
480 + struct iovec **piov,
481 + unsigned int *pniov,
482 + size_t size);
483 + void coroutine_fn (*init_out_iov_from_pdu)(V9fsPDU *pdu,
484 + struct iovec **piov,
485 + unsigned int *pniov,
486 + size_t size);
487 + void coroutine_fn (*push_and_notify)(V9fsPDU *pdu);
488 + size_t coroutine_fn (*msize_limit)(V9fsState *s);
489 + size_t coroutine_fn (*response_buffer_size)(V9fsPDU *pdu);
490 };
491
492 #endif
hw/9pfs/virtio-9p-device.c
+13 -11
@@ -28,7 +28,7 @@
28 #include "qemu/module.h"
29 #include "system/qtest.h"
30
31 -static void virtio_9p_push_and_notify(V9fsPDU *pdu)
31 +static void coroutine_fn virtio_9p_push_and_notify(V9fsPDU *pdu)
32 {
33 V9fsState *s = pdu->s;
34 V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
@@ -117,8 +117,8 @@ static void virtio_9p_reset(VirtIODevice *vdev)
117 v9fs_reset(&v->state);
118 }
119
120 -static ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset,
121 - const char *fmt, va_list ap)
120 +static ssize_t coroutine_fn
121 +virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, va_list ap)
122 {
123 V9fsState *s = pdu->s;
124 V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
@@ -135,8 +135,8 @@ static ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset,
135 return ret;
136 }
137
138 -static ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset,
139 - const char *fmt, va_list ap)
138 +static ssize_t coroutine_fn
139 +virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, va_list ap)
140 {
141 V9fsState *s = pdu->s;
142 V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
@@ -152,8 +152,9 @@ static ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset,
152 return ret;
153 }
154
155 -static void virtio_init_in_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
156 - unsigned int *pniov, size_t size)
155 +static void coroutine_fn
156 +virtio_init_in_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
157 + unsigned int *pniov, size_t size)
158 {
159 V9fsState *s = pdu->s;
160 V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
@@ -172,8 +173,9 @@ static void virtio_init_in_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
173 *pniov = elem->in_num;
174 }
175
175 -static void virtio_init_out_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
176 - unsigned int *pniov, size_t size)
176 +static void coroutine_fn
177 +virtio_init_out_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
178 + unsigned int *pniov, size_t size)
179 {
180 V9fsState *s = pdu->s;
181 V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
@@ -192,13 +194,13 @@ static void virtio_init_out_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
194 *pniov = elem->out_num;
195 }
196
195 -static size_t virtio_9p_msize_limit(V9fsState *s)
197 +static size_t coroutine_fn virtio_9p_msize_limit(V9fsState *s)
198 {
199 const size_t guestPageSize = 4096;
200 return (VIRTQUEUE_MAX_SIZE - 2) * guestPageSize;
201 }
202
201 -static size_t virtio_9p_response_buffer_size(V9fsPDU *pdu)
203 +static size_t coroutine_fn virtio_9p_response_buffer_size(V9fsPDU *pdu)
204 {
205 V9fsState *s = pdu->s;
206 V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
hw/9pfs/xen-9p-backend.c
+17 -17
@@ -136,10 +136,10 @@ static void xen_9pfs_out_sg(Xen9pfsRing *ring,
136 }
137 }
138
139 -static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
140 - size_t offset,
141 - const char *fmt,
142 - va_list ap)
139 +static ssize_t coroutine_fn xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
140 + size_t offset,
141 + const char *fmt,
142 + va_list ap)
143 {
144 Xen9pfsDev *xen_9pfs = container_of(pdu->s, Xen9pfsDev, state);
145 struct iovec in_sg[2];
@@ -161,10 +161,10 @@ static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
161 return ret;
162 }
163
164 -static ssize_t xen_9pfs_pdu_vunmarshal(V9fsPDU *pdu,
165 - size_t offset,
166 - const char *fmt,
167 - va_list ap)
164 +static ssize_t coroutine_fn xen_9pfs_pdu_vunmarshal(V9fsPDU *pdu,
165 + size_t offset,
166 + const char *fmt,
167 + va_list ap)
168 {
169 Xen9pfsDev *xen_9pfs = container_of(pdu->s, Xen9pfsDev, state);
170 struct iovec out_sg[2];
@@ -185,10 +185,10 @@ static ssize_t xen_9pfs_pdu_vunmarshal(V9fsPDU *pdu,
185 return ret;
186 }
187
188 -static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
189 - struct iovec **piov,
190 - unsigned int *pniov,
191 - size_t size)
188 +static void coroutine_fn xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
189 + struct iovec **piov,
190 + unsigned int *pniov,
191 + size_t size)
192 {
193 Xen9pfsDev *xen_9pfs = container_of(pdu->s, Xen9pfsDev, state);
194 Xen9pfsRing *ring = &xen_9pfs->rings[pdu->tag % xen_9pfs->num_rings];
@@ -202,10 +202,10 @@ static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
202 *pniov = num;
203 }
204
205 -static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
206 - struct iovec **piov,
207 - unsigned int *pniov,
208 - size_t size)
205 +static void coroutine_fn xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
206 + struct iovec **piov,
207 + unsigned int *pniov,
208 + size_t size)
209 {
210 Xen9pfsDev *xen_9pfs = container_of(pdu->s, Xen9pfsDev, state);
211 Xen9pfsRing *ring = &xen_9pfs->rings[pdu->tag % xen_9pfs->num_rings];
@@ -234,7 +234,7 @@ again:
234 *pniov = num;
235 }
236
237 -static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
237 +static void coroutine_fn xen_9pfs_push_and_notify(V9fsPDU *pdu)
238 {
239 RING_IDX prod;
240 Xen9pfsDev *priv = container_of(pdu->s, Xen9pfsDev, state);