Bug 1184929

Summary: libvirtError: argument unsupported: QEMU driver does not support <metadata> element
Product: Red Hat Enterprise Linux 7 Reporter: Jan Kurik <jkurik>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: high    
Version: 7.0CC: alukiano, bmcclain, dfediuck, dyuan, ecohen, gklein, honzhang, iheim, jdenemar, jherrman, jiahu, jkurik, knoel, lmiksik, lsurette, mavital, michal.skrivanek, msivak, pkrempa, pm-eus, rbalakri, rhodain, sherold, snagar, yeylon, zhwang
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.1.1-29.el7_0.6 Doc Type: Enhancement
Doc Text:
The support for custom metadata stored in the [metadata] element of the guest XML configuration file has been implemented for the virDomainSetMetadata and virDomainGetMetadata APIs. This allows users to modify the custom metadata of a running virtual machine by using these APIs.
Story Points: ---
Clone Of: 1181157 Environment:
Last Closed: 2015-02-05 12:48:44 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:
Bug Depends On: 1181157    
Bug Blocks: 1179592    
Attachments:
Description Flags
The script to reproduce the bug none

Description Jan Kurik 2015-01-22 13:56:15 UTC
This bug has been copied from bug #1181157 and has been proposed
to be backported to 7.0 z-stream (EUS).

Comment 8 zhenfeng wang 2015-01-29 09:50:14 UTC
I could reproduce this bug with libvirt libvirt-1.1.1-29.el7_0.4
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     7.0                            shut off

# python testmetadata.py -n 7.0 -o set -t 2 -u "http://herp.derp/" -k test -m "<foo><bar fooish='blurb'>baz</bar></foo>"
libvirt: QEMU Driver error : argument unsupported: QEMU driver does not support <metadata> element
Traceback (most recent call last):
  File "testmetadata.py", line 85, in <module>
    main()
  File "testmetadata.py", line 78, in main
    do_set(dom, mtype, metadata, key, uri, flags)
  File "testmetadata.py", line 9, in do_set
    if dom.setMetadata(mtype, metadata, key, uri, flags):
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 1597, in setMetadata
    if ret == -1: raise libvirtError ('virDomainSetMetadata() failed', dom=self)
libvirt.libvirtError: argument unsupported: QEMU driver does not support <metadata> element

Verify this bug with libvirt-1.1.1-29.el7_0.5

scenario 1 verify the bug with the python script

1.# python testmetadata.py -n 7.0 -o set -t 2 -u "http://herp.derp/" -k test -m "<foo><bar fooish='blurb'>baz</bar></foo>"
Okay

2.# python testmetadata.py -n 7.0 -o get -t 2 -u "http://herp.derp/"
<foo>
  <bar fooish="blurb">baz</bar>
</foo>

# virsh dumpxml 7.0 |grep metadata -a2
--
  <metadata>
    <test:foo xmlns:test="http://herp.derp/">
      <test:bar fooish="blurb">baz</test:bar>
    </test:foo>
  </metadata>

3.# python testmetadata.py -n 7.0 -o remove -t 2 -u "http://herp.derp/"
Okay

#virsh dumpxml 7.0 |grep metadata -a2
--
  <metadata/>

scenario 2 
verify the metadata with the virsh command
1.# virsh metadata 7.0 --uri http://herp.derp/ --key herp --set  "<derp xmlns:foobar='http://foo.bar/'></derp>"
Metadata modified

# virsh metadata 7.0 --uri http://herp.derp/ 
<derp xmlns:foobar="http://foo.bar/"/>

# virsh dumpxml 7.0 |grep metadata -a3
--
  <metadata>
    <herp:derp xmlns:foobar="http://foo.bar/" xmlns:herp="http://herp.derp/"/>
  </metadata>

2.Edit the metadata, it will open a window to edit, we can edit it and save it
# virsh metadata 7.0 --edit --key herp --uri http://herp.derp/
<derp xmlns:foobar="http://foo1.bar/"/>

wq:

# virsh metadata 7.0 --key herp --uri http://herp.derp/<derp xmlns:foobar="http://foo1.bar/"/>

3.Edit and set the metadata at the same time will report the expect error

# virsh metadata 7.0  --edit --key herp --uri http://herp.derp/ --set "<derp xmlns:foobar='http://foo.bar/'></derp>"
error: Options --edit and --set are mutually exclusive

4.remove the metadatavirsh list
# virsh metadata 7.0  --uri http://herp.derp/
<derp xmlns:foobar="http://herp.derp/"/>
# virsh metadata 7.0  --uri http://herp.derp/ --remove
Metadata removed
# virsh metadata 7.0  --uri http://herp.derp/
error: metadata not found: Requested metadata element is not present

5.Prepare a pure shutoff guest which didn't include metadata element
run the virsh metadata --remove , the libvirtd didn't crash 
virsh metadata rhel7 "http://herp.derp" --remove

6.Setting metadata with special character in key value  will report the expect error and won't cause the guest fail to start 
# virsh metadata 7.0 "http://herp.derp/" "herp//" "<foo><bar>baz</bar></foo>"
error: internal error: failed to validate prefix for a new XML namespace

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

# virsh start 7.0
Domain 7.0 started

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

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

Comment 9 zhenfeng wang 2015-02-05 05:17:29 UTC
Created attachment 988386 [details]
The script to reproduce the bug

Comment 11 errata-xmlrpc 2015-02-05 12:48:44 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-0131.html