Bug 1143921

Summary: Setting metadata with special character in key value caused guest failed to start and disappeared after restarting libvirtd.
Product: Red Hat Enterprise Linux 7 Reporter: Ruifeng <rbian>
Component: libvirtAssignee: Erik Skultety <eskultet>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, eskultet, lhuang, mzhan, rbalakri, zhwang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.13-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:53:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ruifeng 2014-09-18 09:18:58 UTC
description of problem:
Setting metadata with special character in key value caused guest failed to start and disappeared after restarting libvirtd.

version:
libvirt-1.2.8-2.el7.x86_64
qemu-kvm-1.5.3-60.el7.x86_64

How reproducible:
100%

step to reproduce:
1. set metadata for a shutoff guest
#virsh metadata virt-tests-vm1 "http://herp.derp/" "herp//" "<foo><bar>baz</bar></foo>"
Metadata modified

2. check the metadata.
# virsh metadata virt-tests-vm1 "http://herp.derp/"
<foo>
  <bar>baz</bar>
</foo>

# virsh dumpxml virt-tests-vm1 | grep "metadata" -A 4
  <metadata>
    <herp//:foo xmlns:herp//="http://herp.derp/">
      <herp//:bar>baz</herp//:bar>
    </herp//:foo>
  </metadata>

3. start the guest.
# virsh start virt-tests-vm1
error: Failed to start domain virt-tests-vm1
error: (domain_definition):5: error parsing attribute name
    <herp//:foo xmlns:herp//="http://herp.derp/">
---------^

4. restart libvirtd, the guest disappeared
# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service
# virsh list --all

Actual results:
As described.

Expect result:
The guest should be started sucessfully and don't disappear after libvirtd restart..

Comment 1 Erik Skultety 2014-12-10 09:31:39 UTC
Fixed upstream:

commit 2c22954f99a70ed654e4116a18f433afa24d41c5
Author: Erik Skultety <eskultet>
Date:   Thu Dec 4 14:37:09 2014 +0100

    util: check for an illegal character in a XML namespace prefix
    
    When user tries to insert element metadata providing a namespace
    declaration as well, currently we insert the element without any validation
    check for XML prefix (if provided). The next VM start would then
    fail with parse error. This patch fixes this issue by adding a call to
    xmlValidateNCName function to check for illegal characters in the
    prefix.

v1.2.10-277-g2c22954

Comment 3 Luyao Huang 2015-07-14 03:04:04 UTC
Verify this bug with libvirt-1.2.17-2.el7.x86_64:

1.
# virsh metadata test4 "http://herp.derp/" "herp//" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

2. test other

# virsh metadata test4 "http://herp.derp/" "herp#" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

# virsh metadata test4 "http://herp.derp/" "herp@" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

# virsh metadata test4 "http://herp.derp/" "herp!" "<foo><bar>baz</bar></foo>"
-bash: !": event not found
# virsh metadata test4 "http://herp.derp/" "herp~" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

# virsh metadata test4 "http://herp.derp/" "herp?" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

# virsh metadata test4 "http://herp.derp/" "herp:" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

# virsh metadata test4 "http://herp.derp/" "herp}" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

# virsh metadata test4 "http://herp.derp/" "herp|" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

# virsh metadata test4 "http://herp.derp/" "herp|" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

Comment 5 errata-xmlrpc 2015-11-19 05:53:03 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.

https://rhn.redhat.com/errata/RHBA-2015-2202.html