Skip to content

Commit f19bcdf

Browse files
jasowangmstsirkin
authored andcommitted
virtio-pci: implement queue_enabled method
With version 1, we can detect whether a queue is enabled via queue_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 b2a5f62 commit f19bcdf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

hw/virtio/virtio-pci.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,18 @@ static AddressSpace *virtio_pci_get_dma_as(DeviceState *d)
11071107
return pci_get_address_space(dev);
11081108
}
11091109

1110+
static bool virtio_pci_queue_enabled(DeviceState *d, int n)
1111+
{
1112+
VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
1113+
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
1114+
1115+
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
1116+
return proxy->vqs[vdev->queue_sel].enabled;
1117+
}
1118+
1119+
return virtio_queue_enabled(vdev, n);
1120+
}
1121+
11101122
static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy,
11111123
struct virtio_pci_cap *cap)
11121124
{
@@ -2064,6 +2076,7 @@ static void virtio_pci_bus_class_init(ObjectClass *klass, void *data)
20642076
k->ioeventfd_enabled = virtio_pci_ioeventfd_enabled;
20652077
k->ioeventfd_assign = virtio_pci_ioeventfd_assign;
20662078
k->get_dma_as = virtio_pci_get_dma_as;
2079+
k->queue_enabled = virtio_pci_queue_enabled;
20672080
}
20682081

20692082
static const TypeInfo virtio_pci_bus_info = {

0 commit comments

Comments
 (0)