From nobody Fri May 10 20:03:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1700562610885242.81277250501057; Tue, 21 Nov 2023 02:30:10 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7B22D1879; Tue, 21 Nov 2023 05:30:09 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0BCEE17A4; Tue, 21 Nov 2023 05:28:29 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id CD50C179D; Tue, 21 Nov 2023 05:28:21 -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 38CB6179B for ; Tue, 21 Nov 2023 05:28:21 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-yn1m5yWJMvOUa3EjJ0iyFg-1; Tue, 21 Nov 2023 05:28:19 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 01951185A783 for ; Tue, 21 Nov 2023 10:28:19 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1B31492BE0 for ; Tue, 21 Nov 2023 10:28:18 +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.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: yn1m5yWJMvOUa3EjJ0iyFg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/6] vbox_snapshot_conf: Parse XMLs without net access Date: Tue, 21 Nov 2023 11:28:11 +0100 Message-ID: <7bd2ef6676c61d9b27613a9603dfc8460ec4eb76.1700562423.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 7EFLKLFJJ2CIBP2IGIXH2VE45UCHSBCF X-Message-ID-Hash: 7EFLKLFJJ2CIBP2IGIXH2VE45UCHSBCF X-MailFrom: mprivozn@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: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1700562611919100001 When working with VirtualBox's snapshots, the snapshot XML is firstly parsed, stored in memory (with some parts being stored as verbatim XML snippets, strings), requested changes are made and then this modified XML is formatted via virVBoxSnapshotConfSaveVboxFile() which calls xmlParseInNodeContext() to format those previously stored XML snippets. The first parse of whole VirtualBox snapshot file is done using virXMLParse() (in virVBoxSnapshotConfLoadVboxFile()) and thus with XML_PARSE_NONET specified. But those ad-hoc parsings when formatting the XML back pass zero flags mask: xmlParseInNodeContext(..., options =3D 0, ...); This is potentially dangerous. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/vbox/vbox_snapshot_conf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index 84f7aceac2..467255f77f 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -369,6 +369,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, int firstRegexResult =3D 0; g_auto(GStrv) secondRegex =3D NULL; int secondRegexResult =3D 0; + const int parseFlags =3D XML_PARSE_NONET; =20 uuid =3D g_strdup_printf("{%s}", snapshot->uuid); =20 @@ -406,7 +407,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, parseError =3D xmlParseInNodeContext(node, snapshot->hardware, (int)strlen(snapshot->hardware), - 0, + parseFlags, &hardwareNode); if (parseError !=3D XML_ERR_OK) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -418,7 +419,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, /* storageController */ if (xmlParseInNodeContext(node, snapshot->storageController, (int)strlen(snapshot->storageController), - 0, + parseFlags, &storageControllerNode) !=3D XML_ERR_OK) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Unable to add the snapshot storageController")); @@ -944,6 +945,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMach= ine *machine, int firstRegexResult =3D 0; g_auto(GStrv) secondRegex =3D NULL; int secondRegexResult =3D 0; + const int parseFlags =3D XML_PARSE_NONET; =20 if (machine =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1051,7 +1053,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMa= chine *machine, parseError =3D xmlParseInNodeContext(mediaRegistryNode, machine->mediaRegistry->otherMedia[i], (int)strlen(machine->mediaRegistry->otherMed= ia[i]), - 0, + parseFlags, &cur); if (parseError !=3D XML_ERR_OK) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -1071,7 +1073,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMa= chine *machine, parseError =3D xmlParseInNodeContext(machineNode, machine->hardware, (int)strlen(machine->hardware), - 0, + parseFlags, &cur); if (parseError !=3D XML_ERR_OK) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -1084,7 +1086,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMa= chine *machine, parseError =3D xmlParseInNodeContext(xmlDocGetRootElement(xml), machine->extraData, (int)strlen(machine->extraData), - 0, + parseFlags, &cur); if (parseError !=3D XML_ERR_OK) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -1097,7 +1099,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMa= chine *machine, parseError =3D xmlParseInNodeContext(machineNode, machine->storageController, (int)strlen(machine->storageControl= ler), - 0, + parseFlags, &cur); if (parseError !=3D XML_ERR_OK) { virReportError(VIR_ERR_XML_ERROR, "%s", --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Fri May 10 20:03:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1700562838461614.2758599087908; Tue, 21 Nov 2023 02:33:58 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6C472189E; Tue, 21 Nov 2023 05:33:57 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A8E2D17C1; Tue, 21 Nov 2023 05:28:52 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 75F2A179E; Tue, 21 Nov 2023 05:28:23 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 B1E50179B for ; Tue, 21 Nov 2023 05:28:22 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-YsJXEY5oNeWxUkWOZ5YhXw-1; Tue, 21 Nov 2023 05:28:19 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 894FB83B824 for ; Tue, 21 Nov 2023 10:28:19 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3551B492BE0 for ; Tue, 21 Nov 2023 10:28:19 +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.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: YsJXEY5oNeWxUkWOZ5YhXw-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 2/6] vbox_snapshot_conf: Keep indent in snapshot XML Date: Tue, 21 Nov 2023 11:28:12 +0100 Message-ID: <0191c47b050eb7750e38dbde44829db05f833359.1700562423.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: BDP36AIVG4433COK6THFUK423AGZFDVL X-Message-ID-Hash: BDP36AIVG4433COK6THFUK423AGZFDVL X-MailFrom: mprivozn@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: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1700562839779100001 As mentioned in previous commit, VirtualBox has its own snapshot XML which we parse, change and then format back. During this, we ought to keep the indentation to produce better looking result (especially when we want to compare the output in tests later on, like we do in vboxsnapshotxmltest). Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/vbox/vbox_snapshot_conf.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index 467255f77f..9a10b08c3c 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -25,6 +25,7 @@ #include "virstring.h" #include "virxml.h" =20 +#include #include =20 #define VIR_FROM_THIS VIR_FROM_VBOX @@ -364,12 +365,14 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, xmlParserErrors parseError =3D XML_ERR_OK; char *uuid =3D NULL; char *timeStamp =3D NULL; - g_auto(GStrv) firstRegex =3D NULL; int firstRegexResult =3D 0; g_auto(GStrv) secondRegex =3D NULL; int secondRegexResult =3D 0; - const int parseFlags =3D XML_PARSE_NONET; + const int parseFlags =3D XML_PARSE_NONET | XML_PARSE_NOBLANKS; + int oldIndentTreeOutput =3D xmlIndentTreeOutput; + + xmlIndentTreeOutput =3D 1; =20 uuid =3D g_strdup_printf("{%s}", snapshot->uuid); =20 @@ -440,6 +443,8 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, result =3D 0; =20 cleanup: + xmlIndentTreeOutput =3D oldIndentTreeOutput; + if (result < 0) { xmlFreeNode(descriptionNode); xmlUnlinkNode(snapshotsNode); @@ -940,12 +945,14 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMa= chine *machine, xmlParserErrors parseError =3D XML_ERR_OK; char *currentSnapshot =3D NULL; char *timeStamp =3D NULL; - g_auto(GStrv) firstRegex =3D NULL; int firstRegexResult =3D 0; g_auto(GStrv) secondRegex =3D NULL; int secondRegexResult =3D 0; - const int parseFlags =3D XML_PARSE_NONET; + const int parseFlags =3D XML_PARSE_NONET | XML_PARSE_NOBLANKS; + int oldIndentTreeOutput =3D xmlIndentTreeOutput; + + xmlIndentTreeOutput =3D 1; =20 if (machine =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1127,6 +1134,8 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMa= chine *machine, ret =3D 0; =20 cleanup: + xmlIndentTreeOutput =3D oldIndentTreeOutput; + VIR_FREE(currentSnapshot); VIR_FREE(timeStamp); =20 --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Fri May 10 20:03:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1700562688043913.7449042911579; Tue, 21 Nov 2023 02:31:28 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id CFC4D187E; Tue, 21 Nov 2023 05:31:26 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BEFBC1851; Tue, 21 Nov 2023 05:28:35 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A276E179F; Tue, 21 Nov 2023 05:28:22 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 115E6179D for ; Tue, 21 Nov 2023 05:28:22 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-660-V1V8WRf-MH6NCRcY_j8jvw-1; Tue, 21 Nov 2023 05:28:20 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1D06A8556E5 for ; Tue, 21 Nov 2023 10:28:20 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCCDF492BE0 for ; Tue, 21 Nov 2023 10:28:19 +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.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: V1V8WRf-MH6NCRcY_j8jvw-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 3/6] virxml: include for xmlIndentTreeOutput declaration Date: Tue, 21 Nov 2023 11:28:13 +0100 Message-ID: <5561f0f8bdf4b14fdf3b2eb131ee91b38436a46c.1700562423.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: QQ5HIWCY6M7WF24VRLUZIAM6IU7QNP5B X-Message-ID-Hash: QQ5HIWCY6M7WF24VRLUZIAM6IU7QNP5B X-MailFrom: mprivozn@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: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1700562689299100001 After libxml2's commit of v2.12.0~101 we no longer get xmlIndentTreeOutput declaration by us including just libxml/xpathInternals.h and libxml2's header files leakage. Resolves: https://bugs.gentoo.org/917516 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/virxml.c b/src/util/virxml.c index 0c1eae8c3c..4f215a0e59 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -24,6 +24,7 @@ #include /* for isnan() */ #include =20 +#include #include =20 #include "virerror.h" --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Fri May 10 20:03:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1700562909661492.52127620499766; Tue, 21 Nov 2023 02:35:09 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8A77718E5; Tue, 21 Nov 2023 05:35:08 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4606517E4; Tue, 21 Nov 2023 05:29:02 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id EE08117A9; Tue, 21 Nov 2023 05:28:23 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 E7E7717A8 for ; Tue, 21 Nov 2023 05:28:22 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-imysIvIqM3-4zoWM8kj0Lw-1; Tue, 21 Nov 2023 05:28:20 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4A2C101A53B for ; Tue, 21 Nov 2023 10:28:20 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50582492BE0 for ; Tue, 21 Nov 2023 10:28:20 +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.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: imysIvIqM3-4zoWM8kj0Lw-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 4/6] virXMLParseHelper: Store XML parsing flags in a variable Date: Tue, 21 Nov 2023 11:28:14 +0100 Message-ID: <01f035dee0c486e7c95f923d16d7f3c3e0549be7.1700562423.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: OIP6Q4WRXKWSXD3GNHZBAESA7OC7Y33I X-Message-ID-Hash: OIP6Q4WRXKWSXD3GNHZBAESA7OC7Y33I X-MailFrom: mprivozn@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: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1700562910872100001 The virXMLParseHelper() can work in two modes: either it parses a file or a string. Either way, the same set of flags is specified in call of corresponding function. Save flags in a local variable instead. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 4f215a0e59..31685cddde 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1136,6 +1136,8 @@ virXMLParseHelper(int domcode, g_autoptr(xmlDoc) xml =3D NULL; xmlNodePtr rootnode; const char *docname; + const int parseFlags =3D XML_PARSE_NONET | + XML_PARSE_NOWARNING; =20 if (filename) docname =3D filename; @@ -1154,13 +1156,9 @@ virXMLParseHelper(int domcode, pctxt->sax->error =3D catchXMLError; =20 if (filename) { - xml =3D xmlCtxtReadFile(pctxt, filename, NULL, - XML_PARSE_NONET | - XML_PARSE_NOWARNING); + xml =3D xmlCtxtReadFile(pctxt, filename, NULL, parseFlags); } else { - xml =3D xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL, - XML_PARSE_NONET | - XML_PARSE_NOWARNING); + xml =3D xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL, parseFla= gs); } =20 if (!xml) { --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Fri May 10 20:03:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1700563106847714.6144605492469; Tue, 21 Nov 2023 02:38:26 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id A280E17C1; Tue, 21 Nov 2023 05:38:25 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5516B18C0; Tue, 21 Nov 2023 05:29:20 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 13B20179E; Tue, 21 Nov 2023 05:28:25 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 5E59D17A4 for ; Tue, 21 Nov 2023 05:28:23 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-E02BIcweM7Gd6baYNWMXzg-1; Tue, 21 Nov 2023 05:28:21 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38038811E86 for ; Tue, 21 Nov 2023 10:28:21 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7D9B492BE7 for ; Tue, 21 Nov 2023 10:28:20 +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.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: E02BIcweM7Gd6baYNWMXzg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 5/6] virxml: Introduce parsing APIs that keep indentation Date: Tue, 21 Nov 2023 11:28:15 +0100 Message-ID: <231a885a8ba391ae0186449f3abc35e92aa26298.1700562423.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 6HDLBQ4BAHX5PWIYPBQWNMLUFD2DGKBK X-Message-ID-Hash: 6HDLBQ4BAHX5PWIYPBQWNMLUFD2DGKBK X-MailFrom: mprivozn@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: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1700563108638100001 When parsing an XML it may be important to keep indentation to produce a better looking result when formatting the XML back. Just look at all those xmlKeepBlanksDefault() calls just before virXMLParse() is called. Anyway, as of libxml2 commit v2.12.0~108 xmlKeepBlanksDefault() is deprecated. Therefore, introduce virXMLParse...WithIndent() variants which would do exactly xmlKeepBlanksDefault() did but with non-deprecated APIs. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 15 +++++++++++++-- src/util/virxml.h | 29 +++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 31685cddde..e94708448a 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1129,14 +1129,16 @@ virXMLParseHelper(int domcode, const char *rootelement, xmlXPathContextPtr *ctxt, const char *schemafile, - bool validate) + bool validate, + bool keepindent) { struct virParserData private; g_autoptr(xmlParserCtxt) pctxt =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; xmlNodePtr rootnode; const char *docname; - const int parseFlags =3D XML_PARSE_NONET | + int oldIndentTreeOutput =3D 0; + int parseFlags =3D XML_PARSE_NONET | XML_PARSE_NOWARNING; =20 if (filename) @@ -1155,12 +1157,21 @@ virXMLParseHelper(int domcode, pctxt->_private =3D &private; pctxt->sax->error =3D catchXMLError; =20 + if (keepindent) { + parseFlags |=3D XML_PARSE_NOBLANKS; + xmlIndentTreeOutput =3D 1; + } + if (filename) { xml =3D xmlCtxtReadFile(pctxt, filename, NULL, parseFlags); } else { xml =3D xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL, parseFla= gs); } =20 + if (keepindent) { + xmlIndentTreeOutput =3D oldIndentTreeOutput; + } + if (!xml) { if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) { virGenericReportError(domcode, VIR_ERR_XML_ERROR, diff --git a/src/util/virxml.h b/src/util/virxml.h index 7af47437bd..03a85bfb25 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -199,7 +199,8 @@ virXMLParseHelper(int domcode, const char *rootelement, xmlXPathContextPtr *ctxt, const char *schemafile, - bool validate); + bool validate, + bool keepindent); =20 const char * virXMLPickShellSafeComment(const char *str1, @@ -219,7 +220,17 @@ virXMLPickShellSafeComment(const char *str1, * Return the parsed document object, or NULL on failure. */ #define virXMLParse(filename, xmlStr, url, rootelement, ctxt, schemafile, = validate) \ - virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, rootelement, c= txt, schemafile, validate) + virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, rootelement, c= txt, schemafile, validate, false) + +/** + * virXMLParseWithIndent: + * + * Just like virXMLParse, except indentation is preserved. Should be used = when + * facing an user provided XML which may be formatted back and keeping ver= batim + * spacing is necessary (e.g. due to ). + */ +#define virXMLParseWithIndent(filename, xmlStr, url, rootelement, ctxt, sc= hemafile, validate) \ + virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, rootelement, c= txt, schemafile, validate, true) =20 /** * virXMLParseStringCtxt: @@ -233,7 +244,17 @@ virXMLPickShellSafeComment(const char *str1, * Return the parsed document object, or NULL on failure. */ #define virXMLParseStringCtxt(xmlStr, url, pctxt) \ - virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, pctxt, NULL,= false) + virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, pctxt, NULL,= false, false) + +/** + * virXMLParseStringCtxtWithIndent: + * + * Just like virXMLParseStringCtxt, except indentation is preserved. Shou= ld be + * used when facing an user provided XML which may be formatted back and + * keeping verbatim spacing is necessary (e.g. due to ). + */ +#define virXMLParseStringCtxtWithIndent(xmlStr, url, pctxt) \ + virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, pctxt, NULL,= false, true) =20 /** * virXMLParseFileCtxt: @@ -246,7 +267,7 @@ virXMLPickShellSafeComment(const char *str1, * Return the parsed document object, or NULL on failure. */ #define virXMLParseFileCtxt(filename, pctxt) \ - virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, NULL, pctxt, NU= LL, false) + virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, NULL, pctxt, NU= LL, false, false) =20 int virXMLSaveFile(const char *path, --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Fri May 10 20:03:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1700562998526860.5796027263694; Tue, 21 Nov 2023 02:36:38 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5A4C018EB; Tue, 21 Nov 2023 05:36:37 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 59FA518AE; Tue, 21 Nov 2023 05:29:10 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9D54C17A8; Tue, 21 Nov 2023 05:28:24 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 DEBFD179B for ; Tue, 21 Nov 2023 05:28:23 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-tdanw04YOOaf4VXcAdJIPQ-1; Tue, 21 Nov 2023 05:28:22 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id C002C3816D90 for ; Tue, 21 Nov 2023 10:28:21 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BA7B492BE0 for ; Tue, 21 Nov 2023 10:28:21 +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.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: tdanw04YOOaf4VXcAdJIPQ-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 6/6] lib: Replace xmlKeepBlanksDefault() with virXMLParseWithIndent() Date: Tue, 21 Nov 2023 11:28:16 +0100 Message-ID: <987ef3ed156367ed90a220385e6586961f141904.1700562423.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: GPO4ENWYA77CCUV65YY4BYKAYWVGCYU5 X-Message-ID-Hash: GPO4ENWYA77CCUV65YY4BYKAYWVGCYU5 X-MailFrom: mprivozn@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: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1700563000780100001 Now that we have virXMLParseWithIndent() and virXMLParseStringCtxtWithIndent(), we can use them directly and drop calls to xmlKeepBlanksDefault(). Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/backup_conf.c | 8 +++----- src/conf/checkpoint_conf.c | 8 +++----- src/conf/domain_conf.c | 11 +++-------- src/conf/network_conf.c | 6 ++---- src/conf/snapshot_conf.c | 8 +++----- tools/virsh-util.c | 5 +---- 6 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index e151c29738..1fea6a2be7 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -276,13 +276,11 @@ virDomainBackupDefParseString(const char *xmlStr, { g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - int keepBlanksDefault =3D xmlKeepBlanksDefault(0); bool validate =3D !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL); =20 - xml =3D virXMLParse(NULL, xmlStr, _("(domain_backup)"), - "domainbackup", &ctxt, "domainbackup.rng", validate); - - xmlKeepBlanksDefault(keepBlanksDefault); + xml =3D virXMLParseWithIndent(NULL, xmlStr, _("(domain_backup)"), + "domainbackup", &ctxt, "domainbackup.rng", + validate); =20 if (!xml) return NULL; diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index 89f8675235..3c797f0f5b 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -192,12 +192,10 @@ virDomainCheckpointDefParseString(const char *xmlStr, { g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - int keepBlanksDefault =3D xmlKeepBlanksDefault(0); =20 - xml =3D virXMLParse(NULL, xmlStr, _("(domain_checkpoint)"), - "domaincheckpoint", &ctxt, "domaincheckpoint.rng", t= rue); - - xmlKeepBlanksDefault(keepBlanksDefault); + xml =3D virXMLParseWithIndent(NULL, xmlStr, _("(domain_checkpoint)"), + "domaincheckpoint", &ctxt, + "domaincheckpoint.rng", true); =20 if (!xml) return NULL; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bef76f46aa..428147fe44 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19503,13 +19503,10 @@ virDomainDefParse(const char *xmlStr, { g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - int keepBlanksDefault =3D xmlKeepBlanksDefault(0); bool validate =3D flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 - xml =3D virXMLParse(filename, xmlStr, _("(domain_definition)"), - "domain", &ctxt, "domain.rng", validate); - - xmlKeepBlanksDefault(keepBlanksDefault); + xml =3D virXMLParseWithIndent(filename, xmlStr, _("(domain_definition)= "), + "domain", &ctxt, "domain.rng", validate); =20 if (!xml) return NULL; @@ -19566,10 +19563,8 @@ virDomainObjParseFile(const char *filename, { g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - int keepBlanksDefault =3D xmlKeepBlanksDefault(0); =20 - xml =3D virXMLParse(filename, NULL, NULL, "domstatus", &ctxt, NULL, fa= lse); - xmlKeepBlanksDefault(keepBlanksDefault); + xml =3D virXMLParseWithIndent(filename, NULL, NULL, "domstatus", &ctxt= , NULL, false); =20 if (!xml) return NULL; diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 1a6fd86180..0449b6f07c 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1962,11 +1962,9 @@ virNetworkDefParse(const char *xmlStr, { g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - int keepBlanksDefault =3D xmlKeepBlanksDefault(0); =20 - xml =3D virXMLParse(filename, xmlStr, _("(network_definition)"), - "network", &ctxt, "network.rng", validate); - xmlKeepBlanksDefault(keepBlanksDefault); + xml =3D virXMLParseWithIndent(filename, xmlStr, _("(network_definition= )"), + "network", &ctxt, "network.rng", validate); =20 if (!xml) return NULL; diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 4b0555eb8c..d7fcded302 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -426,13 +426,11 @@ virDomainSnapshotDefParseString(const char *xmlStr, { g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; - int keepBlanksDefault =3D xmlKeepBlanksDefault(0); bool validate =3D flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE; =20 - xml =3D virXMLParse(NULL, xmlStr, _("(domain_snapshot)"), - "domainsnapshot", &ctxt, "domainsnapshot.rng", valid= ate); - - xmlKeepBlanksDefault(keepBlanksDefault); + xml =3D virXMLParseWithIndent(NULL, xmlStr, _("(domain_snapshot)"), + "domainsnapshot", &ctxt, "domainsnapshot.r= ng", + validate); =20 if (!xml) return NULL; diff --git a/tools/virsh-util.c b/tools/virsh-util.c index fb6327613a..a6026eed53 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -474,16 +474,13 @@ virshDumpXML(vshControl *ctl, g_autofree xmlNodePtr *nodes =3D NULL; int nnodes =3D 0; size_t i; - int oldblanks; =20 if (xpath =3D=3D NULL) { vshPrint(ctl, "%s", xml); return true; } =20 - oldblanks =3D xmlKeepBlanksDefault(0); - doc =3D virXMLParseStringCtxt(xml, url, &ctxt); - xmlKeepBlanksDefault(oldblanks); + doc =3D virXMLParseStringCtxtWithIndent(xml, url, &ctxt); if (!doc) return false; =20 --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org