| Design document | |
|---|---|
| Revision | v1 | 
| Status | confirmed | 
| Review | create new issue | 
Currently there is a XenAPI VM.revert which reverts a “VM” to the state it
was in when a VM-level snapshot was taken. There is no VDI.revert so
VM.revert uses VDI.clone to change the state of the disks.
The use of VDI.clone has the side-effect of changing VDI refs and uuids.
This causes the following problems:
VDI.snapshot_of et al) has to be carefully
fixed up since all the old refs are now danglingWe will fix these problems by:
VDI.revert to the SMAPIv2 and calling this from VM.revertvdi_revert and a corresponding capability
VDI_REVERTVDI.revert will first try the vdi_revert,
and fall back to VDI.clone if that failsvdi_revert for common storage types, including File and LVM-based
SRs.We will add the function VDI.revert with arguments:
snapshot: Ref(VDI): the snapshot to which we want to revertdriver_params: Map(String,String): optional extra parametersRef(VDI) the new VDIThe function will look up the VDI which this is a snapshot_of, and change
the VDI to have the same contents as the snapshot. The snapshot will not be
modified. If the implementation is able to revert in-place, then the reference
returned will be the VDI this is a snapshot_of; otherwise it is a reference
to a fresh VDI (created by the VDI.clone fallback path)
References:
We will define the function vdi_revert with arguments:
sr_uuid: the UUID of the SR containing both the VDI and the snapshotvdi_uuid: the UUID of the snapshot whose contents should be duplicatedtarget_uuid: the UUID of the target whose contents should be replacedThe function will replace the contents of the target_uuid VDI with the
contents of the vdi_uuid VDI without changing the identify of the target
(i.e. name-label, uuid and location are guaranteed to remain the same).
The vdi_uuid is preserved by this operation. The operation is obvoiusly
idempotent.
Xapi will
VDI.revert in the VM.revert code-pathxe vdi-revert CLI commandVDI.revert by calling the SMAPIv1 function and falling back
to VDI.clone if a Not_implemented exception is thrownReferences:
We will modify
vdi_revert function which throws
a ‘not implemented’ exceptionVDI.revert using a variant of the existing
snapshot/clone machineryVDI_REVERT capabilityVDI.revert using a variant of the existing
snapshot/clone machineryVDI_REVERT capabilityPrototype code exists here: