xapi-project/xen-api — pull request #1935 by johnelse (2014-09-12 11:51:40+00:00)
Title: CA-143836: Fix up snapshot_of links after reverting to snapshot

SXM uses the snapshot_of field to decide where to migrate snapshot disks, as they should be copied to the same SR as the disk of which they are a snapshot. Reverting a VM to a snapshot does not update snapshot VDIs to point to the new leaf VDIs, meaning SXM can no longer decide where snapshot disks should be migrated.

To fix this without explicitly setting VDI.snapshot_of (an SMAPI-owned field) in xapi, we introduce a new SMAPI call: VDI.revert. This takes a snapshot as an argument, and proceeds to:

* Clone the snapshot
* Update all snapshots in the tree to be snapshot_of this newly cloned VDI.
* Destroy the original VDI from which the snapshot had been taken.

VM.revert then makes use of VDI.revert when reverting all of a VM's disks.