Bug 1247005

Summary: special characters in guest disk file name cannot pass virt-xml-validte
Product: Red Hat Enterprise Linux 7 Reporter: Han Han <hhan>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Lili Zhu <lizhu>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.2CC: dyuan, hhan, jdenemar, mzhan, pkrempa, rbalakri, xuzhang, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-2.5.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:06:41 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 Han Han 2015-07-27 07:05:01 UTC
Description of problem:
some special chars like ,* in guest disk file name cannot pass virt-xml-validte,
but guest can be successfully created and ran.


Version-Release number of selected component (if applicable):
libvirt-1.2.17-2.el7.x86_64
qemu-kvm-rhev-2.3.0-12.el7.x86_64
kernel-3.10.0-297.el7.x86_64 


How reproducible:
100%


Steps to Reproduce:
1. Create gusest with xml like following
...
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/var/lib/libvirt/images/tt,tt.qcow2**'/>
<target dev='vda' bus='virtio'/>
<boot order='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
...
note that the guest disk file name is tt,tt.qcow2** 

2. start the guest
# virsh create guest.xml
Domain guest created from guest.xml 

3. verify the xml
# virt-xml-validate guest.xml
Relax-NG validity error : Extra element devices in interleave
guest.xml:30: element devices: Relax-NG validity error : Element domain failed to validate content
guest.xml fails to validate


Actual results:
As step2-3 shows 


Expected results:
In step3, should output:
guest.xml validates

Additional info:

Comment 2 Peter Krempa 2016-10-07 11:18:17 UTC
Fixed upstream:

commit c4b92f1a8a9cb64a2c4a9f0ed899ed8a7d95d935
Author: Michal Privoznik <mprivozn>
Date:   Fri Aug 12 10:52:30 2016 +0200

    schema: Don't validate paths
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1353296
    
    On UNIX like systems there are no constraints on what characters
    can be in file/dir names (except for NULL, obviously). Moreover,
    some values that we think of as paths (e.g. disk source) are not
    necessarily paths at all. For instance, some hypervisors take
    that as an arbitrary identifier and corresponding file is then
    looked up by hypervisor in its table. Instead of trying to fix
    our regular expressions (and forgetting to include yet another
    character there), lets drop the validation completely.

Comment 4 Lili Zhu 2017-06-18 15:58:22 UTC
Reproduce the bug with build libvirt-2.0.0-10.el7.x86_64
Steps to produce:
1. prepare a xml file as the following:
....
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/rhel7.4\.img**'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
...
Note: the path contains some special chars, such as "*", "/"

2. 
# virsh define rhel7.4v2.xml.dump 
Domain rhel7.4v2 defined from rhel7.4v2.xml.dump

[root@libvirtd images]# virsh start rhel7.4v2
Domain rhel7.4v2 started

3. 
# virt-xml-validate rhel7.4v2.xml.dump 
Relax-NG validity error : Extra element devices in interleave
rhel7.4v2.xml.dump:31: element devices: Relax-NG validity error : Element domain failed to validate content
rhel7.4v2.xml.dump fails to validate


Verify the bug with build libvirt-3.2.0-10.el7.x86_64
Steps to verify:
The first two steps are the same with the steps above in the reproducing part.
3.
# virt-xml-validate rhel7.4v2.xml.dump 
rhel7.4v2.xml.dump validates

As the result match the expectation, mark the bug as verified.

Comment 5 errata-xmlrpc 2017-08-01 17:06:41 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/RHEA-2017:1846

Comment 6 errata-xmlrpc 2017-08-01 23:48: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.

https://access.redhat.com/errata/RHEA-2017:1846

Comment 7 errata-xmlrpc 2017-08-02 01:25:04 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/RHEA-2017:1846