[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] conf: cpu: Fix to escape cpu model, vendor_id and vendor

This patch fixes a problem that encoded xml special charas
of cpu model, vendor_id and vendor are saved as decoded xml
special charas.

If I define model name including encoded xml special charas
in domain XML like below:
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>&gt;&lt;</model>

domain xml definition file is saved as
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>><</model>

After that, if libvirtd is restarted, dumpxml command, edit
command and etc. are disabled with below error until I stop
libvirtd and fix the xml file manually.

2012-12-20 04:56:54.371+0000: 11893: error : catchXMLError:691 :
/etc/libvirt/qemu/f17.xml:25: StartTag: invalid element name
    <model fallback='allow'>><</model>

Also vendor_id and vendor have same problem.

Signed-off-by: Ken ICHIKAWA <ichikawa ken jp fujitsu com>
 src/conf/cpu_conf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 3973c83..e9f9431 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -609,17 +609,17 @@ virCPUDefFormatBuf(virBufferPtr buf,
             virBufferAsprintf(buf, " fallback='%s'", fallback);
             if (def->vendor_id)
-                virBufferAsprintf(buf, " vendor_id='%s'", def->vendor_id);
+                virBufferEscapeString(buf, " vendor_id='%s'", def->vendor_id);
         if (formatModel && def->model) {
-            virBufferAsprintf(buf, ">%s</model>\n", def->model);
+            virBufferEscapeString(buf, ">%s</model>\n", def->model);
         } else {
             virBufferAddLit(buf, "/>\n");
     if (formatModel && def->vendor)
-        virBufferAsprintf(buf, "<vendor>%s</vendor>\n", def->vendor);
+        virBufferEscapeString(buf, "<vendor>%s</vendor>\n", def->vendor);
     if (def->sockets && def->cores && def->threads) {
         virBufferAddLit(buf, "<topology");

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]