Bug 726771

Summary: libvirt does not specify problem file if persistent xml is invalid
Product: Red Hat Enterprise Linux 6 Reporter: Dave Allan <dallan>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 6.2CC: dyuan, mzhan, rwu, whuang, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: libvirt-0.9.9-1.el6 Doc Type: Bug Fix
Doc Text:
Libvirt made a lot of improvements in reporting errors in XML file parsing that make identifying error easier.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 06:29:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dave Allan 2011-07-29 18:38:48 UTC
If a user mistakenly edits the persistent XML on disk instead of using API editing commands, it's possible for the persistent XML on disk to become invalid.  Of course, users should not be editing the XML on disk, so this situation should not happen(™).  Since users frequently do edit the on disk XML, we should try to let them know what they broke.  Currently if I break the XML for a qemu domain, the result in /var/log/libvirt/libvirtd.log is:

10:53:14.690: 793: error : catchXMLError:653 : at line 28: Opening and ending tag mismatch: memory line 11 and domain

which is great if I know what I'm looking for, because it tells me what's wrong with the XML.  However, if all I know is that my VM suddenly vanished, it doesn't help me much in figuring out why.  I would like to see additionally an error message along the lines of:

failed to parse domain [or network, etc] XML from /etc/libvirt/qemu/goat.xml

which would tell me what file is broken.

Comment 3 Peter Krempa 2011-09-06 14:56:46 UTC
Fixed in upstream:

commit 9fd3bb7a88bd41a5cf4830529b3b3c87260be62e
Author: Peter Krempa <pkrempa>
Date:   Tue Sep 6 15:48:22 2011 +0800

    XML: Improve XML parsing error messages

Comment 6 yanbing du 2012-01-10 07:04:51 UTC
Test this bug on libvirt-0.9.9-1.el6.x86_64.
Edit the persistent XML file of a guest on disk, such as:
----<snip>----

<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/rhel6_x86_64_qcow2.img --->here, delete the end tag(" '/> ").
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>

----</snip>----
then restart libvirtd, the guest disappeared in virsh list, and we can find the following error message in libvirtd log:
----<snip>----

2012-01-10 07:02:26.415+0000: 9309: error : virCommandWait:2271 : internal error Child process (/sbin/iscsiadm --mode session) status unexpected: exit status 21
2012-01-10 07:02:26.773+0000: 9309: error : catchXMLError:711 : /etc/libvirt/qemu/test.xml:32: Unescaped '<' not allowed in attributes values
      <target dev='vda' bus='virtio'/>
------^

----</snip>----

So move bug to VERIFIED

Comment 7 Peter Krempa 2012-05-02 13:49:23 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Libvirt made a lot of improvements in reporting errors in XML file parsing that make identifying error easier.

Comment 9 errata-xmlrpc 2012-06-20 06:29:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0748.html