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: <driver name='file' type='raw' queues='2' queue_size='256'/> results in: -s N:0,nvme,/tmp/disk.img,maxq=2,qsz=256 Signed-off-by: Roman Bogorodskiy <[email protected]> --- 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 @@ </os> <devices> <disk type='file'> - <driver name='file' type='raw'/> + <driver name='file' type='raw' queues='2' queue_size='256'/> <source file='/tmp/freebsd.img'/> <target dev='nvme0n1' bus='nvme'/> </disk> 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 @@ <on_crash>destroy</on_crash> <devices> <disk type='file' device='disk'> - <driver name='file' type='raw'/> + <driver name='file' type='raw' queues='2' queue_size='256'/> <source file='/tmp/freebsd.img'/> <target dev='nvme0n1' bus='nvme'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> -- 2.51.0
