Bug 1106419

Summary: No snapshot should be created when create external disk snapshot without specify disk while guest is shut off
Product: Red Hat Enterprise Linux 7 Reporter: Shanzhi Yu <shyu>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Han Han <hhan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: dyuan, eblake, hhan, jdenemar, mzhan, pkrempa, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
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 Shanzhi Yu 2014-06-09 09:52:58 UTC
Description of problem:

No snapshot should be created when create external disk snapshot without specify disk while guest is shut off 

Version-Release number of selected component (if applicable):

libvirt-1.1.1-29.el7.x86_64

How reproducible:

100%

Steps to Reproduce:

1.Define an guest with snapshot='no' in xml 

#virsh dumpxml rhel6|grep disk -A 3
    <disk type='file' device='disk' snapshot='no'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/kvm-rhel6.5-x86_64-qcow2.img'/>
      <target dev='vda' bus='virtio'/>
..

2.Keep guest shut off status and create external disk snapshot

# virsh snapshot-create-as rhel6 s1 --disk-only 
Domain snapshot s1 created

3.Check snapshot info 

# virsh snapshot-dumpxml rhel6 s1 

<domainsnapshot>
  <name>s1</name>
  <state>shutoff</state>
  <creationTime>1402301633</creationTime>
  <memory snapshot='no'/>
  <disks>
    <disk name='vda' snapshot='no'/>
  </disks>
  <domain type='kvm'>
..

4.Create external disk snapshot with specify snapshot file

# virsh snapshot-create-as rhel6 s2 --disk-only --diskspec vda,file=/tmp/s2.disk 
Domain snapshot s2 created

5. check snapshot info

# virsh snapshot-dumpxml rhel6 s2 
<domainsnapshot>
  <name>s2</name>
  <state>shutoff</state>
  <parent>
    <name>s1</name>
  </parent>
  <creationTime>1402303099</creationTime>
  <memory snapshot='no'/>
  <disks>
    <disk name='vda' snapshot='external' type='file'>
      <driver type='qcow2'/>
      <source file='/tmp/s2.disk'/>
    </disk>
  </disks>
  <domain type='kvm'>
..

# virsh domblklist rhel6 
Target     Source
------------------------------------------------
vda        /tmp/s2.disk


Actual results:


Expected results:

No snapshot should be created in step 2

Additional info:

Comment 3 Eric Blake 2015-07-28 15:41:01 UTC
similar to bug 1106416 (which was about internal snapshots); probably a single code change will fix both, in which case I may mark this as a duplicate bug.

Comment 6 Peter Krempa 2016-10-10 03:23:50 UTC
This was already fixed a while ago:

commit 91b7e06865d8f630f2ac9e07435ba92520248af4
Author: Peter Krempa <pkrempa>
Date:   Tue May 20 14:22:25 2014 +0200

    qemu: snapshot: Forbid empty snapshots
    
    If neither disks nor memory are selected for snapshot we'd record
    metadata in case of external snapshot and do a disk snapshot in case of
    external disk snapshot. Forbid this as it doesn't make much sense.

Comment 8 Han Han 2017-03-09 03:29:13 UTC
Hi Peter.
Verify as failed. It doesn't forbid to create external snapshot when snapshot='no'
Version:
qemu-kvm-rhev-2.8.0-6.el7.x86_64
libvirt-3.1.0-2.el7.x86_64

For disk xml with snapshot='no':
<disk type='file' device='disk' snapshot='no'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/BZ1106416.qcow2'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>


It doesn't forbid create external snapshot with --disk-only --diskspec:
# virsh domstate BZ1106416                                                                                             
shut off

# virsh snapshot-create-as BZ1106416 s1 --disk-only --diskspec hda,file=/tmp/xxo
Domain snapshot s1 created

# virsh snapshot-dumpxml BZ1106416 s1|awk '/<disk/,/<\/disk/'
  <disks>
    <disk name='hda' snapshot='external' type='file'>
      <driver type='qcow2'/>
      <source file='/tmp/xxo'/>
    </disk>
      <disk type='file' device='disk' snapshot='no'>
        <driver name='qemu' type='qcow2'/>
        <source file='/var/lib/libvirt/images/BZ1106416.qcow2'/>
        <target dev='hda' bus='ide'/>
        <address type='drive' controller='0' bus='0' target='0' unit='0'/>
      </disk>

Comment 9 Peter Krempa 2017-03-09 07:19:20 UTC
That is expected. --diskspec overrides the default set via the 'snapshot' attribute. The attribute applies only if --diskspec does not cover the given drive.

Comment 10 Han Han 2017-04-14 03:09:46 UTC
As comment8 and comment9. Bug verified on libvirt-3.2.0-2.el7.x86_64
1. Prepare a running VM with snapshot='no' in its disk xml:
<disk type='file' device='disk' snapshot='no'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/q35.qcow2'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

2. Try creating internal or external snapshot
# virsh snapshot-create-as q35                      
[sudo] password for hansolo: 
error: unsupported configuration: internal snapshots and checkpoints require all disks to be selected for snapshot

# virsh snapshot-create-as q35 --disk-only    
error: unsupported configuration: nothing selected for snapshot

As above. Bug fixed.

Comment 11 Han Han 2017-04-14 03:22:03 UTC
Correct a typo in comment10: 'a running VM' should be 'a shutoff VM'.

Comment 12 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 13 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 14 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