From 215a4afe93c051e35d09fabea19172ab51959737 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Mon, 20 Nov 2023 16:20:51 +0100
Subject: [PATCH 7/8] lib: Replace xmlKeepBlanksDefault() with
virXMLParseWithIndent()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Now that we have virXMLParseWithIndent() and
virXMLParseStringCtxtWithIndent(), we can use them directly and
drop calls to xmlKeepBlanksDefault().
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 1fdca3083b52507d7a99f6e9b84e91d8df68013e)
---
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 = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
bool validate = !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL);
- xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"),
- "domainbackup", &ctxt, "domainbackup.rng", validate);
-
- xmlKeepBlanksDefault(keepBlanksDefault);
+ xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_backup)"),
+ "domainbackup", &ctxt, "domainbackup.rng",
+ validate);
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 = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
- xml = virXMLParse(NULL, xmlStr, _("(domain_checkpoint)"),
- "domaincheckpoint", &ctxt, "domaincheckpoint.rng", true);
-
- xmlKeepBlanksDefault(keepBlanksDefault);
+ xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_checkpoint)"),
+ "domaincheckpoint", &ctxt,
+ "domaincheckpoint.rng", true);
if (!xml)
return NULL;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 80f467ae7a..2b6f765b6d 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 = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
bool validate = flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
- xml = virXMLParse(filename, xmlStr, _("(domain_definition)"),
- "domain", &ctxt, "domain.rng", validate);
-
- xmlKeepBlanksDefault(keepBlanksDefault);
+ xml = virXMLParseWithIndent(filename, xmlStr, _("(domain_definition)"),
+ "domain", &ctxt, "domain.rng", validate);
if (!xml)
return NULL;
@@ -19566,10 +19563,8 @@ virDomainObjParseFile(const char *filename,
{
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
- xml = virXMLParse(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
- xmlKeepBlanksDefault(keepBlanksDefault);
+ xml = virXMLParseWithIndent(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
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 = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
- xml = virXMLParse(filename, xmlStr, _("(network_definition)"),
- "network", &ctxt, "network.rng", validate);
- xmlKeepBlanksDefault(keepBlanksDefault);
+ xml = virXMLParseWithIndent(filename, xmlStr, _("(network_definition)"),
+ "network", &ctxt, "network.rng", validate);
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 = NULL;
g_autoptr(xmlDoc) xml = NULL;
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
bool validate = flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE;
- xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
- "domainsnapshot", &ctxt, "domainsnapshot.rng", validate);
-
- xmlKeepBlanksDefault(keepBlanksDefault);
+ xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_snapshot)"),
+ "domainsnapshot", &ctxt, "domainsnapshot.rng",
+ validate);
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 = NULL;
int nnodes = 0;
size_t i;
- int oldblanks;
if (xpath == NULL) {
vshPrint(ctl, "%s", xml);
return true;
}
- oldblanks = xmlKeepBlanksDefault(0);
- doc = virXMLParseStringCtxt(xml, url, &ctxt);
- xmlKeepBlanksDefault(oldblanks);
+ doc = virXMLParseStringCtxtWithIndent(xml, url, &ctxt);
if (!doc)
return false;
--
2.43.0