|
|
a83cc2 |
From f3cec652012b0b5ab1d881f6377719b0984bce63 Mon Sep 17 00:00:00 2001
|
|
|
a83cc2 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
a83cc2 |
Date: Mon, 12 Jul 2021 10:22:31 -0400
|
|
|
a83cc2 |
Subject: [PATCH 11/43] vhost-user-blk: Check that num-queues is supported by
|
|
|
a83cc2 |
backend
|
|
|
a83cc2 |
|
|
|
a83cc2 |
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
RH-Bugzilla: 1957194
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Creating a device with a number of queues that isn't supported by the
|
|
|
a83cc2 |
backend is pointless, the device won't work properly and the error
|
|
|
a83cc2 |
messages are rather confusing.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Just fail to create the device if num-queues is higher than what the
|
|
|
a83cc2 |
backend supports.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Since the relationship between num-queues and the number of virtqueues
|
|
|
a83cc2 |
depends on the specific device, this is an additional value that needs
|
|
|
a83cc2 |
to be initialised by the device. For convenience, allow leaving it 0 if
|
|
|
a83cc2 |
the check should be skipped. This makes sense for vhost-user-net where
|
|
|
a83cc2 |
separate vhost devices are used for the queues and custom initialisation
|
|
|
a83cc2 |
code is needed to perform the check.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1935031
|
|
|
a83cc2 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
a83cc2 |
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
|
|
|
a83cc2 |
Message-Id: <20210429171316.162022-7-kwolf@redhat.com>
|
|
|
a83cc2 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
a83cc2 |
(cherry picked from commit c90bd505a3e8210c23d69fecab9ee6f56ec4a161)
|
|
|
a83cc2 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
---
|
|
|
a83cc2 |
hw/block/vhost-user-blk.c | 1 +
|
|
|
a83cc2 |
hw/virtio/vhost-user.c | 5 +++++
|
|
|
a83cc2 |
include/hw/virtio/vhost.h | 2 ++
|
|
|
a83cc2 |
3 files changed, 8 insertions(+)
|
|
|
a83cc2 |
|
|
|
a83cc2 |
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
|
|
|
a83cc2 |
index c7e502f4c7..c6210fad0c 100644
|
|
|
a83cc2 |
--- a/hw/block/vhost-user-blk.c
|
|
|
a83cc2 |
+++ b/hw/block/vhost-user-blk.c
|
|
|
a83cc2 |
@@ -324,6 +324,7 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
s->connected = true;
|
|
|
a83cc2 |
|
|
|
a83cc2 |
+ s->dev.num_queues = s->num_queues;
|
|
|
a83cc2 |
s->dev.nvqs = s->num_queues;
|
|
|
a83cc2 |
s->dev.vqs = s->vhost_vqs;
|
|
|
a83cc2 |
s->dev.vq_index = 0;
|
|
|
a83cc2 |
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
|
|
|
a83cc2 |
index ded0c10453..ee57abe045 100644
|
|
|
a83cc2 |
--- a/hw/virtio/vhost-user.c
|
|
|
a83cc2 |
+++ b/hw/virtio/vhost-user.c
|
|
|
a83cc2 |
@@ -1909,6 +1909,11 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque)
|
|
|
a83cc2 |
return err;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
+ if (dev->num_queues && dev->max_queues < dev->num_queues) {
|
|
|
a83cc2 |
+ error_report("The maximum number of queues supported by the "
|
|
|
a83cc2 |
+ "backend is %" PRIu64, dev->max_queues);
|
|
|
a83cc2 |
+ return -EINVAL;
|
|
|
a83cc2 |
+ }
|
|
|
a83cc2 |
|
|
|
a83cc2 |
if (virtio_has_feature(features, VIRTIO_F_IOMMU_PLATFORM) &&
|
|
|
a83cc2 |
!(virtio_has_feature(dev->protocol_features,
|
|
|
a83cc2 |
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
|
|
|
a83cc2 |
index 4a8bc75415..21a9a52088 100644
|
|
|
a83cc2 |
--- a/include/hw/virtio/vhost.h
|
|
|
a83cc2 |
+++ b/include/hw/virtio/vhost.h
|
|
|
a83cc2 |
@@ -74,6 +74,8 @@ struct vhost_dev {
|
|
|
a83cc2 |
int nvqs;
|
|
|
a83cc2 |
/* the first virtqueue which would be used by this vhost dev */
|
|
|
a83cc2 |
int vq_index;
|
|
|
a83cc2 |
+ /* if non-zero, minimum required value for max_queues */
|
|
|
a83cc2 |
+ int num_queues;
|
|
|
a83cc2 |
uint64_t features;
|
|
|
a83cc2 |
uint64_t acked_features;
|
|
|
a83cc2 |
uint64_t backend_features;
|
|
|
a83cc2 |
--
|
|
|
a83cc2 |
2.27.0
|
|
|
a83cc2 |
|