render / rpms / libvirt

Forked from rpms/libvirt 4 months ago
Clone
80a318
From ee3f790a24ec16308e016f9e7dc1cc5e29a6a525 Mon Sep 17 00:00:00 2001
80a318
From: Michal Privoznik <mprivozn@redhat.com>
80a318
Date: Tue, 21 Nov 2023 10:40:36 +0100
80a318
Subject: [PATCH 3/7] vbox_snapshot_conf: Keep indent in snapshot XML
80a318
MIME-Version: 1.0
80a318
Content-Type: text/plain; charset=UTF-8
80a318
Content-Transfer-Encoding: 8bit
80a318
80a318
As mentioned in previous commit, VirtualBox has its own snapshot
80a318
XML which we parse, change and then format back. During this, we
80a318
ought to keep the indentation to produce better looking result
80a318
(especially when we want to compare the output in tests later on,
80a318
like we do in vboxsnapshotxmltest).
80a318
80a318
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
80a318
Reviewed-by: Ján Tomko <jtomko@redhat.com>
80a318
(cherry picked from commit d1f58b10f687050dd097c5a60becf62c35deee68)
80a318
---
80a318
 src/vbox/vbox_snapshot_conf.c | 12 ++++++++----
80a318
 1 file changed, 8 insertions(+), 4 deletions(-)
80a318
80a318
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
80a318
index 467255f77f..89cd685954 100644
80a318
--- a/src/vbox/vbox_snapshot_conf.c
80a318
+++ b/src/vbox/vbox_snapshot_conf.c
80a318
@@ -25,6 +25,7 @@
80a318
 #include "virstring.h"
80a318
 #include "virxml.h"
80a318
 
80a318
+#include <libxml/xmlsave.h>
80a318
 #include <libxml/xpathInternals.h>
80a318
 
80a318
 #define VIR_FROM_THIS VIR_FROM_VBOX
80a318
@@ -364,12 +365,11 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node,
80a318
     xmlParserErrors parseError = XML_ERR_OK;
80a318
     char *uuid = NULL;
80a318
     char *timeStamp = NULL;
80a318
-
80a318
     g_auto(GStrv) firstRegex = NULL;
80a318
     int firstRegexResult = 0;
80a318
     g_auto(GStrv) secondRegex = NULL;
80a318
     int secondRegexResult = 0;
80a318
-    const int parseFlags = XML_PARSE_NONET;
80a318
+    const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOBLANKS;
80a318
 
80a318
     uuid = g_strdup_printf("{%s}", snapshot->uuid);
80a318
 
80a318
@@ -940,12 +940,14 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
80a318
     xmlParserErrors parseError = XML_ERR_OK;
80a318
     char *currentSnapshot = NULL;
80a318
     char *timeStamp = NULL;
80a318
-
80a318
     g_auto(GStrv) firstRegex = NULL;
80a318
     int firstRegexResult = 0;
80a318
     g_auto(GStrv) secondRegex = NULL;
80a318
     int secondRegexResult = 0;
80a318
-    const int parseFlags = XML_PARSE_NONET;
80a318
+    const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOBLANKS;
80a318
+    int oldIndentTreeOutput = xmlIndentTreeOutput;
80a318
+
80a318
+    xmlIndentTreeOutput = 1;
80a318
 
80a318
     if (machine == NULL) {
80a318
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
80a318
@@ -1127,6 +1129,8 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
80a318
     ret = 0;
80a318
 
80a318
  cleanup:
80a318
+    xmlIndentTreeOutput = oldIndentTreeOutput;
80a318
+
80a318
     VIR_FREE(currentSnapshot);
80a318
     VIR_FREE(timeStamp);
80a318
 
80a318
-- 
80a318
2.43.0
80a318