virtio: introduce virtio_get_num_queues()
This patch introduces virtio_get_num_queues() which iterates the vqs array and return the number of virtqueues used by device. Signed-off-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
e83980455c
commit
8ad176aaed
@ -746,6 +746,19 @@ int virtio_queue_get_num(VirtIODevice *vdev, int n)
|
||||
return vdev->vq[n].vring.num;
|
||||
}
|
||||
|
||||
int virtio_get_num_queues(VirtIODevice *vdev)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
|
||||
if (!virtio_queue_get_num(vdev, i)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int virtio_queue_get_id(VirtQueue *vq)
|
||||
{
|
||||
VirtIODevice *vdev = vq->vdev;
|
||||
|
@ -176,6 +176,7 @@ void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr);
|
||||
hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n);
|
||||
void virtio_queue_set_num(VirtIODevice *vdev, int n, int num);
|
||||
int virtio_queue_get_num(VirtIODevice *vdev, int n);
|
||||
int virtio_get_num_queues(VirtIODevice *vdev);
|
||||
void virtio_queue_set_align(VirtIODevice *vdev, int n, int align);
|
||||
void virtio_queue_notify(VirtIODevice *vdev, int n);
|
||||
uint16_t virtio_queue_vector(VirtIODevice *vdev, int n);
|
||||
|
Loading…
Reference in New Issue
Block a user