From nobody Sat Nov 23 11:48:57 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 1730793587680833.0799006569073; Mon, 4 Nov 2024 23:59:47 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8E0431255; Tue, 5 Nov 2024 02:59:46 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id AF36911B1; Tue, 5 Nov 2024 02:58:24 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3D1FDE72; Tue, 5 Nov 2024 02:58:19 -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 AEF10D94 for ; Tue, 5 Nov 2024 02:58:18 -0500 (EST) Received: from mx-prod-mc-05.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-589-jVfJR_EuOW-CYnHfXfghEQ-1; Tue, 05 Nov 2024 02:58:17 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 587531955E99 for ; Tue, 5 Nov 2024 07:58:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 901A53000198 for ; Tue, 5 Nov 2024 07:58:15 +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.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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=1730793498; 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=azipwOFJWD6xW51TJ0TjdvYE9PDsracNMkKH22NihSI=; b=RUrOfX9WFzUZ1QFsEKKXqXCoqOTaqW1Q4okAQ0mhAxb9J6jlZan6owzO7Q0sz9WUsaGlyN KZySwOdwPXxkXPvASBsAzFvinrQT/tVI35hS7gME56fGKdT+miH7JBDcWcNc602CS1YD71 FSDMHbH1xPorXti9I0Ft/N4x12EP/vg= X-MC-Unique: jVfJR_EuOW-CYnHfXfghEQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 02/13] qemuFirmwareEnsureNVRAM: Don't try to setup non-local nvram Date: Tue, 5 Nov 2024 08:58:00 +0100 Message-ID: <3da8e66ee4360ad2e0171aff339fdd3c1cecb23c.1730793407.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: E75VS2CNN6W5HMO5PHM4V7EXMAB7X54F X-Message-ID-Hash: E75VS2CNN6W5HMO5PHM4V7EXMAB7X54F 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: 1730793588750116600 Content-Type: text/plain; charset="utf-8" 'qemuFirmwareEnsureNVRAM' which fills the NVRAM configuration bits which may be missing was basing it's decision to do something based on whether the 'path' field was set. This is insufficient if remote storage is to be considered. Use 'virStorageSourceIsEmpty()' instead as that properly considers remote filesystems and explain why the source is unref'd when the function decides to rewrite the config. The 'firmware-auto-efi-format-nvram-qcow2-network-nbd' is modified to omit filling the 'path' field, which without this fix would result in the nvram to be reset to a local file. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_firmware.c | 11 ++++++----- ...-format-nvram-qcow2-network-nbd.x86_64-latest.args | 2 +- ...i-format-nvram-qcow2-network-nbd.x86_64-latest.xml | 2 +- ...rmware-auto-efi-format-nvram-qcow2-network-nbd.xml | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 914f8596bd..5c247b1cf2 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1054,13 +1054,14 @@ qemuFirmwareEnsureNVRAM(virDomainDef *def, if (loader->nvram && !loader->nvram->format) loader->nvram->format =3D loader->format; - /* If the source already exists and is fully specified, including - * the path, leave it alone */ - if (loader->nvram && loader->nvram->path) - return; + if (loader->nvram) { + /* Nothing to do if a proper NVRAM backend is already configured */ + if (!virStorageSourceIsEmpty(loader->nvram)) + return; - if (loader->nvram) + /* otherwise we want to reset and re-populate the definition */ virObjectUnref(loader->nvram); + } loader->nvram =3D virStorageSourceNew(); loader->nvram->type =3D VIR_STORAGE_TYPE_FILE; diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-net= work-nbd.x86_64-latest.args b/tests/qemuxmlconfdata/firmware-auto-efi-forma= t-nvram-qcow2-network-nbd.x86_64-latest.args index 77babdc147..f78b4e7abf 100644 --- a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nb= d.x86_64-latest.args +++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nb= d.x86_64-latest.args @@ -12,7 +12,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.= config \ -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/edk2/ovmf/OVMF_CODE_4M.= qcow2","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard= ":"unmap"}' \ -blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver"= :"qcow2","file":"libvirt-pflash0-storage"}' \ --blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","p= ort":"6000"},"export":"bar","node-name":"libvirt-pflash1-storage","auto-rea= d-only":true,"discard":"unmap"}' \ +-blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","p= ort":"6000"},"node-name":"libvirt-pflash1-storage","auto-read-only":true,"d= iscard":"unmap"}' \ -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver= ":"qcow2","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 \ diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-net= work-nbd.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format= -nvram-qcow2-network-nbd.x86_64-latest.xml index 35865b23c5..cc87905306 100644 --- a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nb= d.x86_64-latest.xml +++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nb= d.x86_64-latest.xml @@ -11,7 +11,7 @@ /usr/share/e= dk2/ovmf/OVMF_CODE_4M.qcow2 - + diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-net= work-nbd.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-n= etwork-nbd.xml index 0028bde4d7..d604840edd 100644 --- a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nb= d.xml +++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nb= d.xml @@ -6,7 +6,7 @@ hvm - + --=20 2.47.0