qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 03/18] vhost_net: do not assume nvqs is always 2


From: Stefano Garzarella
Subject: Re: [PATCH 03/18] vhost_net: do not assume nvqs is always 2
Date: Wed, 23 Jun 2021 16:49:17 +0200

On Mon, Jun 21, 2021 at 12:16:35PM +0800, Jason Wang wrote:
This patch switches to initialize dev.nvqs from the VhostNetOptions
instead of assuming it was 2. This is useful for implementing control
virtqueue support which will be a single vhost_net structure with a
single cvq.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/vhost_net.c      | 2 +-
include/net/vhost_net.h | 1 +
net/tap.c               | 1 +
net/vhost-user.c        | 1 +
net/vhost-vdpa.c        | 1 +
5 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 6bd4184f96..ef1370bd92 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -163,9 +163,9 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
        goto fail;
    }
    net->nc = options->net_backend;
+    net->dev.nvqs = options->nvqs;

    net->dev.max_queues = 1;
-    net->dev.nvqs = 2;
    net->dev.vqs = net->vqs;

    if (backend_kernel) {
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 172b0051d8..fba40cf695 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -14,6 +14,7 @@ typedef struct VhostNetOptions {
    VhostBackendType backend_type;
    NetClientState *net_backend;
    uint32_t busyloop_timeout;
+    unsigned int nvqs;
    void *opaque;
} VhostNetOptions;

diff --git a/net/tap.c b/net/tap.c
index f5686bbf77..f716be3e3f 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -749,6 +749,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, 
NetClientState *peer,
            qemu_set_nonblock(vhostfd);
        }
        options.opaque = (void *)(uintptr_t)vhostfd;
+        options.nvqs = 2;

        s->vhost_net = vhost_net_init(&options);
        if (!s->vhost_net) {
diff --git a/net/vhost-user.c b/net/vhost-user.c
index ffbd94d944..b93918c5a4 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -85,6 +85,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[],
        options.net_backend = ncs[i];
        options.opaque      = be;
        options.busyloop_timeout = 0;
+        options.nvqs = 2;
        net = vhost_net_init(&options);
        if (!net) {
            error_report("failed to init vhost_net for queue %d", i);
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 19187dce8c..18b45ad777 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -105,6 +105,7 @@ static int vhost_vdpa_add(NetClientState *ncs, void *be)
    options.net_backend = ncs;
    options.opaque      = be;
    options.busyloop_timeout = 0;
+    options.nvqs = 2;

    net = vhost_net_init(&options);
    if (!net) {
--
2.25.1



Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]