From nobody Sun Feb 8 23:45:34 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=1725719740; cv=none; d=zohomail.com; s=zohoarc; b=ILAqUZU5DUv80YPWoEM87zmX4qF7U8BDtj3z5knNhOdq+hauBMYkWdamK/T94KEnGxpywyNNwUpNzJ2b18AOoZxP+WABWQgDkEDuSPgjnwVaaQDPTE0F1zGIPHP5WAn+GXKfgEgjBpG24aimB5eaZMikwqx0rjuyvzTVR8x0RBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725719740; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=0CCtP+nyaFlW3wqdDpIgL7iTMRXjQ55Mqr+/4fsFiBI=; b=GNEUU+Uo7Np9QBuxvwhKqZ5VpIuQyWtaXt+eNb4rWR57kqQCloBRTZCFCm6kceYMxVkO2CXrdPIOLrpkRqt+i9aJFs7EevBQT8Rvo3ZPHMwUk/3ATdpx1fgbRLXjsFWdfLdF4hNKqQHtxQtieuCFubpQXRdHULuW38Txi6p5NZw= 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 1725719740070845.4661611520243; Sat, 7 Sep 2024 07:35:40 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 05A4F18C5; Sat, 7 Sep 2024 10:35:38 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 92809172D; Sat, 7 Sep 2024 10:33:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 911F018D1; Sat, 7 Sep 2024 10:33:21 -0400 (EDT) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (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 0723D191D for ; Sat, 7 Sep 2024 10:33:06 -0400 (EDT) Received: from [130.117.225.1] (helo=vz9-barybin-2.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1smwS3-001ZxE-2P; Sat, 07 Sep 2024 16:32:42 +0200 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=HtRT8iuMQj3d10z0dauPOoPwI38XgN9khcbULnO1rJ4=; b=FhWaRW9uSxLn Bjyp4NvYAeW1syENV3Lx5G/w6AVUpO85SfbIp6+KArwfP1dJ0eU1Ojrq8JZBh2N/X7uOulU7KdSzk 5lUdwc90xNmoo7ZSdA4l5jHp/JU4irlZKWyeHU1z+B0By+m8NEASbgfxrDG1csNkP+XCLAmhm+qK/ PQ1J19SiV5/+g5hU7LuplkA4w+iMuwuXe4gYD8s4Zyt8A1uRgKE5EoNLhU7NOU4Kq7JkkgOToDkQ3 q0i/rrsxpNWySX7As5OPCuMkSbYD1wBM4SDu8W7IaCLJv5Usf65jCVVCCJRHWn5JE20loOz53wqQO bplKBrdx/s4vl2G8Ax8RQA==; To: devel@lists.libvirt.org Subject: [PATCH v2 12/13] conf: implement XML parsing/formatingo for dataFileStore Date: Sat, 7 Sep 2024 17:15:40 +0300 Message-ID: <20240907143006.50677-26-nikolai.barybin@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240907143006.50677-1-nikolai.barybin@virtuozzo.com> References: <20240907143006.50677-1-nikolai.barybin@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5HSYY476SLC3M2XIJ6OOUYN3X4EZWJYN X-Message-ID-Hash: 5HSYY476SLC3M2XIJ6OOUYN3X4EZWJYN X-MailFrom: nikolai.barybin@virtuozzo.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 CC: den@openvz.org, Nikolai Barybin 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: From: Nikolai Barybin via Devel Reply-To: Nikolai Barybin X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1725719741454116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin --- src/conf/domain_conf.c | 98 ++++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 13 ++++++ 2 files changed, 111 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a263612ef7..cfd25032b3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7654,6 +7654,52 @@ virDomainStorageSourceParse(xmlNodePtr node, } =20 =20 +int +virDomainDiskDataFileStoreParse(xmlXPathContextPtr ctxt, + virStorageSource *src, + unsigned int flags, + virDomainXMLOption *xmlopt) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt) + xmlNodePtr source; + g_autofree char *type =3D NULL; + g_autofree char *format =3D NULL; + g_autoptr(virStorageSource) dataFileStore =3D NULL; + + if (!(ctxt->node =3D virXPathNode("./dataFileStore", ctxt))) + return 0; + + if (!(type =3D virXMLPropString(ctxt->node, "type"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing data file store type")); + return -1; + } + + if (!(format =3D virXPathString("string(./format/@type)", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing data file store format")); + return -1; + } + + if (!(source =3D virXPathNode("./source", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing disk data file store source")); + return -1; + } + + if (!(dataFileStore =3D virDomainStorageSourceParseBase(type, format, = NULL))) + return -1; + + if (virDomainStorageSourceParse(source, ctxt, dataFileStore, flags, xm= lopt) < 0) + return -1; + + dataFileStore->readonly =3D src->readonly; + src->dataFileStore =3D g_steal_pointer(&dataFileStore); + + return 0; +} + + int virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt, virStorageSource *src, @@ -7704,6 +7750,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctx= t, backingStore->readonly =3D true; =20 if (virDomainStorageSourceParse(source, ctxt, backingStore, flags, xml= opt) < 0 || + virDomainDiskDataFileStoreParse(ctxt, backingStore, flags, xmlopt)= < 0 || virDomainDiskBackingStoreParse(ctxt, backingStore, flags, xmlopt) = < 0) return -1; =20 @@ -8096,6 +8143,9 @@ virDomainDiskDefParseSourceXML(virDomainXMLOption *xm= lopt, return NULL; } =20 + if (virDomainDiskDataFileStoreParse(ctxt, src, flags, xmlopt) < 0) + return NULL; + if (virDomainDiskBackingStoreParse(ctxt, src, flags, xmlopt) < 0) return NULL; =20 @@ -22819,6 +22869,46 @@ virDomainDiskSourceFormat(virBuffer *buf, return 0; } =20 +int +virDomainDiskDataFileStoreFormat(virBuffer *buf, + virStorageSource *src, + virDomainXMLOption *xmlopt, + unsigned int flags) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) formatAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + virStorageSource *dataFileStore =3D src->dataFileStore; + bool inactive =3D flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE; + + if (!dataFileStore) + return 0; + + /* don't write detected data file member to inactive xml */ + if (inactive && dataFileStore->detected) + return 0; + + if (dataFileStore->format !=3D VIR_STORAGE_FILE_RAW) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk data file format '%1$d', only ra= w format is supported"), + dataFileStore->format); + return -1; + } + + virBufferAsprintf(&attrBuf, " type=3D'%s'", + virStorageTypeToString(dataFileStore->type)); + + virBufferAsprintf(&formatAttrBuf, " type=3D'%s'", + virStorageFileFormatTypeToString(dataFileStore->form= at)); + virXMLFormatElement(&childBuf, "format", &formatAttrBuf, NULL); + + if (virDomainDiskSourceFormat(&childBuf, dataFileStore, "source", 0, f= alse, + flags, false, false, xmlopt) < 0) + return -1; + + virXMLFormatElement(buf, "dataFileStore", &attrBuf, &childBuf); + return 0; +} =20 int virDomainDiskBackingStoreFormat(virBuffer *buf, @@ -22877,6 +22967,10 @@ virDomainDiskBackingStoreFormat(virBuffer *buf, flags, false, false, xmlopt) < 0) return -1; =20 + if (backingStore->dataFileStore && + virDomainDiskDataFileStoreFormat(&childBuf, backingStore, xmlopt, = flags) < 0) + return -1; + if (virDomainDiskBackingStoreFormat(&childBuf, backingStore, xmlopt, f= lags) < 0) return -1; =20 @@ -23195,6 +23289,10 @@ virDomainDiskDefFormat(virBuffer *buf, if (virDomainDiskBackingStoreFormat(&childBuf, def->src, xmlopt, flags= ) < 0) return -1; =20 + if (def->src->dataFileStore && + virDomainDiskDataFileStoreFormat(&childBuf, def->src, xmlopt, flag= s) < 0) + return -1; + virBufferEscapeString(&childBuf, "\n", def= ->domain_name); =20 virDomainDiskGeometryDefFormat(&childBuf, def); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 659299bdd1..993c49a731 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3884,6 +3884,12 @@ int virDomainDiskSourceFormat(virBuffer *buf, bool skipEnc, virDomainXMLOption *xmlopt); =20 +int +virDomainDiskDataFileStoreFormat(virBuffer *buf, + virStorageSource *src, + virDomainXMLOption *xmlopt, + unsigned int flags); + int virDomainDiskBackingStoreFormat(virBuffer *buf, virStorageSource *src, @@ -4399,6 +4405,13 @@ int virDomainStorageSourceParse(xmlNodePtr node, virDomainXMLOption *xmlopt) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 +int +virDomainDiskDataFileStoreParse(xmlXPathContextPtr ctxt, + virStorageSource *src, + unsigned int flags, + virDomainXMLOption *xmlopt) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; + int virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt, virStorageSource *src, --=20 2.43.5