RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 868692 - Libvirt: Double dash in VM causes it to disappear - bad parsing of XML
Summary: Libvirt: Double dash in VM causes it to disappear - bad parsing of XML
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.4
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: 6.4
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-10-21 19:25 UTC by Dave
Modified: 2013-02-21 07:10 UTC (History)
9 users (show)

Fixed In Version: libvirt-0.10.2-6.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-02-21 07:10:45 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Relevant XML and log files for this bug (3.19 KB, application/x-compressed-tar)
2012-10-21 19:25 UTC, Dave
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:0276 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2013-02-20 21:18:26 UTC

Description Dave 2012-10-21 19:25:45 UTC
Created attachment 630989 [details]
Relevant XML and log files for this bug

Description of problem:
OS: Scientific Linux 6.3 on x86-64

I came back after reboot to find a VM missing that I had been working on all night.  After google-researching a few things, I found that the VM was not appearing in the VM list due to a double dash:

# less /var/log/libvirt/libvirtd.log
[[
012-10-21 17:59:55.758+0000: 2877: error : catchXMLError:683 : /etc/libvirt/qemu/win7--64.xml:4: Comment not terminated
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES
  virsh edit win7--64
-----------------^
2012-10-21 18:06:18.977+0000: 2873: error : remoteDispatchAuthPolkit:2559 : Policy kit denied action org.libvirt.unix.manage from pid 3984, uid 500: exit status 1

---

The kVM had been created as "win7--64" and ended up in /etc/libvirt/qemu as "win7--64.xml".  Upon starting the ' virt-manager ', the VM was missing due to this bug because the XML parser couldn't detect that the double dash was part of the comment - not trying to end it.



Version-Release number of selected component (if applicable):
libvirt-0.9.10-21.el6_3.5.x86_64
kernel-2.6.32-279.el6.x86_64


How reproducible:
Should be 100%, but the whole thing was working OK until I rebooted

Steps to Reproduce:
1. See attachment - contains original .xml file, fixed .xml file, and relevant log files
2.
3.
  
Actual results:
Teh Craziness Happen(TM)

Expected results:
GUI should at least show some error messages as to why the kVM went missing :(
Also, XML parser should either escape the double dash, or disallow it to be created in the 1st place when constructing a kVM.

Additional info:

# Workaround fix:
o I was able to work around the problem by:

# virsh edit win7--64  # did not happen - error:
kvm error: Domain not found: no domain with matching name

# nano /etc/libvirt/qemu/win7--64.xml # and removed double-dashes
# mv /etc/libvirt/qemu/win7--64.xml win7-64.xml

' service libvirtd restart '

o After restarting ' virt-manager ', the missing VM turned up OK as "win7-64".
I was able to boot it OK, but it did not resume from its Suspended (Saved) state.

---

Refs:
http://www.mentby.com/Group/scientific-linux-users/kvm-vms-disappeared.html
http://permalink.gmane.org/gmane.linux.scientific.user/1778
http://wiki.libvirt.org/page/FAQ#My_VM_doesn.27t_show_up_with_.27virsh_list.27

---

note: I did search the bugzilla under libvirtd but did not find a matching bug:
https://bugzilla.redhat.com/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&product=Red+Hat+Enterprise+Linux+6&content=libvirt

Comment 1 Dave Allan 2012-10-22 15:42:18 UTC
It appears that a domain name with a double hyphen is causing libvirt to generate XML that does not comply with the W3C recommendation:

For compatibility, the string " -- " (double-hyphen) MUST NOT occur within comments.] See:

http://www.w3.org/TR/REC-xml/#sec-comments

Comment 3 Ján Tomko 2012-10-23 12:31:19 UTC
I have proposed a patch upstream that prevents putting double hyphens in the comment:
https://www.redhat.com/archives/libvir-list/2012-October/msg01268.html

Comment 4 Ján Tomko 2012-10-23 13:44:30 UTC
Fixed upstream by:

commit 9b704ab8235af010b1fda4886201aab02098b969
Author:     Ján Tomko <jtomko>
AuthorDate: Tue, 23 Oct 2012 14:16:44 +0200
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue, 23 Oct 2012 14:24:31 +0200

    xml: omit domain name from comment if it contains double hyphen
    
    We put a comment containing "virsh edit <domain_name>" at the start of
    the XML. W3C recommendation forbids the use of "--" in comments [1] and
    libvirt can't parse it either. This patch omits the domain name if it
    contains a double hyphen.
    
    [1] http://www.w3.org/TR/REC-xml/#sec-comments

Moving to POST:
http://post-office.corp.redhat.com/archives/rhvirt-patches/2012-October/msg01132.html

Comment 5 Ján Tomko 2012-10-25 09:17:50 UTC
This doesn't fix it for snapshots, as it only checks the snapshot name in that case, not the domain name:

2012-10-25 08:32:51.506+0000: 5460: error : catchXMLError:691 : (domain_snapshot):4: Double hyphen within comment: <!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES 
  virsh snapshot-edit free--dos 1351153952
--------------------------^
2012-10-25 08:32:51.506+0000: 5460: error : qemuDomainSnapshotLoad:514 : Failed to parse snapshot XML from file '/var/lib/libvirt/qemu/snapshot/free--dos/1351153952.xml'

Comment 7 zhpeng 2012-10-30 05:26:21 UTC
Reproduce it with:
libvirt-0.10.2-5.el6.x86_64

Test with:
libvirt-0.10.2-6.el6.x86_64

define/save/restore/snapshot

All passed.

So it's VERIFIED.

Comment 8 errata-xmlrpc 2013-02-21 07:10:45 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-2013-0276.html


Note You need to log in before you can comment on or make changes to this bug.