net/virtio: fix kernel set memtable for multi-queue device
authorThierry Herbelot <thierry.herbelot@6wind.com>
Fri, 23 Apr 2021 12:25:15 +0000 (14:25 +0200)
committerChenbo Xia <chenbo.xia@intel.com>
Wed, 28 Apr 2021 05:55:27 +0000 (07:55 +0200)
Restore the original code, where VHOST_SET_MEM_TABLE is applied to
all vhostfds of the device.

Fixes: 539d910c9c76 ("net/virtio: add virtio-user memory tables ops")
Cc: stable@dpdk.org
Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_user/vhost_kernel.c

index 58e66bb..ad46f10 100644 (file)
@@ -206,6 +206,7 @@ add_memseg_list(const struct rte_memseg_list *msl, void *arg)
 static int
 vhost_kernel_set_memory_table(struct virtio_user_dev *dev)
 {
+       uint32_t i;
        struct vhost_kernel_data *data = dev->backend_data;
        struct vhost_memory_kernel *vm;
        int ret;
@@ -227,9 +228,14 @@ vhost_kernel_set_memory_table(struct virtio_user_dev *dev)
        if (ret < 0)
                goto err_free;
 
-       ret = vhost_kernel_ioctl(data->vhostfds[0], VHOST_SET_MEM_TABLE, vm);
-       if (ret < 0)
-               goto err_free;
+       for (i = 0; i < dev->max_queue_pairs; ++i) {
+               if (data->vhostfds[i] < 0)
+                       continue;
+
+               ret = vhost_kernel_ioctl(data->vhostfds[i], VHOST_SET_MEM_TABLE, vm);
+               if (ret < 0)
+                       goto err_free;
+       }
 
        free(vm);