[PATCH 1/2] qemu_domain: Strip <acpi/> from s390(x) definitions

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

 



The s390(x) machines never supported ACPI. That didn't stop users
enabling ACPI in their config. As of libvirt-9.2 (98c4e3d073) with new
enough qemu we reject configs which require ACPI, but qemu can't satisfy
it.

This breaks migration of existing VMs with the old wrong configs to new
libvirt installations.

To address this introduce a post-parse fixup removing the ACPI flag
specifically for s390 machines which do enable it in the definition.

The advantage of doing it in post-parse, rather than simply relaxing the
ABI stability check to allow users providing an fixed XML when migrating
(allowing change of the ACPI flag for s390 in ABI stability check, as it
 doesn't impact ABI), is that only the destination installation needs to
be patched in order to preserve migration.

The disadvantage is that users will not be notified that they are using
a broken configuration as it will be silently fixed. This is also the
reason why only specifically s390(x) machines are being fixed up despite
the problem also impacting other legacy architectures not supporting
ACPI as well.

Resolves: https://issues.redhat.com/browse/RHEL-49516
Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 94 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 298f4bfb9e..4f77817215 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5020,6 +5020,98 @@ qemuDomainDefPostParseBasic(virDomainDef *def,
 }


+/**
+ * qemuDomainDefACPIPostParse:
+ * @def: domain definition
+ * @qemuCaps: qemu capabilities object
+ *
+ * Fixup the use of ACPI flag on certain architectures that never supported it
+ * and users for some reason used it, which would break migration to newer
+ * libvirt versions which check whether given machine type supports ACPI.
+ */
+static void
+qemuDomainDefACPIPostParse(virDomainDef *def,
+                           virQEMUCaps *qemuCaps)
+{
+    bool stripACPI = false;
+
+    /* Only cases when ACPI is enabled need to be fixed up */
+    if (def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON)
+        return;
+
+    switch (def->os.arch) {
+    /* x86(_64) and AARCH64 always supported ACPI */
+    case VIR_ARCH_I686:
+    case VIR_ARCH_X86_64:
+    case VIR_ARCH_AARCH64:
+        stripACPI = false;
+        break;
+
+    /* S390 never supported ACPI, but some users enabled it regardless in their
+     * configs for some reason.  In order to fix incoming migration we'll strip
+     * ACPI from those definitions, so that user configs are fixed by updating
+     * only the destination libvirt installation */
+    case VIR_ARCH_S390:
+    case VIR_ARCH_S390X:
+        stripACPI = true;
+        break;
+
+    /* Any other historic architectures could undergo the above treatment but
+     * since there were no user reports of invalid usage we avoid stripping ACPI */
+    case VIR_ARCH_ARMV6L:
+    case VIR_ARCH_ARMV7L:
+    case VIR_ARCH_ARMV7B:
+    case VIR_ARCH_PPC64:
+    case VIR_ARCH_PPC64LE:
+    case VIR_ARCH_ALPHA:
+    case VIR_ARCH_PPC:
+    case VIR_ARCH_PPCEMB:
+    case VIR_ARCH_SH4:
+    case VIR_ARCH_SH4EB:
+    case VIR_ARCH_RISCV32:
+    case VIR_ARCH_SPARC64:
+    case VIR_ARCH_MIPS:
+    case VIR_ARCH_MIPSEL:
+    case VIR_ARCH_MIPS64:
+    case VIR_ARCH_MIPS64EL:
+    case VIR_ARCH_CRIS:
+    case VIR_ARCH_ITANIUM:
+    case VIR_ARCH_LM32:
+    case VIR_ARCH_M68K:
+    case VIR_ARCH_MICROBLAZE:
+    case VIR_ARCH_MICROBLAZEEL:
+    case VIR_ARCH_OR32:
+    case VIR_ARCH_PARISC:
+    case VIR_ARCH_PARISC64:
+    case VIR_ARCH_PPCLE:
+    case VIR_ARCH_SPARC:
+    case VIR_ARCH_UNICORE32:
+    case VIR_ARCH_XTENSA:
+    case VIR_ARCH_XTENSAEB:
+        stripACPI = false;
+        break;
+
+    /* Any modern architecture must obey what qemu reports */
+    case VIR_ARCH_LOONGARCH64:
+    case VIR_ARCH_RISCV64:
+        stripACPI = false;
+        break;
+
+    case VIR_ARCH_NONE:
+    case VIR_ARCH_LAST:
+    default:
+        break;
+    }
+
+    /* To be sure, we only strip ACPI if given machine type doesn't support it
+     * or if the support state is unknown (which effectively means that it's
+     * unsupported, as we don't fixup x86(_64) and AARCH64) */
+    if (stripACPI &&
+        virQEMUCapsMachineSupportsACPI(qemuCaps, def->virtType, def->os.machine) != VIR_TRISTATE_BOOL_YES)
+        def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_TRISTATE_SWITCH_ABSENT;
+}
+
+
 static int
 qemuDomainDefPostParse(virDomainDef *def,
                        unsigned int parseFlags,
@@ -5040,6 +5132,8 @@ qemuDomainDefPostParse(virDomainDef *def,
     if (qemuDomainDefMachinePostParse(def, qemuCaps) < 0)
         return -1;

+    qemuDomainDefACPIPostParse(def, qemuCaps);
+
     if (qemuDomainDefBootPostParse(def, driver, parseFlags) < 0)
         return -1;

-- 
2.45.2




[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