]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: support queue configuration for NVMe disks
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Sat, 8 Nov 2025 08:12:50 +0000 (09:12 +0100)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Tue, 11 Nov 2025 18:25:04 +0000 (19:25 +0100)
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 <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/bhyve/bhyve_command.c
tests/bhyvexml2argvdata/bhyvexml2argv-nvme.args
tests/bhyvexml2argvdata/bhyvexml2argv-nvme.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-nvme.xml

index 0ceac618e874dd57d20c3f4c40bacc9c1e3b0633..8bfd5a6f936230b3e47b5bae40bbf69ab9f7a925 100644 (file)
@@ -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;
index bd39db1fe6581250f678e307f1c9482c0c31199b..80877717f28545d13c3bd95a6c41679edd2518fd 100644 (file)
@@ -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
index 8daaa11e85fc954a5d21e4a86ea0c648b95bfe66..5401ed6ad8c22018c441dada986aacfc58b0934d 100644 (file)
@@ -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>
index d4ab69b15f0c5a3deace4132fa6e6ddeb4458107..40a1ea1c5ea57a0b6de8364eb8d879d3beeb3231 100644 (file)
@@ -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'/>