Bug 1106416

Summary: No internal snapshot should be created when guest xml with snapshot='no'
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:
Attachments:
Description Flags
Verification script none

Description Shanzhi Yu 2014-06-09 09:48:49 UTC
Description of problem:

No internal snapshot should be created when guest xml with snapshot='no'

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 do internal disk snapshot

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

# virsh snapshot-dumpxml rhel6 s1 
<domainsnapshot>
  <name>s1</name>
  <state>shutoff</state>
  <creationTime>1402301229</creationTime>
  <memory snapshot='no'/>
  <disks>
    <disk name='vda' snapshot='no'/>
  </disks>
  <domain type='kvm'>
    <name>rhel6</name>
..
</domainsnapshot>

# qemu-img info /var/lib/libvirt/images/kvm-rhel6.5-x86_64-qcow2.img
image: /var/lib/libvirt/images/kvm-rhel6.5-x86_64-qcow2.img
file format: qcow2
virtual size: 3.9G (4194304000 bytes)
disk size: 2.7G
cluster_size: 65536
Snapshot list:
ID        TAG                 VM SIZE                DATE       VM CLOCK
1         s1                        0 2014-06-09 16:07:09   00:00:00.000
Format specific information:
    compat: 0.10



Actual results:


Expected results:

No snapshot should be created in step 2

Additional info:

Comment 3 Eric Blake 2015-07-28 15:39:40 UTC
Peter may have already fixed this; if not, it should be an easy analysis and fix.

Comment 4 Peter Krempa 2015-09-11 19:12:44 UTC
Internal snapshots are still created with with the old monitor API that does not support skipping certain disks for internal snapshot. We will need to implement the support for blockdev-snapshot-internal-sync to achieve this functionality.

Comment 7 Peter Krempa 2016-10-10 03:27:05 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.

additionally, commit:

commit 03b4da131a95e4cc83cfdfcf21a701ba3ca04a5e
Author: Peter Krempa <pkrempa>
Date:   Tue May 20 14:04:23 2014 +0200

    qemu: snapshot: Forbid partial internal snapshots
    
    qemu's savevm command does a snapshot of all non readonly disks of a VM.
    Libvirt though allowed disabling snapshot for certain disk of a VM.

disallows partial internal snapshots since it's not currently possible.

Comment 9 Han Han 2017-03-09 05:46:51 UTC
Verified on libvirt-3.1.0-2.el7.x86_64:
1. Prepare an inactive guest with snapshot='no':
+ virsh dumpxml BZ1106416
+ awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk' snapshot='no'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/BZ1106416.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>

2. Try to create internal snapshot when VM is inactive:
+ virsh snapshot-create-as BZ1106416 s1
error: unsupported configuration: nothing selected for snapshot

+ virsh dumpxml BZ1106416
+ awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk' snapshot='no'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/BZ1106416.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>

3. Try to create internal snapshot when VM is active:
+ virsh start BZ1106416
Domain BZ1106416 started

+ virsh snapshot-create-as BZ1106416 s1
error: unsupported configuration: internal snapshots and checkpoints require all disks to be selected for snapshot

+ virsh dumpxml BZ1106416
+ awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk' snapshot='no'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/BZ1106416.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>

The result is expected.

4. Set disk as readonly mode, rerun as step1~3. Get the same result when creating internal snapshot.
Bug verified.

Comment 10 Han Han 2017-03-09 07:05:26 UTC
Created attachment 1261448 [details]
Verification script

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