Linux KVM Virtualization Manual Low-Level Guest Export/Import Procedure: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 6: Line 6:
=Overview=
=Overview=


The goal of a ''snapshotting'' operation is to preserve the state of the guest, at a certain moment in time, so it can be reverted to, later, possibly after the guest was removed for a while from the virtualization host. This is the procedure to [[Linux_Virtualization_Concepts#KVM_Virtual_Machine_Snapshot|snapshot a KVM virtual machine]]. It consists in taking snapshots of its XML definition and performing snapshots of all its storage devices.
The goal of a ''snapshotting'' operation is to preserve the state of the guest -its definition and the state of its storage - at a certain moment in time, so it can be reverted to, later, possibly after the guest was removed for a while from the virtualization host. This is the procedure to [[Linux_Virtualization_Concepts#KVM_Virtual_Machine_Snapshot|snapshot a KVM virtual machine]]. It consists in taking snapshots of its XML definition and performing manual snapshots of all its storage devices.
 


{{Error|Investigate virsh snapshot and factor it in.}}
{{Error|Investigate virsh snapshot and factor it in.}}

Revision as of 19:02, 3 November 2017

Internal

Overview

The goal of a snapshotting operation is to preserve the state of the guest -its definition and the state of its storage - at a certain moment in time, so it can be reverted to, later, possibly after the guest was removed for a while from the virtualization host. This is the procedure to snapshot a KVM virtual machine. It consists in taking snapshots of its XML definition and performing manual snapshots of all its storage devices.



Investigate virsh snapshot and factor it in.

Take a Virtual Machine Snapshot


If the virtual machine has more than one storage device attached, they all must be snapshot at the same time to produce a consistent set of storage snapshots that can be reverted to.

Shutdown the Target Guest

virsh shutdown <vm-name>

Identify all Storage Devices

virsh dumpxml <vm-name>

Look for <disk> definitions. The disk definition specifies the source and the format of the virtual storage device. Example:

<disk type='file' device='disk'>
    <driver name='qemu' type='qcow2'/>
    <source file='/main-storage-pool/appproxy.qcow2'/>
    ...
</disk>

Snapshot Each Storage Device

qemu-img snapshot -c <snapshot-tag> <volume-name>

For more details about snapshot mechanics, see

qemu-img snapshot -c

Save the XML Definition

This is only necessary if we plan to modify the hardware configuration.

Restore from Snapshot

Perform the steps described in the "Take a Virtual Machine Snapshot" section in reverse order:

Restore the XML Definition

This is only necessary if the hardware configuration changed between snapshots.

Restore the Content of Storage Device from Snapshot

qemu-img snapshot -a <snapshot-tag> <volume-name>

For more details about restoration mechanics, see

qemu-img snapshot -a

Alternative

Alternative suing qemu-img create. See

http://dustymabe.com/2015/01/11/qemu-img-backing-files-a-poor-mans-snapshotrollback/