Bug 1032363

Summary: document need to pass image name for block backed disks with --disk-only
Product: Red Hat Enterprise Linux 7 Reporter: chhu
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: ajia, dyuan, mzhan, pkrempa, rbalakri, shyu, xuzhang, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.7-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 07:25:51 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 chhu 2013-11-20 03:39:18 UTC
Description of problem:
snapshot-create-as --disk-only is not support with iscsi lun using pool/volume sources

Version-Release number of selected component:
qemu-kvm-rhev-1.5.3-19.el7.x86_64
libvirt-1.1.1-12.el7.x86_64

How reproducible:
100%

Steps:
1. setup the iscsi pool
<pool type='iscsi'>
  <name>iscsipool</name>
  <source>
    <host name='10.66.7.108'/>
    <device path='iqn.2013-07.com.example:iscsi-pool'/>
    <auth type='chap' username='myname'>
      <secret type='iscsi' usage='libvirtiscsi'/>
    </auth>
  </source>
  <target>
    <path>/dev/disk/by-path</path>
    <permissions>
      <mode>0700</mode>
      <owner>0</owner>
      <group>0</group>
    </permissions>
  </target>
</pool>

# virsh pool-create iscsi-pool.xml
Pool iscsipool created from iscsi-pool.xml

# virsh vol-list iscsipool
Name                 Path                                  
-----------------------------------------
unit:0:0:1           /dev/disk/by-path/ip-10.66.7.108:3260-iscsi-iqn.2013-07.com.example:iscsi-pool-lun-1        

2. start a gust with the iscsi lun
<disk type='volume' device='disk'>
      <driver name='qemu'/>
      <source pool='iscsipool' volume='unit:0:0:1' mode='host'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>

# virsh start r7-qcow2
Domain r7-qcow2 started

# ps -ef|grep qemu-kvm|grep iscsi
qemu     18543     1  1 09:56 ?        00:00:05 /usr/libexec/qemu-kvm -name r7-qcow2
......
-drive file=/dev/disk/by-path/ip-10.66.7.108:3260-iscsi-iqn.2013-07.com.example:iscsi-pool-lun-1,if=none,id=drive-virtio-disk0
......

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 11    r7-qcow2                       running

3. try to create external snapshot failed.
# virsh snapshot-create-as r7-qcow2 snap2 --disk-only
error: unsupported configuration: cannot generate external snapshot name for disk 'vda' without source

# virsh snapshot-create-as r7-qcow2 snap3 --memspec file=snap3,snapshot=external
error: unsupported configuration: cannot generate external snapshot name for disk 'vda' without source

4. create internal snapshot success
# virsh snapshot-create-as r7-qcow2 snap1
Domain snapshot snap1 created

# virsh snapshot-list r7-qcow2
 Name                 Creation Time             State
------------------------------------------------------------
 snap1                2013-11-19 10:59:10 +0800 running

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 12    r7-qcow2                       running


5. login to the guest, create a file:/root/snapshot-add
try to revert to the snapshot:snap1

# virsh snapshot-revert r7-qcow2 snap1
error: Requested operation is not valid: this domain does not have a device to load snapshots

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 12    r7-qcow2                       paused


Actual results:
In step3,5, got error: unsupported configuration

Expected results:
In step3,5, snapshot-create-as --disk-only success; snapshot-revert success.

Comment 1 Dave Allan 2013-11-20 03:53:48 UTC
Snapshots are not currently expected to work with iSCSI pools.

Comment 2 Eric Blake 2013-11-20 03:58:58 UTC
(In reply to chhu from comment #0)
> Description of problem:
> snapshot-create-as --disk-only is not support with iscsi lun using
> pool/volume sources

> 3. try to create external snapshot failed.
> # virsh snapshot-create-as r7-qcow2 snap2 --disk-only
> error: unsupported configuration: cannot generate external snapshot name for
> disk 'vda' without source

User error.  If the source is a block device (as is the case for iscsi), then you have to supply the file name for the snapshot destination, as in:

virsh snapshot-create-as r7-qcow2 snap2 --disk-only --diskspec vda,file=/path/to/file

Once you do that, you should be able to create a local qcow2 file as the snapshot of an iscsi volume.

> 
> # virsh snapshot-create-as r7-qcow2 snap3 --memspec
> file=snap3,snapshot=external
> error: unsupported configuration: cannot generate external snapshot name for
> disk 'vda' without source

Using --memspec instead of --disk-only doesn't change the fact that for block devices, you have to provide the destination file name.

> 
> 4. create internal snapshot success
> # virsh snapshot-create-as r7-qcow2 snap1
> Domain snapshot snap1 created
> 

RHEL does not promise support for internal snapshots.  So while it is annoying that this doesn't work, it's an issue for upstream but not for RHEL.

So far, I'm not seeing anything that needs to be changed for RHEL in this report.

Comment 3 chhu 2013-11-20 09:18:46 UTC
Thanks Eric! 

Test pass with --diskspec. 

How about adding this to snapshot-create-as man page ? 
"If the source is a block device, then you have to supply the file name for the snapshot destination with --diskspec"

Or change the error message ?
"error: unsupported configuration: cannot generate external snapshot name for
disk 'vda' without source"


Tested with packages:
qemu-kvm-rhev-1.5.3-19.el7.x86_64
libvirt-1.1.1-12.el7.x86_64

1. Create external snapshot successed.

# virsh dumpxml r7-qcow2| grep disk -A 6
    <disk type='volume' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <auth username='redhat'>
 usage='libvirtiscsi'/>
      </auth>
      <source pool='iscsipool' volume='unit:0:0:1' mode='host'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <contro

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 42    r7-qcow2                       running

# virsh snapshot-create-as r7-qcow2 snap2 --disk-only --diskspec vda,file=/tmp/r7-qcow2-snap2
Domain snapshot snap2 created

# virsh snapshot-list r7-qcow2
 Name                 Creation Time             State
------------------------------------------------------------
 snap2                2013-11-20 16:02:36 +0800 disk-snapshot

# virsh snapshot-create-as r7-qcow2 snap3 --memspec file=snap3,snapshot=external --diskspec vda,file=/tmp/r7-qcow2-snap3
Domain snapshot snap3 created

# virsh snapshot-list r7-qcow2
 Name                 Creation Time             State
------------------------------------------------------------
 snap2                2013-11-20 16:02:36 +0800 disk-snapshot
 snap3                2013-11-20 16:05:59 +0800 running

Comment 4 Peter Krempa 2014-06-09 11:17:06 UTC
Yeah, we will consider mentioning that limitation in the man page.

Comment 6 Peter Krempa 2014-07-14 07:32:01 UTC
Fixed upstream:

commit 500f80a595216d38bbd7e462f99e2a7febc988de
Author: Peter Krempa <pkrempa>
Date:   Fri Jul 11 10:20:33 2014 +0200

    doc: Document that snapshot name of block-backed disk isn't autogenerated
    
    Libvirt generates external snapshot target file names for file backed
    storage but not for block backed storage. Document the limitation.

v1.2.6-129-g500f80a

Comment 8 Yang Yang 2014-10-30 11:12:53 UTC
Verified on libvirt-1.2.8-5.el7.x86_64

 If <code>source</code> is not
            given and the disk is backed by a local image file (not
            a block device or remote storage), a file name is
            generated that consists of the existing file name
            with anything after the trailing dot replaced by the
            snapshot name.

Move it to verified.

Comment 10 errata-xmlrpc 2015-03-05 07:25:51 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/RHSA-2015-0323.html