qemu: Enforce ACPI, UEFI requirements

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.
This commit is contained in:
Andrea Bolognani 2017-03-09 16:38:26 +01:00
parent 560335c35c
commit 396ca36cb0
24 changed files with 33 additions and 33 deletions

View 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;

View 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

View 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 \

View File

@ -13,7 +13,6 @@
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
<gic version='2'/>

View 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

View File

@ -8,7 +8,6 @@
<type arch="aarch64" machine="virt">hvm</type>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>

View 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,\

View 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>

View 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 \

View File

@ -12,7 +12,6 @@
<cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>

View 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 \

View 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>

View 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 \

View File

@ -12,7 +12,6 @@
<cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>

View 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 \

View File

@ -12,7 +12,6 @@
<cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>

View 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 \

View File

@ -13,7 +13,6 @@
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>

View 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 \

View File

@ -12,7 +12,6 @@
<cmdline>earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait</cmdline>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>

View File

@ -13,7 +13,6 @@
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
<gic version='2'/>

View 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'>

View File

@ -13,7 +13,6 @@
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
<gic version='2'/>

View File

@ -13,7 +13,6 @@
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
<gic version='2'/>