Skip to content

Commit b2a5f62

Browse files
jasowangmstsirkin
authored andcommitted
virtio-bus: introduce queue_enabled method
This patch introduces queue_enabled() method which allows the transport to implement its own way to report whether or not a queue is enabled. Signed-off-by: Jason Wang <[email protected]> Signed-off-by: Cindy Lu <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 92fbc3e commit b2a5f62

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

hw/virtio/virtio.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,6 +3286,12 @@ hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n)
32863286

32873287
bool virtio_queue_enabled(VirtIODevice *vdev, int n)
32883288
{
3289+
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
3290+
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
3291+
3292+
if (k->queue_enabled) {
3293+
return k->queue_enabled(qbus->parent, n);
3294+
}
32893295
return virtio_queue_get_desc_addr(vdev, n) != 0;
32903296
}
32913297

include/hw/virtio/virtio-bus.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ typedef struct VirtioBusClass {
8383
*/
8484
int (*ioeventfd_assign)(DeviceState *d, EventNotifier *notifier,
8585
int n, bool assign);
86+
/*
87+
* Whether queue number n is enabled.
88+
*/
89+
bool (*queue_enabled)(DeviceState *d, int n);
8690
/*
8791
* Does the transport have variable vring alignment?
8892
* (ie can it ever call virtio_queue_set_align()?)

0 commit comments

Comments
 (0)