diff options
author | Jason Wang <jasowang@redhat.com> | 2015-05-29 14:15:26 +0800 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-05-31 16:45:38 +0200 |
commit | 8ad176aaed24535f535e0fdb03c538c23017535d (patch) | |
tree | 365658dbb30455ac495c256e3bb5c19607e7a93b /hw/virtio/virtio.c | |
parent | e83980455c8c7eb066405de512be7c4bace3ac4d (diff) | |
download | hqemu-8ad176aaed24535f535e0fdb03c538c23017535d.zip hqemu-8ad176aaed24535f535e0fdb03c538c23017535d.tar.gz |
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>
Diffstat (limited to 'hw/virtio/virtio.c')
-rw-r--r-- | hw/virtio/virtio.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index b50cbef..5602285 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -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; |