Bug 1212715

Summary: qemu-img gets wrong actual path of backing file when the file name contains colon
Product: Red Hat Enterprise Linux 7 Reporter: Yang Yang <yanyang>
Component: qemu-kvm-rhevAssignee: Hanna Czenczek <hreitz>
Status: CLOSED ERRATA QA Contact: Ping Li <pingl>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: aliang, cliao, coli, dyuan, hachen, hhuang, juzhang, michen, mrezanin, mzhan, ngu, pingl, virt-maint, xfu, xuwei, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-rhev-2.10.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-11 00:09:32 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 Yang Yang 2015-04-17 08:10:01 UTC
Description of problem:
qemu-img gets wrong actual path of backing file when the file name contains colon

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.2.0-8.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.create an iscsi pool
# virsh pool-dumpxml iscsi
<pool type='iscsi'>
  <name>iscsi</name>
  <uuid>77fbec86-a460-449e-835d-9704a0e26c9c</uuid>
  <capacity unit='bytes'>11811160064</capacity>
  <allocation unit='bytes'>11811160064</allocation>
  <available unit='bytes'>0</available>
  <source>
    <host name='10.66.5.63' port='3260'/>
    <device path='iqn.2001-01.com.virttest:iscsi-pool.target'/>
  </source>
  <target>
    <path>/dev/disk/by-path</path>
    <permissions>
      <mode>0755</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

# virsh vol-list iscsi
 Name                 Path                                    
------------------------------------------------------------------------------
 unit:0:0:1           /dev/disk/by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-1
 unit:0:0:2           /dev/disk/by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-2
 unit:0:0:3           /dev/disk/by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-3
 unit:0:0:4           /dev/disk/by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-4

2. # ll /dev/disk/by-path/
total 0
lrwxrwxrwx. 1 root root 9 Apr 17 13:32 ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-1 -> ../../sdd
lrwxrwxrwx. 1 root root 9 Apr 17 13:32 ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-2 -> ../../sde
lrwxrwxrwx. 1 root root 9 Apr 17 13:32 ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-3 -> ../../sdf
lrwxrwxrwx. 1 root root 9 Apr 17 13:53 ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-4 -> ../../sdg

3.rewrite unit:0:0:4 backed by unit:0:0:3 with RELATIVE path
# cd /dev/disk/by-path
# qemu-img rebase -f qcow2 -u -b ../by-path/ip-10.66.5.63\:3260-iscsi-iqn.2001-01.com.virttest\:iscsi-pool.target-lun-3 -F qcow2 ip-10.66.5.63\:3260-iscsi-iqn.2001-01.com.virttest\:iscsi-pool.target-lun-4

4. check backing file
# qemu-img info /dev/disk/by-path/ip-10.66.5.63\:3260-iscsi-iqn.2001-01.com.virttest\:iscsi-pool.target-lun-4
image: /dev/disk/by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-4
file format: qcow2
virtual size: 2.0G (2147483648 bytes)
disk size: 0
cluster_size: 65536
backing file: ../by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-3 (actual path: /dev/disk/by-path/ip-10.66.5.63:../by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-3)
backing file format: qcow2
Format specific information:
    compat: 1.1
    lazy refcounts: false
    corrupt: false

5.check if the actual path of backing file exists
# ll /dev/disk/by-path/ip-10.66.5.63:../by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-3
ls: cannot access /dev/disk/by-path/ip-10.66.5.63:../by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-3: No such file or directory


Actual results:
Qemu-img gets wrong actual path

Expected results:
actual path should be /dev/disk/by-path/../by-path/ip-10.66.5.63:3260-iscsi-iqn.2001-01.com.virttest:iscsi-pool.target-lun-3


Additional info:

Comment 5 Ping Li 2017-10-11 07:00:04 UTC
Version-Release number of selected component:
kernel-3.10.0-732.el7.x86_64
qemu-kvm-rhev-2.10.0-1.el7

Test steps:
1. Create two images with qcow2 format
# qemu-img create -f qcow2 ./kvm-qe:test1.qcow2 2G
Formatting './kvm-qe:test1.qcow2', fmt=qcow2 size=2147483648 cluster_size=65536 lazy_refcounts=off refcount_bits=16
# qemu-img create -f qcow2 ./kvm-qe:test2.qcow2 2G
Formatting './kvm-qe:test2.qcow2', fmt=qcow2 size=2147483648 cluster_size=65536 lazy_refcounts=off refcount_bits=16

2. Rebase one image to the other one using unsafe mode
# qemu-img rebase -u -f qcow2 -b ../test/kvm-qe\:test1.qcow2 -F qcow2 ./kvm-qe\:test2.qcow2

3. Check the info of snapshot, acutal path of backing file must be correct.
# qemu-img info /home/tests/test/kvm-qe\:test2.qcow2
image: /home/tests/test/kvm-qe:test2.qcow2
file format: qcow2
virtual size: 2.0G (2147483648 bytes)
disk size: 196K
cluster_size: 65536
backing file: ../test/kvm-qe:test1.qcow2 (actual path: /home/tests/test/../test/kvm-qe:test1.qcow2)
backing file format: qcow2
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

According to the test result above, set the bug status as verified.

Comment 9 errata-xmlrpc 2018-04-11 00:09:32 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-2018:1104