Bug 662026

Summary: No way to revert snapshot to base image by using snapshot-revert
Product: Red Hat Enterprise Linux 6 Reporter: Nan Zhang <nzhang>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.1CC: bsarathy, dallan, eblake, llim, xen-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 674537 (view as bug list) Environment:
Last Closed: 2011-02-02 11:33:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nan Zhang 2010-12-10 11:13:20 UTC
Description of problem:
Like the following snapshot chain, I used 'snapshot-create' to created snapshot1 & snapshot1.1. But how to create snapshot2, I can't revert to base image by virsh command? If it returns nothing by 'snapshot-current', then it shows that the current is base, if not, that's the snapshot which you created. Once you continue to create snapshots, it's certainly not based on base image.
So the snapshot2 impossibly be created.

base 
| 
|__snapshot1 
|     |__snapshot1.1 
|
|__snapshot2 


Version-Release number of selected component (if applicable):
libvirt-0.8.1-28.el6
qemu-kvm-0.12.1.2-2.123.el6

How reproducible:
Always

Steps to Reproduce:
# virsh snapshot-current rhel6

# virsh snapshot-create rhel6
Domain snapshot 1291880262 created

# virsh snapshot-list rhel6
 Name                 Creation Time             State
---------------------------------------------------
 1291880262           2010-12-09 02:37:42 -0500 shutoff

# virsh snapshot-current rhel6
<domainsnapshot>
  <name>1291880262</name>
  <state>shutoff</state>
  <creationTime>1291880262</creationTime>
  <domain>
    <uuid>a35ba4e9-5fbb-3fca-9d6d-9e0dab6e3d32</uuid>
  </domain>
</domainsnapshot>

# virsh snapshot-create rhel6
Domain snapshot 1291880301 created

# virsh snapshot-current rhel6
<domainsnapshot>
  <name>1291880301</name>
  <state>shutoff</state>
  <parent>
    <name>1291880262</name>
  </parent>
  <creationTime>1291880301</creationTime>
  <domain>
    <uuid>a35ba4e9-5fbb-3fca-9d6d-9e0dab6e3d32</uuid>
  </domain>
</domainsnapshot>

# virsh snapshot-list rhel6
 Name                 Creation Time             State
---------------------------------------------------
 1291880262           2010-12-09 02:37:42 -0500 shutoff
 1291880301           2010-12-09 02:38:21 -0500 shutoff

  
Actual results:
Cannot be revert to base image after snapshot created.

Expected results:
Can be revert to base image after snapshot created.

Additional info:
It can workround by restart libvirtd service.

Comment 3 Jiri Denemark 2011-02-02 09:51:29 UTC
The only bug that I see here is that restarting libvirtd resets current
snapshot (I will create a new BZ for that with clearer problem description).

The bug report is a result of misunderstanding the concept of domain
snapshots. Quoting from virsh man page:

    Snapshots take the disk, memory, and device state of a domain at a
    point-of-time, and save it for future use. They have many uses, from
    saving a "clean" copy of an OS image to saving a domain’s state before a
    potentially destructive operation.

That is, a snapshot is an immutable copy of domain state at the time when the
snapshot was created. Just like a photography is an image of a small part of
the world at the time the photography was taken.

Before a snapshot is created, domain's state is a moving target and the main
purpose of the snapshot is to have something one can get back to. So the
first snapshot is what you want to revert to if you need to get the original
pristine state.