Univention Bugzilla – Bug 36098
"xm list" aborts with xml.parsers.expat.ExpatError
Last modified: 2015-01-21 12:23:29 CET
Created attachment 6149 [details] HACK system XML parser to ignore ASCII control characters Ticket#2014100821000491 This happens when the desription contains umlauts, as "xm list" uses the XML-RPC-API to XenD while "virsh list" uses the older HTTP-SXPR-API. Unexpected error: <class 'xml.parsers.expat.ExpatError'> Please report to xen-devel@lists.xensource.com Traceback (most recent call last): File "/usr/sbin/xm", line 7, in <module> main.main(sys.argv) File "/usr/lib/python2.6/dist-packages/xen/xm/main.py", line 3983, in main _, rc = _run_cmd(cmd, cmd_name, args) File "/usr/lib/python2.6/dist-packages/xen/xm/main.py", line 4007, in _run_cmd return True, cmd(args) File "/usr/lib/python2.6/dist-packages/xen/xm/main.py", line 1034, in xm_list doms = getDomains(params, state, use_long, pool) File "/usr/lib/python2.6/dist-packages/xen/xm/main.py", line 981, in getDomains return [server.xend.domain(dom, full) for dom in domain_names] File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__ return self.__send(self.__name, args) File "/usr/lib/python2.6/dist-packages/xen/util/xmlrpcclient.py", line 124, in __request response = xmlrpclib.ServerProxy.__request(self, methodname, params) File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request verbose=self.__verbose File "/usr/lib/python2.6/dist-packages/xen/util/xmlrpcclient.py", line 56, in request request_body, verbose) File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request return self._parse_response(h.getfile(), sock) File "/usr/lib/python2.6/xmlrpclib.py", line 1387, in _parse_response p.feed(response) File "/usr/lib/python2.6/xmlrpclib.py", line 601, in feed self._parser.Parse(data, 0) xml.parsers.expat.ExpatError: not well-formed (invalid token): line 46, column 28 /var/lib/xend/domains/5cf28d78-0a2b-a455-96df-a1e634553ac6/config.sxp looks right, so it seems to be a bug in XenD generating invalid XML output.
This is a XenD bug, which is hidden by UVMMd: albeit the broken description is fetched through libvirt, it gets overwritten by the still correct variant from LDAP: # virsh -c xen://lynx4.phahn.dev/ desc 783df368-2a6b-ae6d-88b5-ec8ffda059e4 Fr\\xc3\\xbcher war alles Schl\\xc3\\xa4cha!\\xe2\\x82\\xac # udm uvmm/info list --filter uuid=783df368-2a6b-ae6d-88b5-ec8ffda059e4 | grep desc description: Früher war alles Schlächa!€ # grep Fr /var/lib/xend/domains/783df368-2a6b-ae6d-88b5-ec8ffda059e4/config.sxp 'Fr\\xc3\\xbcher war aller Schl\\xc3\\xa4cha!\\xe2\\x82\\xac' 'Fr\\xc3\\xbcher war aller Schl\\xc3\\xa4cha!\\xe2\\x82\\xac' For each round of "virsh edit $DOM" the escaping get duplicated.
src/xenconfig/xen_sxpr.c: XenD -> libvirt 1128 if (sexpr_node_copy(root, "domain/description", &def->description) < 0) 1129 goto error; libvirt -> XenD 2222 if (def->description) 2223 virBufferEscapeSexpr(&buf, "(description '%s')", def->description);
Created attachment 6173 [details] xend: Fix hex decoding in sxp.Parser "xm list" sometimes failes with the following traceback: > Traceback (most recent call last): > File "/root/36098_xend-expat.py", line 84, in <module> > main_xmlrpc() > File "/root/36098_xend-expat.py", line 50, in main_xmlrpc > result = xend.xend.domain(UUID) > File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__ > return self.__send(self.__name, args) > File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request > verbose=self.__verbose > File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request > return self._parse_response(h.getfile(), sock) > File "/usr/lib/python2.6/xmlrpclib.py", line 1387, in _parse_response > p.feed(response) > File "/usr/lib/python2.6/xmlrpclib.py", line 601, in feed > self._parser.Parse(data, 0) > xml.parsers.expat.ExpatError: not well-formed (invalid token): line 45, column 18 This happens when the descriptive text for a VM contains non-ASCII-characters, which xen.xend.sxp.show() converts to Python hex-escapes: > print repr(unichr(8364).encode('UTF-8')) > '\xe2\x82\xac' On read-back those are processed by xen.xend.sxp.Parser.state_hex(), which is broken: 'a'..'f' respective 'A'..'F' are converted to 0..5 instead of 10..15. Thus the above sequence gets read back as: 'B\x82\x02'. When converted to XML this produces invalid XML, which breaks expat. Use Pythont int(..., 16) instead.
Sent upstream: <http://lists.xenproject.org/archives/html/xen-devel/2014-10/msg01819.html>
r56410 | Bug #36098 xen: Fix hex decoding in sxp.Parser Package: xen-4.1 Version: 4.1.3-17.43.201412031229 Branch: ucs_3.2-0 Scope: errata3.2-4 r56413 | Bug #36098 xen: Fix hex decoding in sxp.Parser YAML 2014-12-03-xen-4.1.yaml
Whoops, forgot to actually set this bug to verified.. OK: code change OK: having umlauts in the VM description does no longer crash xm list OK: YAML Verified
http://errata.univention.de/ucs/3.2/274.html