9pfs/virtio: implement response_buffer_size callback
Add and implement the response_buffer_size callback for the virtio transport. Returns the actual current virtio response buffer size for the supplied PDU, which will be used as safety guard for limiting the response size when generating a 9p response. Link: https://lore.kernel.org/qemu-devel/5bbed2768f7a0da8fa2be183e75928c5d1ef691d.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
12bcbdca8ae9fcd5fec093e8ef5e70521e85e889
1 file changed
+10
hw/9pfs/virtio-9p-device.c
+10
@@ -198,6 +198,15 @@ static size_t virtio_9p_msize_limit(V9fsState *s)
198
return (VIRTQUEUE_MAX_SIZE - 2) * guestPageSize;
199
}
200
201
+static size_t virtio_9p_response_buffer_size(V9fsPDU *pdu)
202
+{
203
+ V9fsState *s = pdu->s;
204
+ V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
205
+ VirtQueueElement *elem = v->elems[pdu->idx];
206
+
207
+ return iov_size(elem->in_sg, elem->in_num);
208
+}
209
+
210
static const V9fsTransport virtio_9p_transport = {
211
.pdu_vmarshal = virtio_pdu_vmarshal,
212
.pdu_vunmarshal = virtio_pdu_vunmarshal,
@@ -205,6 +214,7 @@ static const V9fsTransport virtio_9p_transport = {
214
.init_out_iov_from_pdu = virtio_init_out_iov_from_pdu,
215
.push_and_notify = virtio_9p_push_and_notify,
216
.msize_limit = virtio_9p_msize_limit,
217
+ .response_buffer_size = virtio_9p_response_buffer_size,
218
};
219
220
static void virtio_9p_device_realize(DeviceState *dev, Error **errp)