Bug 1300177

Summary: Forbid using relative path or file name only as the destination of drive-mirror
Product: Red Hat Enterprise Linux 7 Reporter: Yang Yang <yanyang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Han Han <hhan>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: crobinso, dyuan, hhan, jdenemar, mzhan, pkrempa, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-3.0.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:09:12 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 2016-01-20 07:22:42 UTC
Description of problem:
If using relative path (e.g. ./dest) or file name only (e.g. dest)
as the destination of drive-mirror, libvirt creates file under / dir
After pivoting, we cannot take snapshot and specify snapshot file in other
directories.

Version-Release number of selected component (if applicable):
libvirt-1.3.1-1.fc24_v1.3.1_rc2.x86_64

How reproducible:
100%

Steps to Reproduce:
1. mirror and pivot to ./generic.copy
# virsh blockcopy generic hda ./generic.copy --wait --verbose
Block Copy: [100 %]
Now in mirroring phase
[root@fedora_yy tmp]# virsh blockjob generic hda
Block Copy: [100 %]

[root@fedora_yy tmp]# virsh blockjob generic hda --pivot

[root@fedora_yy tmp]# virsh domblklist generic
Target     Source
------------------------------------------------
hda        ./generic.copy

2. check where is generic.copy
# ll /generic.copy
-rw-------. 1 qemu qemu 1848901632 Jan 19 17:25 /generic.copy

3. take external snapshot and specify snapshot file
# virsh snapshot-create-as generic --disk-only --no-metadata --diskspec hda,file=/tmp/copy.s1
error: internal error: unable to execute QEMU command 'transaction': Could not open '/tmp/./generic.copy': No such file or directory

Actual results:


Expected results:
Forbid using relative path or file name only as the destination of drive-mirror

Additional info:

Comment 1 Cole Robinson 2016-04-20 18:01:38 UTC
I sent a patch upstream, converting a relative path to absolute in the virsh handling

http://www.redhat.com/archives/libvir-list/2016-April/msg01342.html

Comment 2 Peter Krempa 2016-04-21 08:13:01 UTC
(In reply to Cole Robinson from comment #1)
> I sent a patch upstream, converting a relative path to absolute in the virsh
> handling
> 
> http://www.redhat.com/archives/libvir-list/2016-April/msg01342.html

That handling is incorrect. This needs to be fixed in the daemon. I'm picking this up since I'll probably fix it anyways while fixing other aspects of blockcopy.

Comment 3 Peter Krempa 2016-12-19 08:03:15 UTC
Fixed upstream:

commit 9e9305542eee6700358c6f3c449347cc191eb520
Author: Peter Krempa <pkrempa>
Date:   Fri Dec 16 18:30:39 2016 +0100

    qemu: block copy: Forbid block copy to relative paths
    
    Similarly to 29bb066915 forbid paths used with blockjobs to be relative.

Comment 5 Han Han 2017-04-18 10:42:57 UTC
1. Start a transient VM:
# virsh list --all --transient                                                                                                   
 Id    Name                           State
----------------------------------------------------
 3     RHEL                           running

2. Try to blockcopy with relative path:
# virsh blockcopy RHEL sda xx --wait --verbose --pivot                                                                                    
error: invalid argument: absolute path must be used as block copy target

# virsh blockcopy RHEL sda ../xx --wait --verbose --pivot
error: invalid argument: absolute path must be used as block copy target

# virsh blockcopy RHEL sda ./xx --wait --verbose --pivot 
error: invalid argument: absolute path must be used as block copy target

Bug fixed.

Comment 6 errata-xmlrpc 2017-08-01 17:09:12 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-01 23:51:16 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