]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Reject features when using manual firmware selection
authorAndrea Bolognani <abologna@redhat.com>
Mon, 20 Jun 2022 15:44:31 +0000 (17:44 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 1 Jul 2022 13:10:37 +0000 (15:10 +0200)
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_validate.c
tests/qemuxml2argvdata/firmware-manual-efi-features.x86_64-latest.err [new file with mode: 0644]
tests/qemuxml2argvdata/firmware-manual-efi-features.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 355668b04293941b3d2a1a1390add952c310017d..c977c39144f16c1d9ab0ecb3f9d3bdc2b5556b06 100644 (file)
@@ -1655,6 +1655,13 @@ virDomainDefOSValidate(const virDomainDef *def,
             return -1;
         }
     } else {
+        if (def->os.firmwareFeatures) {
+            virReportError(VIR_ERR_XML_DETAIL, "%s",
+                           _("cannot use feature-based firmware autoselection "
+                             "when firmware autoselection is disabled"));
+            return -1;
+        }
+
         if (!loader)
             return 0;
 
diff --git a/tests/qemuxml2argvdata/firmware-manual-efi-features.x86_64-latest.err b/tests/qemuxml2argvdata/firmware-manual-efi-features.x86_64-latest.err
new file mode 100644 (file)
index 0000000..98412de
--- /dev/null
@@ -0,0 +1 @@
+cannot use feature-based firmware autoselection when firmware autoselection is disabled
diff --git a/tests/qemuxml2argvdata/firmware-manual-efi-features.xml b/tests/qemuxml2argvdata/firmware-manual-efi-features.xml
new file mode 100644 (file)
index 0000000..69cc71e
--- /dev/null
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+  <name>test</name>
+  <uuid>362d1fc1-df7d-193e-5c18-49a71bd1da66</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
+    <firmware>
+      <feature enabled='no' name='enrolled-keys'/>
+    </firmware>
+  </os>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='usb' model='none'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
index 473e00ffa7efa72fc209a078228896329fe7e815..4ca113137767bc4fe5de8e1de63b0c9825cd78b3 100644 (file)
@@ -1192,6 +1192,7 @@ mymain(void)
             QEMU_CAPS_DEVICE_ISA_SERIAL);
     DO_TEST_NOCAPS("firmware-manual-efi");
     DO_TEST_PARSE_ERROR_NOCAPS("firmware-manual-efi-no-path");
+    DO_TEST_CAPS_LATEST_PARSE_ERROR("firmware-manual-efi-features");
     DO_TEST_CAPS_LATEST("firmware-manual-bios-rw");
     DO_TEST_CAPS_LATEST("firmware-manual-bios-rw-implicit");
     DO_TEST("firmware-manual-efi-secure",