分类: 虚拟化
2015-12-09 15:32:47
转载至 :http://blog.csdn.net/halcyonbaby
博客地址:http://blog.csdn.net/halcyonbaby
快照分类
内置快照
利用qemu-img
qemu-img snapshot -c snapshot01 test.qcow2 //创建
qemu-img snapshot -l test.qcow2 //查看
qemu-img snapshot -a snapshot01 test.qcow2 //revert到快照点
qemu-img snapshot -d snapshot01 test.qcow2 //删除
利用Libvirt
snapshot.xml
virsh snapshot-create controller snapshot.xml //创建快照。快照元信息在/var/lib/libvirt/qemu/snapshot/(destroy后丢失)
virsh snapshot-list controller --tree //树形查看快照。
virsh snapshot-current controller //查看当前快照
virsh snapshot-revert controller snapshot02 //恢复快照
virsh snapshot-delete controller snapshot02 //删除快照
功能参数:
--quiesce quiesce guest's file systems
--atomic require atomic operation
外置快照
利用qemu-img
利用libvirt
virsh snapshot-create-as --domain f17-base snap1 snap1-desc \
--disk-only --diskspec vda,snapshot=external,file=/export/vmimages/sn1-of-f17-base.qcow2 \
--atomic
# virsh domblklist f17-base
Target Source
----------------------------------------------------
vda /export/vmimages/sn1-of-f17-base.qcow2
virsh blockcommit --domain f17 vda --base /export/vmimages/sn2.qcow2 --top /export/vmimages/sn3.qcow2 --wait --verbose
#只支持pull到最前端
virsh blockpull --domain RootBase --path /var/lib/libvirt/images/active.qcow2 \
--base /var/lib/libvirt/images/RootBase.qcow2 --wait --verbose
virsh snapshot-delete --domain RootBase Snap-3 --metadata #删除无用的快照
其他方法
利用LVM创建。利用文件系统能力创建。利用存储本身的功能创建。
参考
#libvirt的虚拟机快照实现过程:
optionally - use the guest-agent to tell the guest OS to quiesce I/O
tell qemu to migrate guest memory to file; qemu pauses guest
for each disk:
tell qemu to pause disk image modifications for that disk
libvirt resumes qemu (but I/O is still frozen)
for each disk:
libvirt creates the snapshot
if the snapshot involves updating the backing image used by qemu:
pass qemu the new fd for the disk image
tell qemu to resume disk I/O on that disk
#虚拟机快照恢复实现过程:
for each disk:
revert back to disk snapshot point
tell qemu to do incoming migration from file