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=1770645746; cv=none; d=zohomail.com; s=zohoarc; b=YLh1J9wc0y+ojfF/H3/CbnDQTPeQQLRAig+vvw2IRatxy2Vzu1JFEvOw32vTbZVOE9qULbiCohjhrHqZDdit4bSOUjlC8b+6GQp7R8/sqoW4JzFVt/QLi8EMZZh7ud5JbjiAyrOQazuPbHIRq+MN3Gs29YkTyjk6gXCC0E+d3ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770645746; 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=B+zZpjsaN3AoB23M+GGP4R5cP/4Z409a8AQuerszIfc=; b=LYBFvMFVSJYbAH/EZ9VmFLoyVPJv30nfG2+EzoB4/Fy3nHOp3QHzEmGVhnr6bTD3C3WdXq7/t4jaisZ/JRVjFn8lb1v46rmsGGiEAm4/W2NbZamPD2jHrmnHXuqwyCJW4zHSVSBKz0UzKts2fYj3B0FCGzWl9HXUnspSVxbGf4s= 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 1770645746608301.6888401336357; Mon, 9 Feb 2026 06:02:26 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id A7D4E43E45; Mon, 9 Feb 2026 09:02:25 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 16C8643F9E; Mon, 9 Feb 2026 08:47:52 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id D7F6843F47; Mon, 9 Feb 2026 08:47:46 -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 C14C341AD2 for ; Mon, 9 Feb 2026 08:47:27 -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-133-itwDJ5KHPtK1zFgzJB_LVA-1; Mon, 09 Feb 2026 08:47:25 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E3EAC195608E for ; Mon, 9 Feb 2026 13:47:24 +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 2D25C1956053 for ; Mon, 9 Feb 2026 13:47:23 +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=1770644847; 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=B+zZpjsaN3AoB23M+GGP4R5cP/4Z409a8AQuerszIfc=; b=Wx7cAOp6arhhSiADaDFkrJkX1WfGwgU3qjue96nNM6uMFENhS9SB5iZigTwVxEr4wcOjtW 3f9TeDM+CluVGy7SshWx35QlcDiLIF0JK/EkItsgwRV2Fjt+Nh1n++rSQmZq6m6JHFWYmq toEALsBfX7OO186W/RPCUCGM4QhGSEY= X-MC-Unique: itwDJ5KHPtK1zFgzJB_LVA-1 X-Mimecast-MFC-AGG-ID: itwDJ5KHPtK1zFgzJB_LVA_1770644845 To: devel@lists.libvirt.org Subject: [PATCH v2 07/38] conf: Parse and format varstore element Date: Mon, 9 Feb 2026 14:46:41 +0100 Message-ID: <20260209134712.296670-8-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: MGt1vpPUgZhrAqaDIQWYeJ8rLoaflnddXosBf_Hxma0_1770644845 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: AI5AUGPCPHRO27UI7TZ3PPN4VNTEVORU X-Message-ID-Hash: AI5AUGPCPHRO27UI7TZ3PPN4VNTEVORU 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: 1770645747036158500 Content-Type: text/plain; charset="utf-8"; x-default="true" Dealing with the element itself is trivial, however we have to refactor the existing code which deals with the loader and nvram elements slightly: in particular, we can no longer perform an early exit if those elements are absent. Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 79 ++++++++++++++++++++++++++++++++++++---- src/conf/domain_conf.h | 9 +++++ src/conf/virconftypes.h | 2 + src/libvirt_private.syms | 2 + 4 files changed, 85 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e88dc62520..65a1919519 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3943,6 +3943,27 @@ virDomainLoaderDefFree(virDomainLoaderDef *loader) g_free(loader); } =20 +virDomainVarstoreDef * +virDomainVarstoreDefNew(void) +{ + virDomainVarstoreDef *def =3D NULL; + + def =3D g_new0(virDomainVarstoreDef, 1); + + return def; +} + +void +virDomainVarstoreDefFree(virDomainVarstoreDef *varstore) +{ + if (!varstore) + return; + + g_free(varstore->path); + g_free(varstore->template); + g_free(varstore); +} + =20 static void virDomainResctrlMonDefFree(virDomainResctrlMonDef *domresmon) @@ -4045,6 +4066,7 @@ virDomainOSDefClear(virDomainOSDef *os) virDomainOSACPITableDefFree(os->acpiTables[i]); g_free(os->acpiTables); virDomainLoaderDefFree(os->loader); + virDomainVarstoreDefFree(os->varstore); g_free(os->bootloader); g_free(os->bootloaderArgs); } @@ -17954,6 +17976,17 @@ virDomainLoaderDefParseXMLLoader(virDomainLoaderDe= f *loader, } =20 =20 +static int +virDomainVarstoreDefParseXML(virDomainVarstoreDef *varstore, + xmlNodePtr varstoreNode) +{ + varstore->path =3D virXMLPropString(varstoreNode, "path"); + varstore->template =3D virXMLPropString(varstoreNode, "template"); + + return 0; +} + + static int virDomainLoaderDefParseXML(virDomainLoaderDef *loader, xmlNodePtr loaderNode, @@ -18401,16 +18434,29 @@ virDomainDefParseBootLoaderOptions(virDomainDef *= def, xmlNodePtr loaderNode =3D virXPathNode("./os/loader[1]", ctxt); xmlNodePtr nvramNode =3D virXPathNode("./os/nvram[1]", ctxt); xmlNodePtr nvramSourceNode =3D virXPathNode("./os/nvram/source[1]", ct= xt); + xmlNodePtr varstoreNode =3D virXPathNode("./os/varstore[1]", ctxt); =20 - if (!loaderNode && !nvramNode) - return 0; + if (nvramNode && varstoreNode) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Cannot have both and ")); + return -1; + } =20 - def->os.loader =3D virDomainLoaderDefNew(); + if (loaderNode || nvramNode) { + def->os.loader =3D virDomainLoaderDefNew(); =20 - if (virDomainLoaderDefParseXML(def->os.loader, - loaderNode, nvramNode, nvramSourceNode, - ctxt, xmlopt, flags) < 0) - return -1; + if (virDomainLoaderDefParseXML(def->os.loader, + loaderNode, nvramNode, nvramSourceN= ode, + ctxt, xmlopt, flags) < 0) + return -1; + } + + if (varstoreNode) { + def->os.varstore =3D virDomainVarstoreDefNew(); + + if (virDomainVarstoreDefParseXML(def->os.varstore, varstoreNode) <= 0) + return -1; + } =20 return 0; } @@ -28046,6 +28092,20 @@ virDomainLoaderDefFormat(virBuffer *buf, return 0; } =20 +static int +virDomainVarstoreDefFormat(virBuffer *buf, + virDomainVarstoreDef *varstore) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + + virBufferEscapeString(&attrBuf, " template=3D'%s'", varstore->template= ); + virBufferEscapeString(&attrBuf, " path=3D'%s'", varstore->path); + + virXMLFormatElementEmpty(buf, "varstore", &attrBuf, NULL); + + return 0; +} + static void virDomainKeyWrapDefFormat(virBuffer *buf, virDomainKeyWrapDef *keywrap) { @@ -29518,6 +29578,11 @@ virDomainDefFormatInternalSetRootName(virDomainDef= *def, if (def->os.loader && virDomainLoaderDefFormat(buf, def->os.loader, xmlopt, flags) < 0) return -1; + + if (def->os.varstore && + virDomainVarstoreDefFormat(buf, def->os.varstore) < 0) + return -1; + virBufferEscapeString(buf, "%s\n", def->os.kernel); virBufferEscapeString(buf, "%s\n", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1e16310ef9..ceb0053317 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2414,6 +2414,14 @@ struct _virDomainLoaderDef { virDomainLoaderDef *virDomainLoaderDefNew(void); void virDomainLoaderDefFree(virDomainLoaderDef *loader); =20 +struct _virDomainVarstoreDef { + char *path; + char *template; +}; + +virDomainVarstoreDef *virDomainVarstoreDefNew(void); +void virDomainVarstoreDefFree(virDomainVarstoreDef *varstore); + typedef enum { VIR_DOMAIN_IOAPIC_NONE =3D 0, VIR_DOMAIN_IOAPIC_QEMU, @@ -2567,6 +2575,7 @@ struct _virDomainOSDef { size_t nacpiTables; virDomainOSACPITableDef **acpiTables; virDomainLoaderDef *loader; + virDomainVarstoreDef *varstore; char *bootloader; char *bootloaderArgs; int smbios_mode; diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index 6e2573035a..0596791a4d 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -164,6 +164,8 @@ typedef struct _virDomainLeaseDef virDomainLeaseDef; =20 typedef struct _virDomainLoaderDef virDomainLoaderDef; =20 +typedef struct _virDomainVarstoreDef virDomainVarstoreDef; + typedef struct _virDomainMemballoonDef virDomainMemballoonDef; =20 typedef struct _virDomainMemoryDef virDomainMemoryDef; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d81b30f0b6..e5b16f93fa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -718,6 +718,8 @@ virDomainTPMProfileRemoveDisabledTypeToString; virDomainTPMVersionTypeFromString; virDomainTPMVersionTypeToString; virDomainUSBDeviceDefForeach; +virDomainVarstoreDefFree; +virDomainVarstoreDefNew; virDomainVideoDefaultRAM; virDomainVideoDefClear; virDomainVideoDefFree; --=20 2.53.0