[PATCH v2 4/5] qemu: Enforce ACPI, UEFI requirements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Depending on the architecture, requirements for ACPI and UEFI can
be different; more specifically, while on x86 UEFI requires ACPI,
on aarch64 it's the other way around.

Enforce these requirements when validating the domain, and make
the error message more accurate by mentioning that they're not
necessarily applicable to all architectures.

Several aarch64 test cases had to be tweaked because they would
have failed the validation step otherwise.
---
 src/qemu/qemu_command.c                              | 20 ++++----------------
 src/qemu/qemu_domain.c                               | 20 ++++++++++++++++++++
 .../qemuxml2argv-aarch64-aavmf-virtio-mmio.args      |  1 +
 .../qemuxml2argv-aarch64-aavmf-virtio-mmio.xml       |  1 -
 .../qemuxml2argv-aarch64-cpu-passthrough.args        |  1 +
 .../qemuxml2argv-aarch64-cpu-passthrough.xml         |  1 -
 .../qemuxml2argv-aarch64-video-virtio-gpu-pci.args   |  1 +
 .../qemuxml2argv-aarch64-video-virtio-gpu-pci.xml    |  3 ---
 ...xml2argv-aarch64-virt-2.6-virtio-pci-default.args |  1 +
 ...uxml2argv-aarch64-virt-2.6-virtio-pci-default.xml |  1 -
 .../qemuxml2argv-aarch64-virt-default-nic.args       |  1 +
 .../qemuxml2argv-aarch64-virt-default-nic.xml        |  3 ---
 .../qemuxml2argv-aarch64-virt-virtio.args            |  1 +
 .../qemuxml2argv-aarch64-virt-virtio.xml             |  1 -
 .../qemuxml2argv-aarch64-virtio-pci-default.args     |  1 +
 .../qemuxml2argv-aarch64-virtio-pci-default.xml      |  1 -
 ...xml2argv-aarch64-virtio-pci-manual-addresses.args |  1 +
 ...uxml2argv-aarch64-virtio-pci-manual-addresses.xml |  1 -
 .../qemuxml2argv-balloon-mmio-deflate.args           |  1 +
 .../qemuxml2argv-balloon-mmio-deflate.xml            |  1 -
 .../qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml     |  1 -
 .../qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml  |  1 -
 .../qemuxml2xmlout-aarch64-virtio-pci-default.xml    |  1 -
 ...ml2xmlout-aarch64-virtio-pci-manual-addresses.xml |  1 -
 24 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 64d2d71..5cf383a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9324,18 +9324,16 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
 }
 
 
-static int
+static void
 qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
-                                 virDomainDefPtr def,
-                                 virQEMUCapsPtr qemuCaps)
+                                 virDomainDefPtr def)
 {
-    int ret = -1;
     virDomainLoaderDefPtr loader = def->os.loader;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     int unit = 0;
 
     if (!loader)
-        return 0;
+        return;
 
     switch ((virDomainLoader) loader->type) {
     case VIR_DOMAIN_LOADER_TYPE_ROM:
@@ -9344,12 +9342,6 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
         break;
 
     case VIR_DOMAIN_LOADER_TYPE_PFLASH:
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_ACPI) &&
-            def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("ACPI must be enabled in order to use UEFI"));
-            goto cleanup;
-        }
 
         if (loader->secure == VIR_TRISTATE_BOOL_YES) {
             virCommandAddArgList(cmd,
@@ -9387,10 +9379,7 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
         break;
     }
 
-    ret = 0;
- cleanup:
     virBufferFreeAndReset(&buf);
-    return ret;
 }
 
 
@@ -9827,8 +9816,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
     if (qemuBuildCpuCommandLine(cmd, driver, def, qemuCaps) < 0)
         goto error;
 
-    if (qemuBuildDomainLoaderCommandLine(cmd, def, qemuCaps) < 0)
-        goto error;
+    qemuBuildDomainLoaderCommandLine(cmd, def);
 
     if (!migrateURI && !snapshot && qemuDomainAlignMemorySizes(def) < 0)
         goto error;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 458bb5f..e41e8e4 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2884,6 +2884,26 @@ qemuDomainDefValidate(const virDomainDef *def,
         goto cleanup;
     }
 
+    /* On x86, UEFI requires ACPI */
+    if (def->os.loader &&
+        def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH &&
+        ARCH_IS_X86(def->os.arch) &&
+        def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("UEFI requires ACPI on this architecture"));
+        goto cleanup;
+    }
+
+    /* On aarch64, ACPI requires UEFI */
+    if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON &&
+        def->os.arch == VIR_ARCH_AARCH64 &&
+        (!def->os.loader ||
+         def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("ACPI requires UEFI on this architecture"));
+        return -1;
+    }
+
     if (def->os.loader &&
         def->os.loader->secure == VIR_TRISTATE_BOOL_YES) {
         /* These are the QEMU implementation limitations. But we
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.args
index bf4b2f7..68fb61b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.args
@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
 -nodefconfig \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c \
 -kernel /aarch64.kernel \
 -initrd /aarch64.initrd \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.xml
index 8c7428c..5d72173 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.xml
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
     <gic version='2'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
index 52d2112..9c8c001 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
 -nodefconfig \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c \
 -drive file=/aarch64.raw,format=raw,if=none,id=drive-virtio-disk0 \
 -device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
index 4cdf387..0dda095 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
@@ -8,7 +8,6 @@
     <type arch="aarch64" machine="virt">hvm</type>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.args
index 76ee977..2f8c516 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.args
@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
 -nodefconfig \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64-vgpu/monitor.sock,server,nowait \
+-no-acpi \
 -device ioh3420,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\
 addr=0x1 \
 -device ioh3420,port=0x9,chassis=2,id=pci.2,bus=pcie.0,multifunction=on,\
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.xml
index 4b52a73..d9a0128 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.xml
@@ -7,9 +7,6 @@
   <os>
     <type arch='aarch64' machine='virt'>hvm</type>
   </os>
-  <features>
-    <acpi/>
-  </features>
   <cpu mode='custom' match='exact'>
     <model fallback='allow'>cortex-a57</model>
   </cpu>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args
index df03c6e..e99d412 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args
@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
 -nodefconfig \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c \
 -kernel /aarch64.kernel \
 -initrd /aarch64.initrd \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.xml
index e745101..43bc008 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.xml
@@ -12,7 +12,6 @@
     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.args
index 29f65f6..47d7761 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.args
@@ -17,6 +17,7 @@ QEMU_AUDIO_DRV=none \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64-virt-default/monitor.sock,server,\
 nowait \
+-no-acpi \
 -boot c \
 -kernel /aarch64.kernel \
 -initrd /aarch64.initrd \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.xml
index 3a6f098..17ddc90 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.xml
@@ -4,9 +4,6 @@
   <memory>1048576</memory>
   <currentMemory>1048576</currentMemory>
   <vcpu>1</vcpu>
-  <features>
-    <acpi/>
-  </features>
   <cpu match='exact'>
     <model>cortex-a53</model>
   </cpu>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
index b5b010c..5fef3b4 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
 -nodefconfig \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c \
 -kernel /aarch64.kernel \
 -initrd /aarch64.initrd \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
index ad34615..2692e61 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
@@ -12,7 +12,6 @@
     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args
index 46ac51d..23a5fff 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args
@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
 -nodefconfig \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c \
 -kernel /aarch64.kernel \
 -initrd /aarch64.initrd \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.xml
index 2a84a96..72bf0c9 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.xml
@@ -12,7 +12,6 @@
     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args
index 0640399..54244fd 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args
@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
 -nodefconfig \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c \
 -kernel /aarch64.kernel \
 -initrd /aarch64.initrd \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml
index 5e1b494..fee3258 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
index 10d1362..e568e3c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
@@ -16,6 +16,7 @@ QEMU_AUDIO_DRV=none \
 -nodefconfig \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c \
 -kernel /aarch64.kernel \
 -initrd /aarch64.initrd \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
index 1b5b48c..49b7d2c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
@@ -12,7 +12,6 @@
     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml
index bea6599..9e72830 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
     <gic version='2'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml
index 2c765e7..8590f48 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml
@@ -8,7 +8,6 @@
     <type arch='aarch64' machine='virt'>hvm</type>
   </os>
   <features>
-    <acpi/>
     <gic version='2'/>
   </features>
   <cpu mode='custom' match='exact' check='none'>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
index 88a6a6a..e549642 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
     <gic version='2'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml
index 83cf0d1..83d8dcc 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
     <gic version='2'/>
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux