Bug 1594266

Summary: virt-xml-validate validate fails for volume having backing file
Product: Red Hat Enterprise Linux 7 Reporter: yafu <yafu>
Component: libvirtAssignee: Erik Skultety <eskultet>
Status: CLOSED ERRATA QA Contact: Han Han <hhan>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.6CC: dyuan, eskultet, jdenemar, lmen, pkrempa, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-4.5.0-12.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-06 13:13:52 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 yafu 2018-06-22 13:23:02 UTC
Description of problem:
virt-xml-validate validate fails for volume having backing file

Version-Release number of selected component (if applicable):
libvirt-4.4.0-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.#qemu-img create -f qcow2 -o backing_file=/var/lib/libvirt/images/test1.img -F qcow2 /var/lib/libvirt/images/s1.img
Formatting '/var/lib/libvirt/images/s1.img', fmt=qcow2 size=9663676416 backing_file=/var/lib/libvirt/images/test1.img backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16

2.#virsh pool-refresh default

3.#virsh vol-dumpxml s1.img default> vol-s1.xml

4.#cat vol-s1.xml
<volume type='file'>
  <name>s1.img</name>
  <key>/var/lib/libvirt/images/s1.img</key>
  <source>
  </source>
  <capacity unit='bytes'>9663676416</capacity>
  <allocation unit='bytes'>200704</allocation>
  <physical unit='bytes'>196752</physical>
  <target>
    <path>/var/lib/libvirt/images/s1.img</path>
    <format type='qcow2'/>
    <permissions>
      <mode>0644</mode>
      <owner>0</owner>
      <group>0</group>
      <label>unconfined_u:object_r:virt_image_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1529670693.131883698</atime>
      <mtime>1529670693.128883709</mtime>
      <ctime>1529670693.128883709</ctime>
    </timestamps>
    <compat>1.1</compat>
    <features/>
  </target>
  <backingStore>
    <path>/var/lib/libvirt/images/test1.img</path>
    <format type='qcow2'/>
    <permissions>
      <mode>0777</mode>
      <owner>0</owner>
      <group>0</group>
      <label>system_u:object_r:virt_image_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1529662109.606056087</atime>
      <mtime>1513831365.421893800</mtime>
      <ctime>1528767814.814001686</ctime>
    </timestamps>
  </backingStore>
</volume>

5.# virt-xml-validate vol-s1.xml
Relax-NG validity error : Extra element backingStore in interleave
vol-s1.xml:1: element volume: Relax-NG validity error : Element volume failed to validate content
vol-s1.xml fails to validate

Actual results:
virt-xml-validate validate fails for volume having backing file

Expected results:
virt-xml-validate works well for volume having backing file

Additional info:

Comment 2 Erik Skultety 2018-09-11 08:45:52 UTC
Fixed upstream by:
commit 0376939dd03f490ff54398d569ec17b0a1150b49
Refs: v4.7.0-81-g0376939dd0
Author:     Julio Faracco <jcfaracco>
AuthorDate: Mon Sep 10 23:57:13 2018 -0300
Commit:     Erik Skultety <eskultet>
CommitDate: Tue Sep 11 10:44:26 2018 +0200

    docs: schemas: Fix missing timestamp inside backingStore

    All backingStore XML definitions have a XML tag with the timestamp. This
    timestamp is not defined insinde RNG volume storage schema and it is
    causing some problems to validate and check volume XMLs.

    https://bugzilla.redhat.com/show_bug.cgi?id=1594266

    Signed-off-by: Julio Faracco <jcfaracco>
    Reviewed-by: Erik Skultety <eskultet>

Comment 6 Han Han 2019-04-23 03:58:20 UTC
Verified on libvirt-4.5.0-12.el7.x86_64:

1. Prepare this xml
# cat /tmp/schema.xml
<volume type='file'>
  <name>s1.img</name>
  <key>/var/lib/libvirt/images/s1.img</key>
  <source>
  </source>
  <capacity unit='bytes'>9663676416</capacity>
  <allocation unit='bytes'>200704</allocation>
  <physical unit='bytes'>196752</physical>
  <target>
    <path>/var/lib/libvirt/images/s1.img</path>
    <format type='qcow2'/>
    <permissions>
      <mode>0644</mode>
      <owner>0</owner>
      <group>0</group>
      <label>unconfined_u:object_r:virt_image_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1529670693.131883698</atime>
      <mtime>1529670693.128883709</mtime>
      <ctime>1529670693.128883709</ctime>
    </timestamps>
    <compat>1.1</compat>
    <features/>
  </target>
  <backingStore>
    <path>/var/lib/libvirt/images/test1.img</path>
    <format type='qcow2'/>
    <permissions>
      <mode>0777</mode>
      <owner>0</owner>
      <group>0</group>
      <label>system_u:object_r:virt_image_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1529662109.606056087</atime>
      <mtime>1513831365.421893800</mtime>
      <ctime>1528767814.814001686</ctime>
    </timestamps>
  </backingStore>
</volume>

2. Validate the xml:
# virt-xml-validate /tmp/schema.xml
/tmp/schema.xml validates

Comment 8 errata-xmlrpc 2019-08-06 13:13:52 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://access.redhat.com/errata/RHSA-2019:2294