From nobody Mon Feb 9 16:02:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1691686385; cv=none; d=zohomail.com; s=zohoarc; b=HvNv1tGYUXLjAZ+YReNpERcBTpqGCjSqdFXneWYB03dHvdo4PMYePL34Z2RFZNh3ay1Lf5XvHTwbTsE+CTU827fjXSJWZlPGEFQTXyPx1Q6uLlKIYB91ZidNtSpLQ4aH8fqnfQXLUU+Nso0AFfgVrjWgMiP82K+MbHFBviuWPRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691686385; 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=Vua2fij043HnLxxK2brlAPPns4DzCPA2o9S/cpPHJUA=; b=G47/wQo1EGACSINNjyqZlNTj07/b/xhdTu23ybJIFRdjJQqqwChgHlAPSmMli/THDvm71DEyu1v+nOBvrbHTx3jrI2SShSduRlnXl+lFExoxD7BFE4TcUpAFKyirO/C1dAxUrBsoWS2AWw7EeIL5LjOe8HVKTv8ly6VWm/1w1Ls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 169168638595470.77857957999993; Thu, 10 Aug 2023 09:53:05 -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-634-8SSClBFHNJ-ShKbEIDOjMg-1; Thu, 10 Aug 2023 12:51:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8680C805587; Thu, 10 Aug 2023 16:51:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72BC8C15E69; Thu, 10 Aug 2023 16:51:06 +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 9BC361946A6A; Thu, 10 Aug 2023 16:51:00 +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 60223194658F for ; Thu, 10 Aug 2023 16:50:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 41869140E973; Thu, 10 Aug 2023 16:50:52 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE0BF140E96F for ; Thu, 10 Aug 2023 16:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691686385; 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=Vua2fij043HnLxxK2brlAPPns4DzCPA2o9S/cpPHJUA=; b=a2Kl0Q4FoKlRhvIARZdBk/hVwpNjQmjjee4pLBfjBga1+e5uqmFVsELwkk+hpHQ9M5Sd5U byiqtJ1axUpQZkHkWuBBxuNrxRWYRxtSISH6QI9tPd6vUYHj0Vkmi7GneVphPzBvRdbSn1 G4kRW2QHsHe4QscJnarJF3QQtyQwWjc= X-MC-Unique: 8SSClBFHNJ-ShKbEIDOjMg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 14/21] qemu: Don't overwrite NVRAM template for legacy firmware Date: Thu, 10 Aug 2023 18:50:31 +0200 Message-ID: <20230810165038.169700-15-abologna@redhat.com> In-Reply-To: <20230810165038.169700-1-abologna@redhat.com> References: <20230810165038.169700-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.8 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: 1691686387553100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Just because we have found a matching entry, it doesn't mean that we should discard the information explicitly provided in the domain XML. https://bugzilla.redhat.com/show_bug.cgi?id=3D2196178 https://gitlab.com/libvirt/libvirt/-/issues/500 Signed-off-by: Andrea Bolognani --- src/qemu/qemu_firmware.c | 26 +++++++++++++++++-- ...efi-secboot-legacy-paths.x86_64-latest.xml | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index b1d342563b..a9437b5b95 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1609,8 +1609,30 @@ qemuFirmwareFillDomainLegacy(virQEMUDriver *driver, loader->type =3D VIR_DOMAIN_LOADER_TYPE_PFLASH; loader->readonly =3D VIR_TRISTATE_BOOL_YES; =20 - VIR_FREE(loader->nvramTemplate); - loader->nvramTemplate =3D g_strdup(cfg->firmwares[i]->nvram); + /* Only use the default template path if one hasn't been + * provided by the user. + * + * In addition to fully-custom templates, which are a valid + * use case, we could simply be in a situation where + * qemu.conf contains + * + * nvram =3D [ + * "/path/to/OVMF_CODE.secboot.fd:/path/to/OVMF_VARS.fd", + * "/path/to/OVMF_CODE.secboot.fd:/path/to/OVMF_VARS.secboot.f= d" + * ] + * + * and the domain has been configured as + * + * + * /path/to/OVMF_CODE= .secboot.fd + * + * + * + * In this case, the global default is to have Secure Boot + * disabled, but the domain configuration explicitly enables + * it, and we shouldn't overrule this choice */ + if (!loader->nvramTemplate) + loader->nvramTemplate =3D g_strdup(cfg->firmwares[i]->nvram); =20 qemuFirmwareEnsureNVRAM(def, cfg, VIR_STORAGE_FILE_RAW); =20 diff --git a/tests/qemuxml2xmloutdata/firmware-manual-efi-secboot-legacy-pa= ths.x86_64-latest.xml b/tests/qemuxml2xmloutdata/firmware-manual-efi-secboo= t-legacy-paths.x86_64-latest.xml index b8c2dfef66..9027123558 100644 --- a/tests/qemuxml2xmloutdata/firmware-manual-efi-secboot-legacy-paths.x86= _64-latest.xml +++ b/tests/qemuxml2xmloutdata/firmware-manual-efi-secboot-legacy-paths.x86= _64-latest.xml @@ -7,7 +7,7 @@ hvm /usr/share/OVM= F/OVMF_CODE.secboot.fd - /var/lib/libvirt/qemu= /nvram/guest_VARS.fd + /var/lib/libv= irt/qemu/nvram/guest_VARS.fd --=20 2.41.0