diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2018-10-22 12:37:21 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-03-07 17:28:42 +0100 |
commit | 6bd4a6d4b867fab1f94f9fe3d1b19d02ac3d684b (patch) | |
tree | e393625078c7e5be8fe90ea9836b7959533ce5a4 /tests/libqos/virtio-net.c | |
parent | 6ae333f91b99cc4448e6c0af45f38d87bc952c82 (diff) |
tests/libqos: support multiqueue for virtio-net
Initialize the additional virtqueues if they are supported.
This is needed to switch vhost-user-test's multiqueue test
to the virtio-net qgraph.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/libqos/virtio-net.c')
-rw-r--r-- | tests/libqos/virtio-net.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/libqos/virtio-net.c b/tests/libqos/virtio-net.c index 3ddfbdc419..61c56170e9 100644 --- a/tests/libqos/virtio-net.c +++ b/tests/libqos/virtio-net.c @@ -27,14 +27,19 @@ static QGuestAllocator *alloc; static void virtio_net_cleanup(QVirtioNet *interface) { - qvirtqueue_cleanup(interface->vdev->bus, interface->rx, alloc); - qvirtqueue_cleanup(interface->vdev->bus, interface->tx, alloc); + int i; + + for (i = 0; i < interface->n_queues; i++) { + qvirtqueue_cleanup(interface->vdev->bus, interface->queues[i], alloc); + } + g_free(interface->queues); } static void virtio_net_setup(QVirtioNet *interface) { QVirtioDevice *vdev = interface->vdev; uint64_t features; + int i; features = qvirtio_get_features(vdev); features &= ~(QVIRTIO_F_BAD_FEATURE | @@ -42,8 +47,16 @@ static void virtio_net_setup(QVirtioNet *interface) (1u << VIRTIO_RING_F_EVENT_IDX)); qvirtio_set_features(vdev, features); - interface->rx = qvirtqueue_setup(vdev, alloc, 0); - interface->tx = qvirtqueue_setup(vdev, alloc, 1); + if (features & (1u << VIRTIO_NET_F_MQ)) { + interface->n_queues = qvirtio_config_readw(vdev, 8) * 2; + } else { + interface->n_queues = 2; + } + + interface->queues = g_new(QVirtQueue *, interface->n_queues); + for (i = 0; i < interface->n_queues; i++) { + interface->queues[i] = qvirtqueue_setup(vdev, alloc, i); + } qvirtio_set_driver_ok(vdev); } |