Bug 893273

Summary: virt-xml-validate pass but pool can not be defined by the xml
Product: Red Hat Enterprise Linux 6 Reporter: EricLee <bili>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.4CC: cwei, dyuan, jtomko, mzhan, rbalakri
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.10.2-31.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-14 04:14:55 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 EricLee 2013-01-09 02:04:37 UTC
Description of problem:
virt-xml-validate pass but pool can not be defined by the xml

Version-Release number of selected component (if applicable):
libvirt-0.10.2-14.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Do not add <path> element in <target> of a pool xml file:
# cat pool.xml
<pool type='dir'>
  <name>test</name>
  <capacity unit='bytes'>82569920512</capacity>
  <allocation unit='bytes'>22617657344</allocation>
  <available unit='bytes'>59952263168</available>
  <source>
  </source>
  <target>
    <permissions>
      <mode>0700</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

2. # virt-xml-validate pool.xml
pool.xml validates

# echo $?
0

3. # virt-xml-validate pool.xml storagepool
pool.xml validates

# echo $?
0

4. # virsh pool-define pool.xml
error: Failed to define pool from pool.xml
error: XML error: missing storage pool target path

# echo $?
1

Actual results:
as steps

Expected results:
virt-xml-validate should be failed.

Additional info:

Comment 1 EricLee 2013-01-10 02:11:46 UTC
And there is another problem of volume.xml:
do not add <source> element to vol.xml
# cat vol.xml
<volume>
  <name>rhel6.img</name>
  <capacity unit='bytes'>8589934592</capacity>
  <allocation unit='bytes'>1043378176</allocation>
  <target>
    <permissions>
      <mode>0600</mode>
      <owner>0</owner>
      <group>0</group>
      <label>system_u:object_r:virt_image_t:s0</label>
    </permissions>
  </target>
</volume>

# virt-xml-validate vol.xml
vol.xml:3: element capacity: Relax-NG validity error : Did not expect element capacity there
vol.xml fails to validate

But can create a volume from that xml:

# virsh vol-create default vol.xml
Vol rhel6.img created from vol.xml

# virsh vol-list default
Name                 Path                                    
-----------------------------------------      
rhel6.img            /var/lib/libvirt/images/rhel6.img      

# virsh vol-dumpxml rhel6.img default
<volume>
  <name>rhel6.img</name>
  <key>/var/lib/libvirt/images/rhel6.img</key>
  <source>
  </source>
  <capacity unit='bytes'>8589934592</capacity>
  <allocation unit='bytes'>1044402176</allocation>
  <target>
    <path>/var/lib/libvirt/images/rhel6.img</path>
    <format type='raw'/>
    <permissions>
      <mode>0600</mode>
      <owner>0</owner>
      <group>0</group>
      <label>unconfined_u:object_r:virt_image_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1357610541</atime>
      <mtime>1357610526</mtime>
      <ctime>1357610526</ctime>
    </timestamps>
  </target>
</volume>

So virt-xml-validate should pass in this case.

Comment 2 Ján Tomko 2013-05-17 06:56:41 UTC
Fixed upstream by:
commit 25b98d31ec5519a914551a6cab15c8d8b4e67034
Author:     Ján Tomko <jtomko>
AuthorDate: 2013-05-16 15:43:06 +0200
Commit:     Ján Tomko <jtomko>
CommitDate: 2013-05-17 08:35:08 +0200

    schema: make source optional in volume XML
    
    We don't parse it anyway.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=893273

commit a07b88ee03f350f0b4d62c3cc1481c16f7e369e3
Author:     Ján Tomko <jtomko>
AuthorDate: 2013-05-16 15:37:14 +0200
Commit:     Ján Tomko <jtomko>
CommitDate: 2013-05-17 08:33:22 +0200

    schema: require target path in storage pool xml
    
    Make target path mandatory for pool types that require target,
    since we refuse to parse a target without a path.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=893273

git describe: v1.0.5-249-g25b98d3

Comment 3 Jiri Denemark 2013-06-11 09:56:04 UTC
We decided not to rebase libvirt in RHEL 6.5 to avoid stability issues
we faced in 6.4. This bug has already been fixed upstream but it is
considered unsuitable for backporting to RHEL 6.5 because at least one
of the following conditions is met:

- this bug requires new API(s), which we cannot introduce without
  rebasing libvirt
- the patches required to address this bug are complex or invasive
  causing the backport to be too risky
- this bug is not important enough to justify backporting non-trivial
  patches for it

Thus I'm pushing this bug to RHEL 6.6 (and setting Upstream keyword to
indicate we have patches upstream) for now. If you don't agree with
this resolution, please, give us reasons which you think are strong
enough for us to reevaluate the decision not to backport patches for
this bug.

Comment 8 EricLee 2014-04-14 09:13:03 UTC
Verified pass in libvirt-0.10.2-32.el6:

pool.xml and vol.xml just as like description and comment #1:

# virt-xml-validate pool.xml
pool.xml:6: element source: Relax-NG validity error : Expecting element target, got source
pool.xml:8: element target: Relax-NG validity error : Expecting element path, got permissions
pool.xml:8: element target: Relax-NG validity error : Element target failed to validate content
pool.xml:5: element available: Relax-NG validity error : Expecting element target, got available
pool.xml:1: element pool: Relax-NG validity error : Element pool failed to validate content
pool.xml fails to validate

# virt-xml-validate pool.xml storagepool
pool.xml:6: element source: Relax-NG validity error : Expecting element target, got source
pool.xml:8: element target: Relax-NG validity error : Expecting element path, got permissions
pool.xml:8: element target: Relax-NG validity error : Element target failed to validate content
pool.xml:5: element available: Relax-NG validity error : Expecting element target, got available
pool.xml:1: element pool: Relax-NG validity error : Element pool failed to validate content
pool.xml fails to validate

# echo $?
3

# virt-xml-validate vol.xml 
vol.xml validates

Works fine, setting verified.

Comment 11 errata-xmlrpc 2014-10-14 04:14:55 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/RHBA-2014-1374.html