Bug 1210564

Summary: virt-clone deals abnormal when set --file path under /
Product: Red Hat Enterprise Linux 7 Reporter: tingting zheng <tzheng>
Component: virt-managerAssignee: Giuseppe Scrivano <gscrivan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: gscrivan, juzhou, mzhan, xiaodwan
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: virt-manager-1.2.1-1-el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:25:17 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:
Attachments:
Description Flags
Attach the debug file none

Description tingting zheng 2015-04-10 05:39:18 UTC
Description
virt-clone deals abnormal when set --file path under /

Version:
virt-manager-1.1.0-12.el7.noarch
virt-install-1.1.0-12.el7.noarch

How reproducible:
100%

Steps to Reproduce:
1.Prepare a guest,eg:vm1.

2.Use virt-clone to clone the guest,set output disk under /,eg:/test,then virt-clone will deal it as //test.
2.1 Try --file /test:
# virt-clone -o vm1 -n vm1-test --file /test
Allocating 'test'                                                                          | 1.0 kB  00:00:09

Clone 'vm1-test' created successfully.

2.2Try --file /root:
# virt-clone -o vm1 -n vm1-test --file /root
ERROR    This will overwrite the existing path '//root' (Use --force to override)


3.After clone,check the xml file of the new cloned guest,it shows as //test.
# virsh dumpxml vm1-test
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='//test'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

4.Check the pool,there are 2 additional pools with path / and // created.
# virsh pool-dumpxml dirpool
<pool type='dir'>
  <name>dirpool</name>
  <uuid>cff91592-bb7d-4d76-ab78-46b0f0ec1aa8</uuid>
 <capacity unit='bytes'>189456433152</capacity>
  <allocation unit='bytes'>70228844544</allocation>
  <available unit='bytes'>119227588608</available>
  <source>
  </source>
  <target>
    <path>/</path>
    <permissions>
      <mode>0755</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

# virsh pool-dumpxml dirpool-1
<pool type='dir'>
  <name>dirpool-1</name>
  <uuid>9ce6e1ea-6490-45ef-b6bb-582e13651f86</uuid>
  <capacity unit='bytes'>189456433152</capacity>
  <allocation unit='bytes'>61638909952</allocation>
  <available unit='bytes'>127817523200</available>
  <source>
  </source>
  <target>
    <path>//</path>

 <permissions>
      <mode>0755</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

Actual results:
As description.

Expected results:
2.1 A image named test under / will be created for the newly cloned guest.
2.2 Some error like below will be showed:
Error with storage parameters: The path '/root' must be a file or a device, not a directory

Additional info:
I can not reproduce this issue on rhel6:
2.1 Try --file /test:
it will if I use --file /test,then a image named test under / will be created.
2.2 Try --file /root:
# virt-clone -o test -n test-test -f /root
ERROR    Error with storage parameters: The path '/root' must be a file or a device, not a directory

Comment 2 tingting zheng 2015-04-10 10:08:41 UTC
Created attachment 1013071 [details]
Attach the debug file

Comment 3 Giuseppe Scrivano 2015-04-10 10:20:55 UTC
it seems to be fixed upstream by:

commit cf0206a58cf042e257923316e018d6c20739095d
Author: Cole Robinson <crobinso>
Date:   Fri Dec 5 21:09:26 2014 -0500

    devicedisk: Break apart set_create_storage
    
    And break about the vol_install vs local clone storage creators. And
    just generally delete a lot of code. The commit aint pretty but it works
    and deletes a ton of hacks

Comment 5 fwu 2015-06-05 04:41:24 UTC
I can reproduce this bug on the following version:
virt-manager-1.1.0-12.el7.noarch
virt-install-1.1.0-12.el7.noarch

Steps are the same as the backport in Comment 1 shows.

Then verify with the latest package:
virt-manager-1.2.0-4.el7.noarch
virt-install-1.2.0-4.el7.noarch

Steps:
1.Prepare a guest, eg:rhel6.7.

2.Use virt-clone to clone the guest, set output disk under /, eg:/test, or /root.
2.1 Try --file /test:
# virt-clone -o rhel6.7 -n rhel6.7-test --file /test

2.2 Try --file /root:
# virt-clone -o rhel6.7 -n rhel6.7-test2 --file /root

3.After clone,check the xml file of the new cloned guest.
# virsh dumpxml rhel6.7-test

4.Check the pool,there are 2 additional pools with path / and // created.
# virsh pool-dumpxml dirpool
# virsh pool-dumpxml dirpool-1

Results:
1. After Step 2.1, the cloned VM was created successfully.
Allocating 'test'                                                       | 6.0 GB  00:00:07     

Clone 'rhel6.7-clone2' created successfully.

2. After Step 2.2, there is an error message:
ERROR    Could not use path '/root' for cloning: The path '//root' must be a file or a device, not a directory

3. After Step 3, the storage shows this:
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='//test'/>
      <target dev='hda' bus='ide'/>
      <boot order='1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

4. After Step 4, there are two pools created, path '/' and '//', respectively.
<pool type='dir'>
  <name>dirpool</name>
  <uuid>b53d0b60-34fa-4600-9050-7b4b1eedeb8a</uuid>
  <capacity unit='bytes'>199901442048</capacity>
  <allocation unit='bytes'>36832423936</allocation>
  <available unit='bytes'>163069018112</available>
  <source>
  </source>
  <target>
    <path>/</path>
    <permissions>
      <mode>0755</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

  <name>dirpool-1</name>
  <uuid>5fad1a63-28f3-4004-8a42-ff3456b6bf55</uuid>
  <capacity unit='bytes'>199901442048</capacity>
  <allocation unit='bytes'>32537817088</allocation>
  <available unit='bytes'>167363624960</available>
  <source>
  </source>
  <target>
    <path>//</path>
    <permissions>
      <mode>0755</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

According to the result shown above, the error message for path '/root' has fixed correctly. However, there are duplicate storage pool created and a wrong storage path was indicated when set --file path under /. Therefore, move this bug from ON_QA to ASSIGNED.

Comment 8 fwu 2015-06-24 07:26:46 UTC
Verify this bug with the latest package:
virt-manager-1.2.1-2.el7.noarch
virt-install-1.2.1-2.el7.noarch

Steps:
1.Prepare a guest, eg:rhel6.7.

2.Use virt-clone to clone the guest, set output disk under /, eg:/test, or /root.
2.1 Try --file /test:
# virt-clone -o rhel6.7 -n rhel6.7-test --file /test

2.2 Try --file /root:
# virt-clone -o rhel6.7 -n rhel6.7-test2 --file /root

3.After clone,check the xml file of the new cloned guest.
# virsh dumpxml rhel6.7-test

4.Check the pool by executing:
# virsh pool-dumpxml dirpool

Results:
1. After Step 2.1, the cloned VM was created successfully.
Allocating 'test'                                                       | 6.0 GB  00:00:07     

Clone 'rhel6.7-clone' created successfully.

2. After Step 2.2, there is an error message:
ERROR    Could not use path '/root' for cloning: The path '//root' must be a file or a device, not a directory

3. After Step 3, the storage shows this:

   <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/test'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>


4. After Step 4, there are a pool created. The pool path is '/'.

<pool type='dir'>
  <name>dirpool</name>
  <uuid>5e5bd99e-4fbb-489f-bd6b-8d96170818a7</uuid>
  <capacity unit='bytes'>199901442048</capacity>
  <allocation unit='bytes'>48903094272</allocation>
  <available unit='bytes'>150998347776</available>
  <source>
  </source>
  <target>
    <path>/</path>
    <permissions>
      <mode>0755</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

According to the result shown above, move this bug from ON_QA to VERIFIED.

Comment 10 errata-xmlrpc 2015-11-19 05:25:17 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://rhn.redhat.com/errata/RHBA-2015-2206.html