From nobody Thu Oct 31 00:24:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1722423809331861.0351124335278; Wed, 31 Jul 2024 04:03:29 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3041913F1; Wed, 31 Jul 2024 07:03:28 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A232ABC3; Wed, 31 Jul 2024 07:02:39 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A800092E; Wed, 31 Jul 2024 07:02:34 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1EDFDB14 for ; Wed, 31 Jul 2024 07:02:34 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-568-SVetZwcQNu2kYSW0Ofn9rQ-1; Wed, 31 Jul 2024 07:02:32 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 702721955D4B for ; Wed, 31 Jul 2024 11:02:31 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.16]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7A3E31955D4B for ; Wed, 31 Jul 2024 11:02:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722423753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WJVrgNTGzk0dbInmIndOpp8SgL/v7ImO9hJLo37ZsRY=; b=d9N7lbndpPGVroNmdazR/2glZu8Ke1LoYZMxZZDwm2NCXZgxpNNoY5D2PjKjgPTdIsM7N1 B2Js2rxtSUsrSLSFmdCBk9sZnQI/7xHqJHC1y4KST5fWDoCAARqSV2Kht3JXJR0Eak36ae TBlqJFyi+5j4f7TNB+V1/6b+OjHs0Z0= X-MC-Unique: SVetZwcQNu2kYSW0Ofn9rQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 1/2] qemu_domain: Strip from s390(x) definitions Date: Wed, 31 Jul 2024 13:02:26 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MDEDDHIZLFPOTLVQCJMHKFKOPBYGXCSV X-Message-ID-Hash: MDEDDHIZLFPOTLVQCJMHKFKOPBYGXCSV X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1722423811388116600 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Boris Fiuczynski --- 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 supporte= d 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 =3D false; + + /* Only cases when ACPI is enabled need to be fixed up */ + if (def->features[VIR_DOMAIN_FEATURE_ACPI] !=3D 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 =3D 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 upda= ting + * only the destination libvirt installation */ + case VIR_ARCH_S390: + case VIR_ARCH_S390X: + stripACPI =3D true; + break; + + /* Any other historic architectures could undergo the above treatment = but + * since there were no user reports of invalid usage we avoid strippin= g 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 =3D false; + break; + + /* Any modern architecture must obey what qemu reports */ + case VIR_ARCH_LOONGARCH64: + case VIR_ARCH_RISCV64: + stripACPI =3D 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 suppor= t 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.ma= chine) !=3D VIR_TRISTATE_BOOL_YES) + def->features[VIR_DOMAIN_FEATURE_ACPI] =3D VIR_TRISTATE_SWITCH_ABS= ENT; +} + + 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; --=20 2.45.2