diff --git a/lib/virtio/virtio_user.c b/lib/virtio/virtio_user.c index e7fc65a8a..bdffde5db 100644 --- a/lib/virtio/virtio_user.c +++ b/lib/virtio/virtio_user.c @@ -47,7 +47,7 @@ #include "spdk_internal/virtio.h" #define VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES \ - (0) + ((1ULL << VHOST_USER_PROTOCOL_F_MQ)) static int virtio_user_create_queue(struct virtio_dev *vdev, uint32_t queue_sel) @@ -145,6 +145,15 @@ virtio_user_start_device(struct virtio_dev *vdev) uint64_t host_max_queues; int ret; + if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ)) == 0 && + vdev->max_queues > 1 + vdev->fixed_queues_num) { + SPDK_WARNLOG("%s: requested %"PRIu16" request queues, but the " + "host doesn't support VHOST_USER_PROTOCOL_F_MQ. " + "Only one request queue will be used.\n", + vdev->name, vdev->max_queues - vdev->fixed_queues_num); + vdev->max_queues = 1 + vdev->fixed_queues_num; + } + /* negotiate the number of I/O queues. */ ret = dev->ops->send_request(dev, VHOST_USER_GET_QUEUE_NUM, &host_max_queues); if (ret < 0) { diff --git a/lib/virtio/virtio_user/vhost.h b/lib/virtio/virtio_user/vhost.h index 69bedb177..7a434064a 100644 --- a/lib/virtio/virtio_user/vhost.h +++ b/lib/virtio/virtio_user/vhost.h @@ -43,6 +43,10 @@ #define VHOST_USER_MAX_CONFIG_SIZE 256 +#ifndef VHOST_USER_PROTOCOL_F_MQ +#define VHOST_USER_PROTOCOL_F_MQ 0 +#endif + enum vhost_user_request { VHOST_USER_NONE = 0, VHOST_USER_GET_FEATURES = 1,