Fix libxml2 API changes
This commit is contained in:
parent
56d89b1d61
commit
80a3188a20
@ -1,10 +1,11 @@
|
|||||||
|
From b049f42dda977b094895acdf348304ba2f4f1cd4 Mon Sep 17 00:00:00 2001
|
||||||
From: Pavel Hrdina <phrdina@redhat.com>
|
From: Pavel Hrdina <phrdina@redhat.com>
|
||||||
Date: Fri, 3 Nov 2023 14:03:55 +0100
|
Date: Fri, 3 Nov 2023 14:03:55 +0100
|
||||||
Subject: [PATCH] qemu_process: fix crash in qemuSaveImageDecompressionStart
|
Subject: [PATCH 1/7] qemu_process: fix crash in
|
||||||
|
qemuSaveImageDecompressionStart
|
||||||
MIME-Version: 1.0
|
MIME-Version: 1.0
|
||||||
Content-Type: text/plain; charset=UTF-8
|
Content-Type: text/plain; charset=UTF-8
|
||||||
Content-Transfer-Encoding: 8bit
|
Content-Transfer-Encoding: 8bit
|
||||||
Content-type: text/plain
|
|
||||||
|
|
||||||
Commit changing the code to allow passing NULL as @data into
|
Commit changing the code to allow passing NULL as @data into
|
||||||
qemuSaveImageDecompressionStart() was not correct as it left the
|
qemuSaveImageDecompressionStart() was not correct as it left the
|
||||||
@ -14,6 +15,7 @@ Introduced-by: 2f3e582a1ac1008eba8d43c751cdba8712dd1614
|
|||||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2247754
|
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2247754
|
||||||
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
||||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||||
|
(cherry picked from commit 4f4a8dce944e05311565b690a84f6bb1ef67c086)
|
||||||
---
|
---
|
||||||
src/qemu/qemu_process.c | 3 ---
|
src/qemu/qemu_process.c | 3 ---
|
||||||
1 file changed, 3 deletions(-)
|
1 file changed, 3 deletions(-)
|
||||||
@ -32,3 +34,6 @@ index 1ef032dbd2..b9267d8699 100644
|
|||||||
/* No cookie means libvirt which saved the domain was too old to mess up
|
/* No cookie means libvirt which saved the domain was too old to mess up
|
||||||
* the CPU definitions.
|
* the CPU definitions.
|
||||||
*/
|
*/
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
||||||
|
109
0002-vbox_snapshot_conf-Parse-XMLs-without-net-access.patch
Normal file
109
0002-vbox_snapshot_conf-Parse-XMLs-without-net-access.patch
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
From 982184d57fff654c1cccf0d4a4a5d1631058819d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Date: Mon, 20 Nov 2023 04:49:53 +0100
|
||||||
|
Subject: [PATCH 2/7] vbox_snapshot_conf: Parse XMLs without net access
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
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 = 0, ...);
|
||||||
|
|
||||||
|
This is potentially dangerous.
|
||||||
|
|
||||||
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||||
|
(cherry picked from commit d8cb1cd50c608eb647fcb17c4347a2e9d5004e8d)
|
||||||
|
---
|
||||||
|
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 = 0;
|
||||||
|
g_auto(GStrv) secondRegex = NULL;
|
||||||
|
int secondRegexResult = 0;
|
||||||
|
+ const int parseFlags = XML_PARSE_NONET;
|
||||||
|
|
||||||
|
uuid = g_strdup_printf("{%s}", snapshot->uuid);
|
||||||
|
|
||||||
|
@@ -406,7 +407,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node,
|
||||||
|
parseError = xmlParseInNodeContext(node,
|
||||||
|
snapshot->hardware,
|
||||||
|
(int)strlen(snapshot->hardware),
|
||||||
|
- 0,
|
||||||
|
+ parseFlags,
|
||||||
|
&hardwareNode);
|
||||||
|
if (parseError != 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) != XML_ERR_OK) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("Unable to add the snapshot storageController"));
|
||||||
|
@@ -944,6 +945,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||||
|
int firstRegexResult = 0;
|
||||||
|
g_auto(GStrv) secondRegex = NULL;
|
||||||
|
int secondRegexResult = 0;
|
||||||
|
+ const int parseFlags = XML_PARSE_NONET;
|
||||||
|
|
||||||
|
if (machine == NULL) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
@@ -1051,7 +1053,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||||
|
parseError = xmlParseInNodeContext(mediaRegistryNode,
|
||||||
|
machine->mediaRegistry->otherMedia[i],
|
||||||
|
(int)strlen(machine->mediaRegistry->otherMedia[i]),
|
||||||
|
- 0,
|
||||||
|
+ parseFlags,
|
||||||
|
&cur);
|
||||||
|
if (parseError != XML_ERR_OK) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
@@ -1071,7 +1073,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||||
|
parseError = xmlParseInNodeContext(machineNode,
|
||||||
|
machine->hardware,
|
||||||
|
(int)strlen(machine->hardware),
|
||||||
|
- 0,
|
||||||
|
+ parseFlags,
|
||||||
|
&cur);
|
||||||
|
if (parseError != XML_ERR_OK) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
@@ -1084,7 +1086,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||||
|
parseError = xmlParseInNodeContext(xmlDocGetRootElement(xml),
|
||||||
|
machine->extraData,
|
||||||
|
(int)strlen(machine->extraData),
|
||||||
|
- 0,
|
||||||
|
+ parseFlags,
|
||||||
|
&cur);
|
||||||
|
if (parseError != XML_ERR_OK) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
@@ -1097,7 +1099,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||||
|
parseError = xmlParseInNodeContext(machineNode,
|
||||||
|
machine->storageController,
|
||||||
|
(int)strlen(machine->storageController),
|
||||||
|
- 0,
|
||||||
|
+ parseFlags,
|
||||||
|
&cur);
|
||||||
|
if (parseError != XML_ERR_OK) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
76
0003-vbox_snapshot_conf-Keep-indent-in-snapshot-XML.patch
Normal file
76
0003-vbox_snapshot_conf-Keep-indent-in-snapshot-XML.patch
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
From ee3f790a24ec16308e016f9e7dc1cc5e29a6a525 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Date: Tue, 21 Nov 2023 10:40:36 +0100
|
||||||
|
Subject: [PATCH 3/7] vbox_snapshot_conf: Keep indent in snapshot XML
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
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 <mprivozn@redhat.com>
|
||||||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||||
|
(cherry picked from commit d1f58b10f687050dd097c5a60becf62c35deee68)
|
||||||
|
---
|
||||||
|
src/vbox/vbox_snapshot_conf.c | 12 ++++++++----
|
||||||
|
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
|
||||||
|
index 467255f77f..89cd685954 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"
|
||||||
|
|
||||||
|
+#include <libxml/xmlsave.h>
|
||||||
|
#include <libxml/xpathInternals.h>
|
||||||
|
|
||||||
|
#define VIR_FROM_THIS VIR_FROM_VBOX
|
||||||
|
@@ -364,12 +365,11 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node,
|
||||||
|
xmlParserErrors parseError = XML_ERR_OK;
|
||||||
|
char *uuid = NULL;
|
||||||
|
char *timeStamp = NULL;
|
||||||
|
-
|
||||||
|
g_auto(GStrv) firstRegex = NULL;
|
||||||
|
int firstRegexResult = 0;
|
||||||
|
g_auto(GStrv) secondRegex = NULL;
|
||||||
|
int secondRegexResult = 0;
|
||||||
|
- const int parseFlags = XML_PARSE_NONET;
|
||||||
|
+ const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOBLANKS;
|
||||||
|
|
||||||
|
uuid = g_strdup_printf("{%s}", snapshot->uuid);
|
||||||
|
|
||||||
|
@@ -940,12 +940,14 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||||
|
xmlParserErrors parseError = XML_ERR_OK;
|
||||||
|
char *currentSnapshot = NULL;
|
||||||
|
char *timeStamp = NULL;
|
||||||
|
-
|
||||||
|
g_auto(GStrv) firstRegex = NULL;
|
||||||
|
int firstRegexResult = 0;
|
||||||
|
g_auto(GStrv) secondRegex = NULL;
|
||||||
|
int secondRegexResult = 0;
|
||||||
|
- const int parseFlags = XML_PARSE_NONET;
|
||||||
|
+ const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOBLANKS;
|
||||||
|
+ int oldIndentTreeOutput = xmlIndentTreeOutput;
|
||||||
|
+
|
||||||
|
+ xmlIndentTreeOutput = 1;
|
||||||
|
|
||||||
|
if (machine == NULL) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
@@ -1127,6 +1129,8 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
+ xmlIndentTreeOutput = oldIndentTreeOutput;
|
||||||
|
+
|
||||||
|
VIR_FREE(currentSnapshot);
|
||||||
|
VIR_FREE(timeStamp);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
@ -0,0 +1,36 @@
|
|||||||
|
From 09f06f6286f864fefdf4877b5792999e0d4e89d1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Date: Mon, 20 Nov 2023 03:18:12 +0100
|
||||||
|
Subject: [PATCH 4/7] virxml: include <libxml/xmlsave.h> for
|
||||||
|
xmlIndentTreeOutput declaration
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
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 <mprivozn@redhat.com>
|
||||||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||||
|
(cherry picked from commit 7a5f232be2269e74943a029c0e8b1b0124674a6c)
|
||||||
|
---
|
||||||
|
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 <math.h> /* for isnan() */
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
+#include <libxml/xmlsave.h>
|
||||||
|
#include <libxml/xpathInternals.h>
|
||||||
|
|
||||||
|
#include "virerror.h"
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
@ -0,0 +1,51 @@
|
|||||||
|
From 68a14369033486ad9e02cb144cde2aced7351ce2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Date: Sat, 18 Nov 2023 04:17:47 +0100
|
||||||
|
Subject: [PATCH 5/7] virXMLParseHelper: Store XML parsing flags in a variable
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
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 <mprivozn@redhat.com>
|
||||||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||||
|
(cherry picked from commit 1beb69df877596fe57efc8d8a117a30a72e5d04e)
|
||||||
|
---
|
||||||
|
src/util/virxml.c | 9 +++------
|
||||||
|
1 file changed, 3 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/util/virxml.c b/src/util/virxml.c
|
||||||
|
index 4f215a0e59..027cdb97b9 100644
|
||||||
|
--- a/src/util/virxml.c
|
||||||
|
+++ b/src/util/virxml.c
|
||||||
|
@@ -1136,6 +1136,7 @@ virXMLParseHelper(int domcode,
|
||||||
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
|
xmlNodePtr rootnode;
|
||||||
|
const char *docname;
|
||||||
|
+ const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOWARNING;
|
||||||
|
|
||||||
|
if (filename)
|
||||||
|
docname = filename;
|
||||||
|
@@ -1154,13 +1155,9 @@ virXMLParseHelper(int domcode,
|
||||||
|
pctxt->sax->error = catchXMLError;
|
||||||
|
|
||||||
|
if (filename) {
|
||||||
|
- xml = xmlCtxtReadFile(pctxt, filename, NULL,
|
||||||
|
- XML_PARSE_NONET |
|
||||||
|
- XML_PARSE_NOWARNING);
|
||||||
|
+ xml = xmlCtxtReadFile(pctxt, filename, NULL, parseFlags);
|
||||||
|
} else {
|
||||||
|
- xml = xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL,
|
||||||
|
- XML_PARSE_NONET |
|
||||||
|
- XML_PARSE_NOWARNING);
|
||||||
|
+ xml = xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL, parseFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!xml) {
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
123
0006-virxml-Introduce-parsing-APIs-that-keep-indentation.patch
Normal file
123
0006-virxml-Introduce-parsing-APIs-that-keep-indentation.patch
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
From 6371a0d85b6febd8e034eeec02d70c551535ad5b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Date: Tue, 21 Nov 2023 10:39:58 +0100
|
||||||
|
Subject: [PATCH 6/7] virxml: Introduce parsing APIs that keep indentation
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
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 <mprivozn@redhat.com>
|
||||||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||||
|
(cherry picked from commit 69958ba3102810bb4f90a91d2f6d9032e1a1da2d)
|
||||||
|
---
|
||||||
|
src/util/virxml.c | 9 +++++++--
|
||||||
|
src/util/virxml.h | 29 +++++++++++++++++++++++++----
|
||||||
|
2 files changed, 32 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/util/virxml.c b/src/util/virxml.c
|
||||||
|
index 027cdb97b9..6d0c8f0311 100644
|
||||||
|
--- a/src/util/virxml.c
|
||||||
|
+++ b/src/util/virxml.c
|
||||||
|
@@ -1129,14 +1129,15 @@ virXMLParseHelper(int domcode,
|
||||||
|
const char *rootelement,
|
||||||
|
xmlXPathContextPtr *ctxt,
|
||||||
|
const char *schemafile,
|
||||||
|
- bool validate)
|
||||||
|
+ bool validate,
|
||||||
|
+ bool keepindent)
|
||||||
|
{
|
||||||
|
struct virParserData private;
|
||||||
|
g_autoptr(xmlParserCtxt) pctxt = NULL;
|
||||||
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
|
xmlNodePtr rootnode;
|
||||||
|
const char *docname;
|
||||||
|
- const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOWARNING;
|
||||||
|
+ int parseFlags = XML_PARSE_NONET | XML_PARSE_NOWARNING;
|
||||||
|
|
||||||
|
if (filename)
|
||||||
|
docname = filename;
|
||||||
|
@@ -1154,6 +1155,10 @@ virXMLParseHelper(int domcode,
|
||||||
|
pctxt->_private = &private;
|
||||||
|
pctxt->sax->error = catchXMLError;
|
||||||
|
|
||||||
|
+ if (keepindent) {
|
||||||
|
+ parseFlags |= XML_PARSE_NOBLANKS;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (filename) {
|
||||||
|
xml = xmlCtxtReadFile(pctxt, filename, NULL, parseFlags);
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
|
||||||
|
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, ctxt, schemafile, validate)
|
||||||
|
+ virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, rootelement, ctxt, 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 verbatim
|
||||||
|
+ * spacing is necessary (e.g. due to <metadata/>).
|
||||||
|
+ */
|
||||||
|
+#define virXMLParseWithIndent(filename, xmlStr, url, rootelement, ctxt, schemafile, validate) \
|
||||||
|
+ virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, rootelement, ctxt, schemafile, validate, true)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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. Should be
|
||||||
|
+ * used when facing an user provided XML which may be formatted back and
|
||||||
|
+ * keeping verbatim spacing is necessary (e.g. due to <metadata/>).
|
||||||
|
+ */
|
||||||
|
+#define virXMLParseStringCtxtWithIndent(xmlStr, url, pctxt) \
|
||||||
|
+ virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, pctxt, NULL, false, true)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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, NULL, false)
|
||||||
|
+ virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, NULL, pctxt, NULL, false, false)
|
||||||
|
|
||||||
|
int
|
||||||
|
virXMLSaveFile(const char *path,
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
162
0007-lib-Replace-xmlKeepBlanksDefault-with-virXMLParseWit.patch
Normal file
162
0007-lib-Replace-xmlKeepBlanksDefault-with-virXMLParseWit.patch
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
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/7] 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
|
||||||
|
|
@ -251,7 +251,14 @@ URL: https://libvirt.org/
|
|||||||
Source: https://download.libvirt.org/%{?mainturl}libvirt-%{version}.tar.xz
|
Source: https://download.libvirt.org/%{?mainturl}libvirt-%{version}.tar.xz
|
||||||
|
|
||||||
# Fix crash with snapshot restore (bz #2247754)
|
# Fix crash with snapshot restore (bz #2247754)
|
||||||
Patch0001: 0001-qemu_process-fix-crash-in-qemuSaveImageDecompression.patch
|
Patch: 0001-qemu_process-fix-crash-in-qemuSaveImageDecompression.patch
|
||||||
|
# Fix libxml2 API changes
|
||||||
|
Patch: 0002-vbox_snapshot_conf-Parse-XMLs-without-net-access.patch
|
||||||
|
Patch: 0003-vbox_snapshot_conf-Keep-indent-in-snapshot-XML.patch
|
||||||
|
Patch: 0004-virxml-include-libxml-xmlsave.h-for-xmlIndentTreeOut.patch
|
||||||
|
Patch: 0005-virXMLParseHelper-Store-XML-parsing-flags-in-a-varia.patch
|
||||||
|
Patch: 0006-virxml-Introduce-parsing-APIs-that-keep-indentation.patch
|
||||||
|
Patch: 0007-lib-Replace-xmlKeepBlanksDefault-with-virXMLParseWit.patch
|
||||||
|
|
||||||
Requires: libvirt-daemon = %{version}-%{release}
|
Requires: libvirt-daemon = %{version}-%{release}
|
||||||
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
||||||
|
Loading…
Reference in New Issue
Block a user