Re: [PATCH RFC 08/15] hw/virtio/vhost-shadow-virtqueue: used handler
Stefan Hajnoczi <[email protected]> Tue, 28 Jul 2026 11:06:31 -0400
| Newsgroups | dev.linux.lists.virtio-fs,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <20260728150631.GF371693@fedora> |
--bnqYc8PExKM7h3vZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 23, 2026 at 03:30:07PM -0700, Connor Kite wrote: > Adds a handler callback to shadow virtqueues in order to enable > non-default processing of used vring elements from the device. >=20 > Signed-off-by: Connor Kite <[email protected]> > --- > hw/virtio/vhost-shadow-virtqueue.c | 4 ++++ > hw/virtio/vhost-shadow-virtqueue.h | 14 ++++++++++++++ > 2 files changed, 18 insertions(+) >=20 > diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-= virtqueue.c > index bcb7f2ffc7..eb86c1ee37 100644 > --- a/hw/virtio/vhost-shadow-virtqueue.c > +++ b/hw/virtio/vhost-shadow-virtqueue.c > @@ -669,6 +669,10 @@ static void vhost_svq_flush(VhostShadowVirtqueue *sv= q, > break; > } > =20 > + if (svq->ops && svq->ops->used_handler) { > + svq->ops->used_handler(svq, elem, svq->ops_opaque); > + } > + > if (unlikely(i >=3D svq->vring.num)) { > qemu_log_mask(LOG_GUEST_ERROR, > "More than %u used buffers obtained in a %u siz= e SVQ", > diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-= virtqueue.h > index ec16a1e838..ccfeee36d7 100644 > --- a/hw/virtio/vhost-shadow-virtqueue.h > +++ b/hw/virtio/vhost-shadow-virtqueue.h > @@ -56,8 +56,22 @@ typedef int (*VirtQueueAvailCallback)(VhostShadowVirtq= ueue *svq, > VirtQueueElement *elem, > void *vq_callback_opaque); > =20 > +/** > + * Callback to handle a used buffer > + * > + * @svq: Shadow virtqueue > + * @elem: Element placed in the queue by the device > + * @vq_callback_opaque: Used to pass arguments to callback > + * > + * Returns 0 if the vq is running as expected The doc comment should mention what non-0 look like. Are errors reported as a negative errno? > + */ > +typedef int (*VirtQueueUsedCallback)(VhostShadowVirtqueue *svq, > + VirtQueueElement *elem, > + void *vq_callback_opaque); > + > typedef struct VhostShadowVirtqueueOps { > VirtQueueAvailCallback avail_handler; > + VirtQueueUsedCallback used_handler; > } VhostShadowVirtqueueOps; > =20 > /* Shadow virtqueue to relay notifications */ >=20 > --=20 > 2.43.0 >=20 --bnqYc8PExKM7h3vZ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmpoxXcACgkQnKSrs4Gr c8gEPAgAnM6gyWjjb6vq24pJXR1H067s9W6tNHemw0rnqT+tOhL0zrKs5bwsa7QJ C5GmytVPByQVkR5AAvGVNioKhkx366NbjkUFCb9T+lJUACWTWZHha/4fH+HuLaI/ +paYr3L5wQ2DWD5sTeHw9kUa5koz+zZEX3dBFh8rRGT8NuxsizK43ObYziMx4tlQ maxC4ffSsCnQ1JtVlkfbD4OhgJFilrpwXoHCmWaR/MynF/QCVcN2rIQPmB9BEUZC siRj6oL3FVHYBqy2yFWusYLvaUb0ksEjxZWr4hA4ZpJrzXlxF1JFPf9KChzI43B3 2s/BlDWvdUL7ZLNJfdHVgOqS3OiwTw== =7ZzM -----END PGP SIGNATURE----- --bnqYc8PExKM7h3vZ--