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