Openstack snapshot Analysis

Source: Internet
Author: User
1. snapshot OverviewFor openstack, the snapshot of a virtual machine is an image. After the snapshot is completed, it is stored in glance as an image. Although openstack snapshot is based on libvirt (qemu-KVM), there are major differences in implementation between the two:
  • Libvirt mainstream snapshot implementation: uses the virdomainsnapshotcreatexml () function (CLI is virsh snapshot-create ). The new snapshot is associated with the Virtual Machine: if it is a built-in snapshot, the snapshot information and the virtual machine exist in the same qcow2 image; if it is an external snapshot, create a qcow2 file, the disk of the original VM will be changed to a read-only template image. The new qcow2 image is only recorded with 2. differential data of template images. This type of snapshot contains the snapshot chain information, which can retain disk and ram information and roll back to the snapshot point.
  • Openstack snapshot implementation: openstack does not use virdomainsnapshotcreatexml () to create snapshots. Instead, it simply converts and copies Virtual Machine images, generates an image unrelated to the virtual machine, and finally uploads it to glance. This snapshot does not contain snapshot chain information. It only retains disk information and cannot be rolled back to the snapshot point. You can only use this snapshot image to create a new virtual machine.


2. Cold snapshot and live Snapshot
  • Cold snapshot: when creating a snapshot, you must pause the VM.
  • Live snapshot: when creating a snapshot, you do not need to pause the VM.

3. Cold snapshot process:
# Save the state and stop a running guest, then detach PCI devices $ Virsh managedsave VM# Create a qemu internal Snapshot   $ Qemu-IMG snapshot-C snap1 vm_snapshot# Extract the internal snapshot, convert it to qcow2 and export it a file, then upload to glance $ Qemu-IMG convert-F qcow2 VM-O qcow2 vm_snapshot# Start the guest again $ Virsh start VM

 

4. Live snapshot Process

# Abort any failed/finished block operations:

$ Virsh blockjob vm vda -- abort

# Undefine a running domain. (Note: undefining a running domain does not _ kill _ the domain, it just converts it from persistent to transient .)

$ Virsh undefine VM

# Create a destination image with the original backing file and matching size of the Instance root disk.

$ Qemu-IMG create-F qcow2 vm_copy -- backing_file = backing_file -- size = root_disk_size

# Invoke 'virsh blockcopy' (this will take time, depending on the size of disk image VM1 ):

$ Virsh blockcopy -- domain vm vda vm_copy -- wait -- verbose

# Abort any failed/finished block operations:

$ Virsh blockjob vm vda -- abort

# Define the guest again (to make it persistent ):

$ Virsh define VM

# From the obtained new copy, convert the qcow2 with a backing file to a qcow2 image with no backing file, then upload to glance:

$ Qemu-IMG convert-F qcow2-o raw vm_copy vm_convert


5. virsh snapshot-create-as/snapshot-create snapshot Analysis 

The default value is built-in snapshot, which supports snapshot chain, snapshot rollback, and memory information.

During the snapshot process, the VM gets stuck for a short time.

I wonder why openstack does not use this method to implement mainstream snapshots ?!


6. Conclusion

Supported Functions

  • VM snapshot (the snapshot is stored in glance)
  • Volume snapshot (LVM snapshot is stored locally)

Restrictions and disadvantages

  • No snapshot chain information. Revert is not supported to restore the VM to a snapshot point.
  • Snapshots of system disks are used only. Memory snapshots are not supported. snapshots of virtual machines and disks are not supported at the same time.
  • You must perform consistent operations.
  • Metadata-containing data cannot be exported, and metadata-containing data cannot be imported.

  • Only full data snapshots of virtual machines are supported (related to the implementation of snapshots, because they are saved through images). The process is long (you need to store snapshots first, then, the snapshots are extracted and uploaded to glance. snapshots are saved as images instead of cinder volumes. Therefore, you cannot take full advantage of the storage capabilities to accelerate snapshot creation and usage.

References:1. https://www.redhat.com/archives/libvirt-users/2012-April/msg00142.html2. http://blog.csdn.net/halcyonbaby/article/details/199981552. http://itxx.sinaapp.com/blog/content/1303. http://kashyapc.com/2012/09/14/externaland-live-snapshots-with-libvirt/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.