From nobody Tue Feb 10 05:43:58 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770648283; cv=none; d=zohomail.com; s=zohoarc; b=hv378SzYvRn+8941xyA1lrMNsR7eqT4koCgAy8FO2ksP3iZeIryMYlLQvvKuv2vq2EAqrhayDOKoVfKQs+jGKViS7MxMqVYR7toTGkDdF8x7yR1XPse21xGL8w0GRNCaaddrQraZztW7nk+wu2URz/mfqfmFUwwDHzpQspj8mCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770648283; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=Bvlp4GKbchXsESiSQj74jLWZsrwxaKIK59ugDazBmQc=; b=dzHnwnnowSH09PHvzu3BZzz9pdE7zb+y2/IMNdbDaP+J1qKhJhSqY702e58nsckZ0EL8/9R1lLx0sVasnBD4YuTygezw2Le5o9cliGPCMARgUOmjZvMqXe6r1nGO5Pyj95m/+oWKRFfMRQhE21DCekYPZs8UuKpDPHkMYuNwSRo= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770648283124120.11758153242204; Mon, 9 Feb 2026 06:44:43 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 2684241A39; Mon, 9 Feb 2026 09:44:42 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 5ACDD44721; Mon, 9 Feb 2026 09:07:10 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id AEE5F43F0E; Mon, 9 Feb 2026 09:02:37 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B93F141B20 for ; Mon, 9 Feb 2026 08:47:57 -0500 (EST) Received: from mx-prod-mc-03.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-677-Y10JMJeVNKWeXRwxHXl1Tg-1; Mon, 09 Feb 2026 08:47:56 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4685B1955DC0 for ; Mon, 9 Feb 2026 13:47:55 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.226.251]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 840111956053 for ; Mon, 9 Feb 2026 13:47:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770644877; 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=Bvlp4GKbchXsESiSQj74jLWZsrwxaKIK59ugDazBmQc=; b=bo5gdBLW+3atKZ2gwWbWRh5I5TQ3JE33iL3O6RDJjJtTFu1PjdcbbMIld4RXUAN/JriM6+ ixe8/WgZqJ0zSOSAp/3iA0LtGbNXJik2mruXYNRBycXJOpPD1D57yY8ENzRYPd7Moy+MXp r9oh83wlHhnWPHRehosJQrcUcvZnI50= X-MC-Unique: Y10JMJeVNKWeXRwxHXl1Tg-1 X-Mimecast-MFC-AGG-ID: Y10JMJeVNKWeXRwxHXl1Tg_1770644875 To: devel@lists.libvirt.org Subject: [PATCH v2 32/38] qemu: Create and delete varstore file Date: Mon, 9 Feb 2026 14:47:06 +0100 Message-ID: <20260209134712.296670-33-abologna@redhat.com> In-Reply-To: <20260209134712.296670-1-abologna@redhat.com> References: <20260209134712.296670-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: QP4GY48hxUMUNyu5f8ZzLMQ284S-x5cK24oI9PLDLmI_1770644875 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZDRXOCCVYUJMUN2MQIJ64MI3BDN67Q7R X-Message-ID-Hash: ZDRXOCCVYUJMUN2MQIJ64MI3BDN67Q7R X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Andrea Bolognani via Devel Reply-To: Andrea Bolognani X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770648284736158500 Content-Type: text/plain; charset="utf-8"; x-default="true" Simply mimicking what is currently done for NVRAM files works. A few user-visible messages are updated to reflect the fact that they apply both to NVRAM and varstore. https://issues.redhat.com/browse/RHEL-82645 Signed-off-by: Andrea Bolognani --- src/qemu/qemu_driver.c | 15 ++++++++++----- src/qemu/qemu_process.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f3c2988751..3bbc04945c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6648,22 +6648,27 @@ qemuDomainUndefineFlags(virDomainPtr dom, } } =20 - if (vm->def->os.loader && vm->def->os.loader->nvram && - virStorageSourceIsLocalStorage(vm->def->os.loader->nvram)) { - nvram_path =3D g_strdup(vm->def->os.loader->nvram->path); + if (vm->def->os.loader) { + if (vm->def->os.loader->nvram && + virStorageSourceIsLocalStorage(vm->def->os.loader->nvram)) { + nvram_path =3D g_strdup(vm->def->os.loader->nvram->path); + } + if (vm->def->os.varstore && vm->def->os.varstore->path) { + nvram_path =3D g_strdup(vm->def->os.varstore->path); + } } =20 if (nvram_path && virFileExists(nvram_path)) { if ((flags & VIR_DOMAIN_UNDEFINE_NVRAM)) { if (unlink(nvram_path) < 0) { virReportSystemError(errno, - _("failed to remove nvram: %1$s"), + _("Failed to remove NVRAM/varstore: %= 1$s"), nvram_path); goto endjob; } } else if (!(flags & VIR_DOMAIN_UNDEFINE_KEEP_NVRAM)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot undefine domain with nvram")); + _("Cannot undefine domain with NVRAM/varstore")= ); goto endjob; } } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 997b1d383b..37866c33ea 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5030,6 +5030,27 @@ qemuPrepareNVRAM(virQEMUDriver *driver, } =20 =20 +static int +qemuPrepareVarstore(virQEMUDriver *driver, + virDomainDef *def, + bool reset_nvram) +{ + virDomainLoaderDef *loader =3D def->os.loader; + virDomainVarstoreDef *varstore =3D def->os.varstore; + + if (!loader || !varstore) + return 0; + + VIR_DEBUG("varstore=3D'%s'", NULLSTR(varstore->path)); + + if (qemuPrepareNVRAMFileCommon(driver, varstore->path, + varstore->template, reset_nvram) < 0) + return -1; + + return 0; +} + + static void qemuLogOperation(virDomainObj *vm, const char *msg, @@ -7829,6 +7850,7 @@ qemuProcessPrepareHost(virQEMUDriver *driver, unsigned int hostdev_flags =3D 0; qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + bool reset_nvram =3D !!(flags & VIR_QEMU_PROCESS_START_RESET_NVRAM); =20 /* * Create all per-domain directories in order to make sure domain @@ -7838,8 +7860,10 @@ qemuProcessPrepareHost(virQEMUDriver *driver, qemuProcessMakeDir(driver, vm, priv->channelTargetDir) < 0) return -1; =20 - if (qemuPrepareNVRAM(driver, vm->def, - !!(flags & VIR_QEMU_PROCESS_START_RESET_NVRAM)) <= 0) + if (qemuPrepareNVRAM(driver, vm->def, reset_nvram) < 0) + return -1; + + if (qemuPrepareVarstore(driver, vm->def, reset_nvram) < 0) return -1; =20 if (vm->def->vsock) { --=20 2.53.0