From nobody Tue Mar 3 04:53:02 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=1771418238; cv=none; d=zohomail.com; s=zohoarc; b=mFhwkEtiKN+Sv6SVkLbueIUOCif0Ndl7J9yMIMRNJ21vGBC0/bFwBYwF4rSSPZNxdY2eUms5HcKxpNzfNq6w4QzGfL79QnY1sY6o1+tMiGp+yKcs42HmqXhxnJTyfLjOAigjcNow5eRAi/1FHiDgjgGoFDuZrW6d/hHx2p+R3Qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771418238; 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=tKpl4Pzr4Z427XapJsWfFHtLetKeHOEEbnEXkk8PlX8=; b=QeNP90CMFlCUIq3zIAjOmD2iNecvcC8zedGdVCDX5MnOu9UKQYt6JW/5fIb+0JxPL7m8Q/czXvFry+0Ri6hvIIYA9YIwWs96LVePu4iCHHwCmOVoLSBoopSwPsUwCcm9ApfAnDFoXadKwUSKeyGO+d7FbZQqrPT48ESBX98NkuY= 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 1771418238672403.5671064410741; Wed, 18 Feb 2026 04:37:18 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 09187419B6; Wed, 18 Feb 2026 07:37:18 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id D842844200; Wed, 18 Feb 2026 07:11:00 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 6E98D44186; Wed, 18 Feb 2026 07:10:55 -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 1A06841BD7 for ; Wed, 18 Feb 2026 07:07:01 -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-213-5EqvkzD9PnaoFBFZGG9FSQ-1; Wed, 18 Feb 2026 07:06:59 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B4A06195606C for ; Wed, 18 Feb 2026 12:06:58 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.45.226.171]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BF42230001A5 for ; Wed, 18 Feb 2026 12:06:57 +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=-4.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,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=1771416420; 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=tKpl4Pzr4Z427XapJsWfFHtLetKeHOEEbnEXkk8PlX8=; b=JwaNM1344TwuN3uFbwzJmOMfEGAyxAZzJ8TVGA902ICFytCTukWIalMI2nUoMteH+SfRx4 y7nth5YFhxZlxQFC5mI+dvKJuT6wRw20GDTYJLOX47ozv7nptpfzZxLtpQrjyG79kstJqW UhH//VRZTAZmBxZpDcR15IqPSh7IL7g= X-MC-Unique: 5EqvkzD9PnaoFBFZGG9FSQ-1 X-Mimecast-MFC-AGG-ID: 5EqvkzD9PnaoFBFZGG9FSQ_1771416418 To: devel@lists.libvirt.org Subject: [PATCH v3 32/38] qemu: Create and delete varstore file Date: Wed, 18 Feb 2026 13:05:55 +0100 Message-ID: <20260218120601.230343-33-abologna@redhat.com> In-Reply-To: <20260218120601.230343-1-abologna@redhat.com> References: <20260218120601.230343-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: NEPFdWwRjsagVY5tzgQhRdFUoFg2v3DGrBTwuy25m1A_1771416418 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: TZBC5HUM6DPTEDCEO4756K4YWJKVCJXV X-Message-ID-Hash: TZBC5HUM6DPTEDCEO4756K4YWJKVCJXV 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: 1771418240237154100 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 9620f737ba..c9e9e970e7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6646,22 +6646,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 db43b035c1..a82ee4b15e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5029,6 +5029,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, @@ -7799,6 +7820,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 @@ -7808,8 +7830,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