libvirt/libvirt-qemu-Relax-os.loader-type-check-when-validating-doma.patch
2019-09-30 10:58:53 -04:00

99 lines
4.0 KiB
Diff

From f8c3c7f120aafa218615b7f6e4b380538efeb674 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Sat, 13 Jul 2019 09:17:06 +0200
Subject: [PATCH] qemu: Relax os.loader->type check when validating domain
When validating a domain among all the checks there are two that
concern VIR_DOMAIN_LOADER_TYPE_PFLASH specifically. The first
check ensures that on x86 ACPI is enabled when UEFI is requested,
the second ensures that UEFI is used when ACPI is requested on
aarch64. However, check for UEFI is done by plain comparison of
def->os.loader->type which is insufficient because we have
def->os.firmware too.
NB, this wouldn't be a problem for active domain, because on
startup process def->os.loader->type gets filled by
qemuFirmwareEnableFeatures(), but that's not the case for
inactive domains.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1729604
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
(cherry-picked from commit 7711a7346a990810603c0715d3c6ba922eb88c51)
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
src/qemu/qemu_domain.c | 10 ++++++----
.../aarch64-os-firmware-efi.aarch64-latest.args | 1 -
tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml | 1 +
.../aarch64-os-firmware-efi.aarch64-latest.xml | 1 +
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d71d9b3..56fadd5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4230,8 +4230,9 @@ qemuDomainDefValidate(const virDomainDef *def,
}
/* On x86, UEFI requires ACPI */
- if (def->os.loader &&
- def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH &&
+ if ((def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI ||
+ (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",
@@ -4242,8 +4243,9 @@ qemuDomainDefValidate(const virDomainDef *def,
/* 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)) {
+ (def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI &&
+ (!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;
diff --git a/tests/qemuxml2argvdata/aarch64-os-firmware-efi.aarch64-latest.args b/tests/qemuxml2argvdata/aarch64-os-firmware-efi.aarch64-latest.args
index 9821e28..3914b6b 100644
--- a/tests/qemuxml2argvdata/aarch64-os-firmware-efi.aarch64-latest.args
+++ b/tests/qemuxml2argvdata/aarch64-os-firmware-efi.aarch64-latest.args
@@ -29,7 +29,6 @@ format=raw,unit=1 \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc \
-no-shutdown \
--no-acpi \
-boot strict=on \
-kernel /aarch64.kernel \
-initrd /aarch64.initrd \
diff --git a/tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml b/tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml
index c3e25f3..48605f7 100644
--- a/tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml
+++ b/tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml
@@ -13,6 +13,7 @@
<boot dev='hd'/>
</os>
<features>
+ <acpi/>
<apic/>
<pae/>
<gic version='2'/>
diff --git a/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml b/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml
index 529ce6f..1e51d55 100644
--- a/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml
+++ b/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml
@@ -13,6 +13,7 @@
<boot dev='hd'/>
</os>
<features>
+ <acpi/>
<apic/>
<pae/>
<gic version='2'/>
--
2.19.1