From nobody Mon Feb 9 09:18:51 2026 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 1740759557748767.0557383942551; Fri, 28 Feb 2025 08:19:17 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 58E1F156D; Fri, 28 Feb 2025 11:19:16 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D57A11570; Fri, 28 Feb 2025 11:18:53 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 08DF5156B; Fri, 28 Feb 2025 11:18:51 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 84F501568 for ; Fri, 28 Feb 2025 11:18:50 -0500 (EST) 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-189-bK-Qd0WJOPCjqB_OYyMOsg-1; Fri, 28 Feb 2025 11:18:48 -0500 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 B121419540ED for ; Fri, 28 Feb 2025 16:18:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.15]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D316019560AE for ; Fri, 28 Feb 2025 16:18:43 +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_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,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=1740759530; 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; bh=wM9sUb5Ys7m5z0q/eKCNC0oShvD6FWedUCPaP/Q6VlY=; b=MmJAZH9VezBPDy7fW/F61p/YMHsFH0kaCvoqpsd5ozRMWs9lONwNR7QEpiW6K5wYofZ8oa 0KBDFK4plRck1Il1Fksnat07PTIzBx0V85Xxo5GjnmZ1k7f3Ef3MhXBWmjOP2MCim3vHev oxw98+OtLV/ai6EWLRADipE+DV3fIB0= X-MC-Unique: bK-Qd0WJOPCjqB_OYyMOsg-1 X-Mimecast-MFC-AGG-ID: bK-Qd0WJOPCjqB_OYyMOsg_1740759524 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH] qemuPrepareNVRAMFile: Fix NVRAM image conversion check Date: Fri, 28 Feb 2025 17:18:42 +0100 Message-ID: <3d9331ded372a35bfdd0814d30d7c68927af63ac.1740759522.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: XjWIHJdaNWAPqGf0KD4sSV8IvDw8K3oikjrfUNqswD8_1740759524 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CK3FUSPHECBIHRRQYBTTS4DSZSGESPIB X-Message-ID-Hash: CK3FUSPHECBIHRRQYBTTS4DSZSGESPIB 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: 1740759560013019100 Content-Type: text/plain; charset="utf-8" In case when user provides custom paths (those not covered by the JSON firmware descriptor files or the default locations) for the loader and nvram template no auto-detection will be performed and user's config will be taken at face value. Historically when 'templateFormat' didn't exist we assumed that the 'format' field covers both. Thus if 'templateFormat' is VIR_STORAGE_FILE_NONE we need to skip the check forbidding image format conversion for 'file' backed to avoid breaking legacy configs with manual/non-detected format assuming that user picked the correct format. Add a comment to the declaration of 'nvramTemplateFormat' noting the above for future reference. Resolves: https://issues.redhat.com/browse/RHEL-81731 Fixes: 2aa644a2fc8 Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/conf/domain_conf.h | 7 +++++++ src/qemu/qemu_process.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d4fa79cb84..1fcc3fdb98 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2362,6 +2362,13 @@ struct _virDomainLoaderDef { virStorageSource *nvram; bool newStyleNVRAM; char *nvramTemplate; /* user override of path to master nvram */ + /* Historically it was assumed that the format of the template and the + * actual nvram image are identical, which is no longer true. + * + * Note: if 'nvramTemplate' comes from the user and is not overriden by + * auto-detection nvramTemplateFormat may be VIR_STORAGE_FILE_NONE. Co= de + * shall assume that the template format matches if it isn't provided. + */ virStorageFileFormat nvramTemplateFormat; }; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0d9b8bcb93..7b7b5c17e3 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4709,7 +4709,10 @@ qemuPrepareNVRAMFile(virQEMUDriver *driver, return -1; } - if (loader->nvram->format !=3D loader->nvramTemplateFormat) { + /* If 'nvramTemplateFormat' is empty it means that it's a user-provided + * template which we couldn't verify. Assume the user knows what they'= re doing */ + if (loader->nvramTemplateFormat !=3D VIR_STORAGE_FILE_NONE && + loader->nvram->format !=3D loader->nvramTemplateFormat) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("conversion of the nvram template to another targ= et format is not supported")); return -1; --=20 2.48.1