Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

VM Snapshot - A Hyper-V snapshot is an encapsulation of a running VM’s state, data, and hardware configuration

 

Feature Specifications

VM Snapshot creation

  • VM snapshots form a tree structure, each VM snapshot can have one(or zero) parent snapshot.
  • A current snapshot refers to the most recent snapshot compared to the current state of the VM (although a domain might have snapshots without a current snapshot, if snapshots have been deleted in the meantime)
  • Two types of snapshots: disk, which takes snapshot of all disks of specified VM; disk and memory, which takes CPU/memory snapshot in addition to disks snapshot.
  • Support disk snapshot when specified VM is in running and stopped state
  • Support disk and memory snapshot when specified VM is in running state

VM Snapshot limitations

  • Detaching/attaching VM volume is not allowed if there are VM snapshots, because any changes to the disk layout will break the semantics of VM-based snapshot
  • VM's memory snapshots will be automatically discarded if VM's service offering is upgraded.
  • Volume snapshot operations and volume snapshot operations can not be performed concurrently.
  • For one VM, only one VM snapshot operation is allowed at a time. (no concurrent operations)
  • Customers should only use CS to take snapshot. CS maintains the tree in database, out-of-band snapshots will not be tracked or sync to CS
  • Limit per account not supported
  • Recurring snapshot not supported

VM Snapshot deletion

  • Deleting a snapshot should not have any impact to its subsequent snapshots
  • Snapshots will be destroyed when VM is destroyed

VM Snapshot revert

  • Revert VM from running/stopped to a disk+memory snapshot, result in running state
  • Revert VM from running/stopped to a disk snapshot, result in stopped state

VM Snapshot List

  • Can list with commonly used parameters, like vmId, account, domainId, state..etc
  • Support query by keyword (unimplemented)

Performance consideration

  • Both create and revert should be completed in the scale of seconds
  • As the number snapshots for one VM grows, performance may downgrade. Users should have the awareness to control the the length of VM snapshot chain.


Use cases

  • Create snapshot for a specified VM
  • Revert VM to a specified snapshot
  • Delete a specified snapshot
  • List snapshots for a specified VM

...

      

  • VM snapshot detail

      

HighLevel WorkFlow

VMSnapshot state machine

Image Added

createVMSnapshot:

Common workflow

  1. check authority, concurrency, existence...
  2. allocate VM snapshot entry in DB
  3. transit vm and vmsnapshot state to snapshotting/creating
  4. prepare TO object and CreateVMSnapshotCommand
  5. send command to agent
  6. update DB, like current/parent fields or volume table, depending on CreateVMSnapshotAnswer and TO object
  7. transit vm and vmsnapshot state

revertToVMSnapshot:

Common workflow

  1. check authority, concurrency, existence.
  2. call advanceStart or advanceStop first if revert will change vm's state; for example, when reverting a stopped VM to a DiskAndMemory snapshot, we will start this VM first and then revert it.
  3. transit vm/ vmsnapshot state to reverting
  4. prepare TO objects and send command
  5. update DB with information from Answer object
  6. transite vm/vmsnapshot state

deleteVMSnapshot:

Unlike VM expunging, VM snapshot deletion is designed as a sync operation, there is no daemon thread scanning and expunging them.

the implemention is fairly straightforward:

  1. transit vmsnapshot to expunging state
  2. prepare TO object and send command,
  3. update snapshots tree 
  4. mark as removed

VMSnapshotSync:

  1. Add vm snapshot sync to fullSync and fullHostSync.
  2. It will check if there are any vm snapshot in transient states.
  3. Transient state found during host connection usually means mgmt server restart/outrage, or hypervisor cluster down. Because mgmt server has no idea if those tasks succeed or not, it will re-send the command in question

Enable/disable on a per hypervisor :

Add enable/disable by hypervisor_capabilities,

Add a new column ` vm_snapshot_enabled` in table `hypervisor_capabilities`, and change related VO/Dao

Set vm_snapshot_enabled = 1

Check hypervisor_capabilities when createVMSnapshot

Testing

Suggest following (but not limited) basic test scenarios

Create one VM snapshot with snapshotMemory (on, off) when VM is (running, stopped)

Revert to previous snapshot when VM is (running, stopped)

Create multiple VM snapshot with snapshotMemory (on, off, mixed) when VM is (running, stopped), the snapshots should form a tree hierarchy, such as:

    A

  /    \

B     C

Revert to any snapshots in the tree when VM is (running, stopped)

Delete (current, any, all) VM snapshots

Attach/detach a volume to a VM when this VM has VM snapshots.

Upgrade VM serviceOffering when VM has snapshots with snapshotMemory (on, off)

take Volume Snapshot when associated VM has VM snapshots

 

 

Important

Do not delete .avhd files directly from the storage location.

...