|
|
edecca |
From 45fb61b56bbd74f365b71e9e35bf953dc045833e Mon Sep 17 00:00:00 2001
|
|
|
edecca |
Message-Id: <45fb61b56bbd74f365b71e9e35bf953dc045833e@dist-git>
|
|
|
edecca |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
edecca |
Date: Thu, 22 Nov 2018 16:28:56 +0100
|
|
|
edecca |
Subject: [PATCH] virsh: Strip XML declaration when extracting CPU XMLs
|
|
|
edecca |
MIME-Version: 1.0
|
|
|
edecca |
Content-Type: text/plain; charset=UTF-8
|
|
|
edecca |
Content-Transfer-Encoding: 8bit
|
|
|
edecca |
|
|
|
edecca |
Since commit v4.3.0-336-gc84726fbdd all
|
|
|
edecca |
{hypervisor-,}cpu-{baseline,compare} commands use a generic
|
|
|
edecca |
vshExtractCPUDefXMLs helper for extracting individual CPU definitions
|
|
|
edecca |
from the provided input file. The helper wraps the input file in a
|
|
|
edecca |
<container> element so that several independent elements can be easily
|
|
|
edecca |
parsed from the file. This works fine except when the file starts with
|
|
|
edecca |
XML declaration () because the XML declaration
|
|
|
edecca |
cannot be put inside any element. In fact it has to be at the very
|
|
|
edecca |
beginning of the XML document without any preceding white space
|
|
|
edecca |
characters. We can just simply skip the XML declaration.
|
|
|
edecca |
|
|
|
edecca |
https://bugzilla.redhat.com/show_bug.cgi?id=1592737
|
|
|
edecca |
|
|
|
edecca |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
edecca |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
edecca |
(cherry picked from commit fcd1c865e168bdb9763b19e790c15e80aa29be66)
|
|
|
edecca |
|
|
|
edecca |
https://bugzilla.redhat.com/show_bug.cgi?id=1659048
|
|
|
edecca |
|
|
|
edecca |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
edecca |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
edecca |
---
|
|
|
edecca |
tools/virsh-host.c | 9 ++++++++-
|
|
|
edecca |
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
edecca |
|
|
|
edecca |
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
|
|
|
edecca |
index 16f504bafe..b7f86bdd91 100644
|
|
|
edecca |
--- a/tools/virsh-host.c
|
|
|
edecca |
+++ b/tools/virsh-host.c
|
|
|
edecca |
@@ -1130,13 +1130,20 @@ vshExtractCPUDefXMLs(vshControl *ctl,
|
|
|
edecca |
xmlDocPtr xml = NULL;
|
|
|
edecca |
xmlXPathContextPtr ctxt = NULL;
|
|
|
edecca |
xmlNodePtr *nodes = NULL;
|
|
|
edecca |
+ char *doc;
|
|
|
edecca |
size_t i;
|
|
|
edecca |
int n;
|
|
|
edecca |
|
|
|
edecca |
if (virFileReadAll(xmlFile, VSH_MAX_XML_FILE, &buffer) < 0)
|
|
|
edecca |
goto error;
|
|
|
edecca |
|
|
|
edecca |
- if (virAsprintf(&xmlStr, "<container>%s</container>", buffer) < 0)
|
|
|
edecca |
+ /* Strip possible XML declaration */
|
|
|
edecca |
+ if (STRPREFIX(buffer, "")))
|
|
|
edecca |
+ doc += 2;
|
|
|
edecca |
+ else
|
|
|
edecca |
+ doc = buffer;
|
|
|
edecca |
+
|
|
|
edecca |
+ if (virAsprintf(&xmlStr, "<container>%s</container>", doc) < 0)
|
|
|
edecca |
goto error;
|
|
|
edecca |
|
|
|
edecca |
if (!(xml = virXMLParseStringCtxt(xmlStr, xmlFile, &ctxt)))
|
|
|
edecca |
--
|
|
|
edecca |
2.20.1
|
|
|
edecca |
|