]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: domain: improve disks validation
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Sun, 9 Nov 2025 10:10:54 +0000 (11:10 +0100)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Tue, 11 Nov 2025 18:25:11 +0000 (19:25 +0100)
Do not allow to configure queues and queue size for non-NVMe disks.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/bhyve/bhyve_domain.c
tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio-queue-opts.xml [new file with mode: 0644]
tests/bhyvexml2argvtest.c

index 16ca4b1d0f23bd7285f84c3274ef6ca253c23ab4..4c9ed29333b4739d9228da9b2d394595dc0f18bd 100644 (file)
@@ -316,6 +316,13 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev,
             return -1;
         }
 
+        if ((disk->queues || disk->queue_size) &&
+            disk->bus != VIR_DOMAIN_DISK_BUS_NVME) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("queue configuration is only valid for NVMe bus"));
+            return -1;
+        }
+
         break;
     }
     case VIR_DOMAIN_DEVICE_AUDIO:
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio-queue-opts.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio-queue-opts.xml
new file mode 100644 (file)
index 0000000..1119c37
--- /dev/null
@@ -0,0 +1,23 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw' queues='4' queue_size='512'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='vda' bus='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </disk>
+    <interface type='bridge'>
+      <mac address='52:54:00:bc:85:fe'/>
+      <model type='virtio'/>
+      <source bridge="virbr0"/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+  </devices>
+</domain>
index f7411ee094f7270d74a4b4ea5c4dbd9589524ad6..2a785ef8aa3b91745a182e9e9db11f87454e941e 100644 (file)
@@ -267,6 +267,7 @@ mymain(void)
     DO_TEST_FAILURE("2-nvme-same-controller");
     DO_TEST("sata-rotation-rate");
     DO_TEST_FAILURE("disk-virtio-rotation-rate");
+    DO_TEST_FAILURE("disk-virtio-queue-opts");
 
     /* Address allocation tests */
     DO_TEST("addr-single-sata-disk");