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

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

 



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:
<domain>
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>&gt;&lt;</model>
  </cpu>
</domain>

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

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@xxxxxxxxxxxxxx>
---
 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");
-- 
1.7.11.7


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]