From 26a9c7d840d2764e61cadffd912de4d731328dae Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Sat, 8 Nov 2025 09:12:50 +0100 Subject: [PATCH] bhyve: support queue configuration for NVMe disks bhyve supports queue configuration for the NVMe disks: maxq Max number of queues. qsz Max elements in each queue. Map that to the disk driver's "queues" and "queue_size" attributes respectfully, so: results in: -s N:0,nvme,/tmp/disk.img,maxq=2,qsz=256 Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_command.c | 16 ++++++++++++++-- tests/bhyvexml2argvdata/bhyvexml2argv-nvme.args | 2 +- tests/bhyvexml2argvdata/bhyvexml2argv-nvme.xml | 2 +- .../bhyvexml2xmloutdata/bhyvexml2xmlout-nvme.xml | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 0ceac618e8..8bfd5a6f93 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -371,6 +371,9 @@ bhyveBuildNVMeControllerArgStr(const virDomainDef *def, size_t i; for (i = 0; i < def->ndisks; i++) { + g_autofree char *nvme_opts = NULL; + + g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER; virDomainDiskDef *disk = def->disks[i]; if (disk->bus != VIR_DOMAIN_DISK_BUS_NVME) @@ -389,10 +392,19 @@ bhyveBuildNVMeControllerArgStr(const virDomainDef *def, disk_source = virDomainDiskGetSource(disk); + if (disk->queues) + virBufferAsprintf(&opt, ",maxq=%d", disk->queues); + if (disk->queue_size) + virBufferAsprintf(&opt, ",qsz=%d", disk->queue_size); + + nvme_opts = virBufferContentAndReset(&opt); + virCommandAddArg(cmd, "-s"); - virCommandAddArgFormat(cmd, "%d:0,nvme,%s", + virCommandAddArgFormat(cmd, "%d:0,nvme,%s%s", controller->info.addr.pci.slot, - disk_source); + disk_source, + NULLSTR_EMPTY(nvme_opts)); + } return 0; diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-nvme.args b/tests/bhyvexml2argvdata/bhyvexml2argv-nvme.args index bd39db1fe6..80877717f2 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-nvme.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-nvme.args @@ -5,5 +5,5 @@ bhyve \ -H \ -P \ -s 0:0,hostbridge \ --s 2:0,nvme,/tmp/freebsd.img \ +-s 2:0,nvme,/tmp/freebsd.img,maxq=2,qsz=256 \ bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-nvme.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-nvme.xml index 8daaa11e85..5401ed6ad8 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-nvme.xml +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-nvme.xml @@ -8,7 +8,7 @@ - + diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-nvme.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-nvme.xml index d4ab69b15f..40a1ea1c5e 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-nvme.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-nvme.xml @@ -14,7 +14,7 @@ destroy - +
-- 2.47.3