On Wed, 27 May 2026, Christian Schoenebeck wrote:
> 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).
>
> Signed-off-by: Christian Schoenebeck <[email protected]>
> ---
> hw/9pfs/xen-9p-backend.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
> index ca0fff5fa9..94654022fe 100644
> --- a/hw/9pfs/xen-9p-backend.c
> +++ b/hw/9pfs/xen-9p-backend.c
> @@ -250,12 +250,19 @@ static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
> qemu_bh_schedule(ring->bh);
> }
>
> +static size_t xen_9p_msize_limit(V9fsState *s)
> +{
> + Xen9pfsDev *xen_9pfs = container_of(s, Xen9pfsDev, state);
> + return XEN_FLEX_RING_SIZE(xen_9pfs->rings[0].ring_order);
> +}
This is correct as a computation. But there are multiple rings with
potentially different ring_orders (although I have never seen it in
practice.)
So I think something like this would be better:
---
size_t limit = XEN_FLEX_RING_SIZE(xen_9pfs->rings[0].ring_order);
for (i = 1; i < xen_9pfs->num_rings; i++) {
limit = MIN(limit, XEN_FLEX_RING_SIZE(xen_9pfs->rings[i].ring_order));
}
return limit;
> static const V9fsTransport xen_9p_transport = {
> .pdu_vmarshal = xen_9pfs_pdu_vmarshal,
> .pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
> .init_in_iov_from_pdu = xen_9pfs_init_in_iov_from_pdu,
> .init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
> .push_and_notify = xen_9pfs_push_and_notify,
> + .msize_limit = xen_9p_msize_limit,
> };
>
> static int xen_9pfs_init(struct XenLegacyDevice *xendev)