From nobody Wed Feb 11 05:11:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681235564; cv=none; d=zohomail.com; s=zohoarc; b=FNbT4SCM3FMg/i3UHlpbLsD9zKvkyv7qnDT66hyDlXTU/a0A1fpgD23AboiAR2SwvsuFUtCmv5sQ3R1h4WTZuVdZGZBTzqOc/tPvAFDxGkVvhwOgPlgT0JYHf2c/NCBinyCPj5II8UNaRKRyl2opd2D19cmdSSAC5zUW55K+fHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681235564; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0bVWG7UJ4qsgbvalDx1E+DXMvn1o2kp/FQGp0GhFEU0=; b=PczPdGA/5Pkx6cZbVH9WdGOfryNvP36OWN09cwd6fQzJbiMQ5SKSu0ecs8exmOr8KtNFTtW1GjNBguQ/7aSj0ExaDCbD2XPjN5bhkGihXHMVYfXtUjKwJzJs9SKR+857i1eS8RTbbSLelVGjUv95aS9M1Bh9FPU1V4fnyTUWEUQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16812355644139.530183556273528; Tue, 11 Apr 2023 10:52:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-252-alWno0vpMR6mMsXlEtrw9w-1; Tue, 11 Apr 2023 13:52:39 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C43687B2C4; Tue, 11 Apr 2023 17:52:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07025492B03; Tue, 11 Apr 2023 17:52:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CC2C01946A41; Tue, 11 Apr 2023 17:52:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0758319466DF for ; Tue, 11 Apr 2023 17:52:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DD5911417202; Tue, 11 Apr 2023 17:52:33 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.226.242]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4516C14171D6 for ; Tue, 11 Apr 2023 17:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681235563; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0bVWG7UJ4qsgbvalDx1E+DXMvn1o2kp/FQGp0GhFEU0=; b=GfmFTGg2fc+s0Nvx2ijw3yLsq2w04cwhSmw1cJ0NC0FKykG38TedwjRP8NL7AurkKH0pIX u3THjoDT7W3UhsRabSvALffBz53G6LMu27I/Ci36vGVogJHHx9Kr0WvirSmZAyQzgq2MhV lXQH3ifrR13CLp6VjnJozIGbRerxmYc= X-MC-Unique: alWno0vpMR6mMsXlEtrw9w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] conf: Fix migration in some firmware autoselection scenarios Date: Tue, 11 Apr 2023 19:52:28 +0200 Message-Id: <20230411175228.102597-3-abologna@redhat.com> In-Reply-To: <20230411175228.102597-1-abologna@redhat.com> References: <20230411175228.102597-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681235565890100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduce a small kludge in the parser to avoid unnecessarily blocking incoming migration from a range of recent libvirt releases. https://bugzilla.redhat.com/show_bug.cgi?id=3D2184966 Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 39 ++++++++++++++++++- ...are-manual-efi-features.x86_64-latest.args | 35 +++++++++++++++++ tests/qemuxml2argvtest.c | 6 ++- ...ware-manual-efi-features.x86_64-latest.xml | 36 +++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 5 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/firmware-manual-efi-features.x86= _64-latest.args create mode 100644 tests/qemuxml2xmloutdata/firmware-manual-efi-features.x= 86_64-latest.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 70e4d52ee6..bc20acf103 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17210,11 +17210,13 @@ virDomainDefParseBootKernelOptions(virDomainDef *= def, =20 static int virDomainDefParseBootFirmwareOptions(virDomainDef *def, - xmlXPathContextPtr ctxt) + xmlXPathContextPtr ctxt, + unsigned int flags) { g_autofree char *firmware =3D virXPathString("string(./os/@firmware)",= ctxt); g_autofree xmlNodePtr *nodes =3D NULL; g_autofree int *features =3D NULL; + bool abiUpdate =3D !!(flags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE); int fw =3D 0; int n =3D 0; size_t i; @@ -17222,6 +17224,39 @@ virDomainDefParseBootFirmwareOptions(virDomainDef = *def, if ((n =3D virXPathNodeSet("./os/firmware/feature", ctxt, &nodes)) < 0) return -1; =20 + /* Migration compatibility kludge. + * + * Between 8.6.0 and 9.1.0 (extremes included), the migratable + * XML produced when feature-based firmware autoselection was + * enabled looked like + * + * + * + * + * + * Notice how there's no firmware=3D'foo' attribute for the + * element, meaning that firmware autoselection is disabled, and + * yet some elements, which are used to control the + * firmware autoselection process, are present. We don't consider + * this to be a valid combination, and want such a configuration + * to get rejected when submitted by users. + * + * In order to achieve that, while at the same time keeping + * migration coming from the libvirt versions listed above + * working, we can simply stop parsing early and ignore the + * tags when firmware autoselection is not enabled, + * *except* if we're defining a new domain. + * + * This is safe to do because the configuration will either come + * from another libvirt instance, in which case it will have a + * properly filled in element that contains enough + * information to successfully define and start the domain, or it + * will be a random configuration that lacks such information, in + * which case a different failure will be reported anyway. + */ + if (n > 0 && !firmware && !abiUpdate) + return 0; + if (n > 0) features =3D g_new0(int, VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_LAST); =20 @@ -17350,7 +17385,7 @@ virDomainDefParseBootOptions(virDomainDef *def, case VIR_DOMAIN_OSTYPE_HVM: virDomainDefParseBootKernelOptions(def, ctxt); =20 - if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0) + if (virDomainDefParseBootFirmwareOptions(def, ctxt, flags) < 0) return -1; =20 if (virDomainDefParseBootLoaderOptions(def, ctxt, xmlopt, flags) <= 0) diff --git a/tests/qemuxml2argvdata/firmware-manual-efi-features.x86_64-lat= est.args b/tests/qemuxml2argvdata/firmware-manual-efi-features.x86_64-lates= t.args new file mode 100644 index 0000000000..57c71542cd --- /dev/null +++ b/tests/qemuxml2argvdata/firmware-manual-efi-features.x86_64-latest.args @@ -0,0 +1,35 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-guest \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dguest,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-guest/master-key.aes"}' \ +-blockdev '{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.fd","nod= e-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'= \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver"= :"raw","file":"libvirt-pflash0-storage"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/guest_= VARS.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"disca= rd":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash1-storage"}' \ +-machine pc-i440fx-4.0,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc= .ram,pflash0=3Dlibvirt-pflash0-format,pflash1=3Dlibvirt-pflash1-format,acpi= =3Don \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e055d372fa..1808d9fc02 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1051,7 +1051,11 @@ mymain(void) DO_TEST_CAPS_LATEST("firmware-manual-bios-stateless"); DO_TEST_CAPS_LATEST_PARSE_ERROR("firmware-manual-bios-not-stateless"); DO_TEST_CAPS_LATEST("firmware-manual-efi"); - DO_TEST_CAPS_LATEST_PARSE_ERROR("firmware-manual-efi-features"); + DO_TEST_CAPS_LATEST("firmware-manual-efi-features"); + DO_TEST_CAPS_ARCH_LATEST_FULL("firmware-manual-efi-features", "x86_64", + ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR, + ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI= _UPDATE, + ARG_END); DO_TEST_CAPS_LATEST("firmware-manual-efi-rw"); DO_TEST_CAPS_LATEST("firmware-manual-efi-rw-implicit"); DO_TEST_CAPS_LATEST("firmware-manual-efi-loader-secure"); diff --git a/tests/qemuxml2xmloutdata/firmware-manual-efi-features.x86_64-l= atest.xml b/tests/qemuxml2xmloutdata/firmware-manual-efi-features.x86_64-la= test.xml new file mode 100644 index 0000000000..dc4b8bb97f --- /dev/null +++ b/tests/qemuxml2xmloutdata/firmware-manual-efi-features.x86_64-latest.x= ml @@ -0,0 +1,36 @@ + + guest + 63840878-0deb-4095-97e6-fc444d9bc9fa + 1048576 + 1048576 + 1 + + hvm + + + + + /usr/share/OVMF/OVMF_CODE.fd<= /loader> + /var/lib/libvirt/qemu= /nvram/guest_VARS.fd + + + + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index e19aba0878..b1bc6e9216 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -866,6 +866,7 @@ mymain(void) DO_TEST_CAPS_LATEST("firmware-manual-bios"); DO_TEST_CAPS_LATEST("firmware-manual-bios-stateless"); DO_TEST_CAPS_LATEST("firmware-manual-efi"); + DO_TEST_CAPS_LATEST("firmware-manual-efi-features"); DO_TEST_CAPS_LATEST("firmware-manual-efi-rw"); DO_TEST_CAPS_LATEST("firmware-manual-efi-rw-implicit"); DO_TEST_CAPS_LATEST("firmware-manual-efi-loader-secure"); --=20 2.39.2