]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Validate that iothreads are used only with 'virtio-scsi' controllers
authorPeter Krempa <pkrempa@redhat.com>
Fri, 14 Feb 2025 15:30:58 +0000 (16:30 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 20 Feb 2025 14:21:45 +0000 (15:21 +0100)
The documentation states:

 ``iothread``
    Supported for controller type ``scsi`` using model ``virtio-scsi`` for
    ``address`` types ``pci`` and ``ccw`` :since:`since 1.3.5 (QEMU 2.4)`. The

The code itself didn't validate if iothread is specified for any other
controller type.

Add test case showing the issue on one example.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_validate.c
tests/qemuxmlconfdata/controller-virtio-serial-iothread.x86_64-latest.err [new file with mode: 0644]
tests/qemuxmlconfdata/controller-virtio-serial-iothread.xml [new file with mode: 0644]
tests/qemuxmlconftest.c

index 563558d9208e9ac390dded1b930f25e99f790973..ad3d17f0fd13cd3a325c2dd4a83fcdda7e355357 100644 (file)
@@ -1260,6 +1260,17 @@ virDomainControllerDefValidate(const virDomainControllerDef *controller)
         }
     }
 
+    if (controller->iothread != 0) {
+        if (controller->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI ||
+            !(controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI ||
+              controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL ||
+              controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("iothreads are supported only by 'virtio-scsi' controllers"));
+            return -1;
+        }
+    }
+
     return 0;
 }
 
diff --git a/tests/qemuxmlconfdata/controller-virtio-serial-iothread.x86_64-latest.err b/tests/qemuxmlconfdata/controller-virtio-serial-iothread.x86_64-latest.err
new file mode 100644 (file)
index 0000000..ac4d8b2
--- /dev/null
@@ -0,0 +1 @@
+XML error: 'iothread' attribute only supported for virtio scsi controllers
diff --git a/tests/qemuxmlconfdata/controller-virtio-serial-iothread.xml b/tests/qemuxmlconfdata/controller-virtio-serial-iothread.xml
new file mode 100644 (file)
index 0000000..0b52309
--- /dev/null
@@ -0,0 +1,27 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='virtio-serial' index='0'>
+      <driver iothread='3'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <console type='pty'>
+      <target type='virtio'/>
+    </console>
+  </devices>
+</domain>
index c271170d25b000694af60f4f6b86c76eb2b85d42..905b283f94e52d0b628e220ba4b960deac90c3ab 100644 (file)
@@ -2824,6 +2824,8 @@ mymain(void)
     DO_TEST_CAPS_LATEST("virtio-options-rng-packed");
     DO_TEST_CAPS_LATEST("virtio-options-video-packed");
 
+    DO_TEST_CAPS_LATEST_PARSE_ERROR("controller-virtio-serial-iothread");
+
     DO_TEST_CAPS_LATEST("fd-memory-numa-topology");
     DO_TEST_CAPS_LATEST("fd-memory-numa-topology2");
     DO_TEST_CAPS_LATEST("fd-memory-numa-topology3");