9pfs/xen: implement msize_limit callback
Add and implement the msize_limit callback for the Xen transport. The limit is calculated using XEN_FLEX_RING_SIZE() based on the negotiated ring_order. For the theoretical maximum ring_order of 9, this results in a maximum 'msize' of 1048576 bytes (1 MiB). The minimum limit of all rings is picked, because multiple rings could theoretically have different ring_orders. Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Link: https://lore.kernel.org/qemu-devel/9471786bc47b93e822f6c6233a83f2b9f61e6c82.1781287774.git.qemu_oss@crudebyte.com Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Christian Schoenebeck committed
Jun 12, 2026 at 20:22 UTC
815d1799c3d3d6cd058cb4634392ca5a34830450
1 file changed
+19
hw/9pfs/xen-9p-backend.c
+19
@@ -250,12 +250,31 @@ static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
250
qemu_bh_schedule(ring->bh);
251
}
252
253
+static size_t xen_9p_msize_limit(V9fsState *s)
254
+{
255
+ Xen9pfsDev *xen_9pfs = container_of(s, Xen9pfsDev, state);
256
+ size_t limit;
257
+ int i;
258
+
259
+ if (!xen_9pfs->num_rings) {
260
+ return 0;
261
+ }
262
+
263
+ limit = XEN_FLEX_RING_SIZE(xen_9pfs->rings[0].ring_order);
264
+ for (i = 1; i < xen_9pfs->num_rings; i++) {
265
+ limit = MIN(limit, XEN_FLEX_RING_SIZE(xen_9pfs->rings[i].ring_order));
266
+ }
267
+
268
+ return limit;
269
+}
270
+
271
static const V9fsTransport xen_9p_transport = {
272
.pdu_vmarshal = xen_9pfs_pdu_vmarshal,
273
.pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
274
.init_in_iov_from_pdu = xen_9pfs_init_in_iov_from_pdu,
275
.init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
276
.push_and_notify = xen_9pfs_push_and_notify,
277
+ .msize_limit = xen_9p_msize_limit,
278
};
279
280
static int xen_9pfs_init(struct XenLegacyDevice *xendev)