]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Enforce ACPI, UEFI requirements
authorAndrea Bolognani <abologna@redhat.com>
Thu, 9 Mar 2017 15:38:26 +0000 (16:38 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 3 Apr 2017 08:58:00 +0000 (10:58 +0200)
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.

24 files changed:
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.args
tests/qemuxml2argvdata/qemuxml2argv-aarch64-aavmf-virtio-mmio.xml
tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.args
tests/qemuxml2argvdata/qemuxml2argv-aarch64-video-virtio-gpu-pci.xml
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.xml
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.args
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-default-nic.xml
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.xml
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.args
tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-manual-addresses.xml
tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.args
tests/qemuxml2argvdata/qemuxml2argv-balloon-mmio-deflate.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml

index 64d2d7105071b669a435d9abc1be8c07db14ae8e..5cf383aaea3138dbe433047ddc3ea1e4098a9f6b 100644 (file)
@@ -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;
index b733505d0bbd552d45f3b660995ed3dafa60c084..a3bb7dbc9a255fd2b792ea40c77f3d866d0649f6 100644 (file)
@@ -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"));
+        goto cleanup;
+    }
+
     if (def->os.loader &&
         def->os.loader->secure == VIR_TRISTATE_BOOL_YES) {
         /* These are the QEMU implementation limitations. But we
index bf4b2f79362fdeb0bb8cc9eb2aa9e688bc9b48fd..68fb61b1e4c65d86228bf3054cb98f880d357fd5 100644 (file)
@@ -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 \
index 8c7428cf82e6dba9b799057b1f8c9db056cf43d1..5d7217307b9af4fee2e5cebb8e61da2694141553 100644 (file)
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
     <gic version='2'/>
index 52d2112b8492627bae8efa7f0c21010493bca093..9c8c001f1adaba990545e9beebf33819160d4c2d 100644 (file)
@@ -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
index 4cdf387f36d02e5cda2bc00e7c629e1008bc9e76..0dda095049740e7d80fc20f54f86b4f96984aff1 100644 (file)
@@ -8,7 +8,6 @@
     <type arch="aarch64" machine="virt">hvm</type>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
index 76ee977a3ca2cc56f149a66a978032fba13aa1fa..2f8c51610bebd3147d3c02680c858572daa442d3 100644 (file)
@@ -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,\
index 4b52a731b043610a94015e14b76104e2afd7f6c3..d9a012893296d26cead6d58262ab1be30d7b992e 100644 (file)
@@ -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>
index df03c6e025b33499a30093ae9a239ae293d700df..e99d412a7e536b880688ad7b53ed80135b1bf8f5 100644 (file)
@@ -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 \
index e745101f13b9d4f457f03425948a840940f0d716..43bc0089c943453633515e7446e86a2cbc309d74 100644 (file)
@@ -12,7 +12,6 @@
     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
index 29f65f6b991b3a7641be44547b5dfbfeed183dc3..47d77618b97e339807c41652272ec2704b742f1b 100644 (file)
@@ -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 \
index 3a6f098d0767378e012137b510baf7f07e724633..17ddc9096bee8ac2f3af362ad0189aad499f1ae5 100644 (file)
@@ -4,9 +4,6 @@
   <memory>1048576</memory>
   <currentMemory>1048576</currentMemory>
   <vcpu>1</vcpu>
-  <features>
-    <acpi/>
-  </features>
   <cpu match='exact'>
     <model>cortex-a53</model>
   </cpu>
index b5b010ca41c3896ccb147a3ae84a626152bbbb96..5fef3b48826f9d8bb29eebf4ab8be35f019ca0ce 100644 (file)
@@ -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 \
index ad34615128a5d9dc71f9363c16f9653f4d584388..2692e61c4289afaf2d84e8faec14fae12e3d2ef5 100644 (file)
@@ -12,7 +12,6 @@
     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
index 46ac51d506dd0d40410f057b4f9081685a32c94e..23a5fffd09cf4cfcacae4bee019bfa6b441f1d34 100644 (file)
@@ -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 \
index 2a84a96698cae1e30c946581bd326064a4791b6a..72bf0c95c3d8a0c9980b6cd3e7fe9e91a1d81b48 100644 (file)
@@ -12,7 +12,6 @@
     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
index 06403996e28803391c7b5ff0cc03e4c35c2b2646..54244fdcf73e5f5f25778ad2ec613913d98168c6 100644 (file)
@@ -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 \
index 5e1b494ed7c56f5934877175260dc1ed1731cb3e..fee32588f73d0f734cb9893b49c839f55d224b89 100644 (file)
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
index 10d1362581a2e1c92b35cc21f2eb892fef597e7e..e568e3c3934e0c9e0856dace515e032a9e397daa 100644 (file)
@@ -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 \
index 1b5b48c429337f93e53b0295586c00d6771e527b..49b7d2c60560a63722dfd39ef12f5379b4ef895b 100644 (file)
@@ -12,7 +12,6 @@
     <cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
   </features>
index bea65990e7443c45d5072576086ef3cc359a3e9d..9e728300e567cf4196f4867c2de6523d3f02172b 100644 (file)
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
     <gic version='2'/>
index 2c765e7c356837d8305c9bce3c5c21dc8b4005e4..8590f485ed9a1e930f658abe1c8bc6a89ca3a8a4 100644 (file)
@@ -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'>
index 88a6a6a0c27461d104fefda18e2d0de50a4afef9..e5496424b338891d44731ef8be369888d93944c3 100644 (file)
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
     <gic version='2'/>
index 83cf0d1f51230d1233e903075f5e90041ddfbc09..83d8dcc4a7c58434940f74215c6458e9e37c7779 100644 (file)
@@ -13,7 +13,6 @@
     <boot dev='hd'/>
   </os>
   <features>
-    <acpi/>
     <apic/>
     <pae/>
     <gic version='2'/>