Features/SnapshotsMultipleDevices

From QEMU
Revision as of 13:45, 16 January 2012 by JeffCody (talk | contribs) (Created page with '=Atomic Snapshots of Multiple Devices= '''NOTE: This wiki page covers a ''proposed'' feature of QEMU and Live Snapshots - it does not reflect the current QEMU codebase''' There…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Atomic Snapshots of Multiple Devices

NOTE: This wiki page covers a proposed feature of QEMU and Live Snapshots - it does not reflect the current QEMU codebase

There has been some concern with the current snapshot_blkdev command; namely, it performs snapshots one device at a time, even if a guest has multiple devices. This can be troublesome in the instance of a snapshot failure. While qemu will revert back to the original backing store should a snapshot fail, that could still leave the guest in an overall inconsistent state, with respect to its other devices.

For instance, let us assume there are three devices in a guest: virtio0, virtio1, and virtio2. If we successfully perform a snapshot on virtio0 and virtio1, yet virtio2 fails, we could be in an inconsistent state. While we will have reverted virtio2 back to the previous backing store, virtio0 and virtio1 will have already successfully gone through the snapshot. Ideally, there would be a mechanism to allow all devices to have a snapshot taken as one atomic unit, so that for the snapshot to be successfully performed, all devices must have success.

There are a few different solutions to this issue, and the one proposed here is a mechanism to take snapshots of multiple devices atomically (with respect to the snapshot command), by the addition of new commands for taking snapshots of a set of devices. This will not replace the existing snapshot_blkdev command - that will remain available to take single snapshot of devices.

Snapshot sets will allow multiple devices to be queued for a snapshot, with the snapshot for all devices happening during a single command. This will allow an entire set to have a snapshot taken, and if any one device fails, the entire set reverted back to the original backing store.

The proposed commands are:

  • snapshot_set_create(id)
  • snapshot_set_destroy(id)
  • snapshot_set_add(id, device, snapshot-file, format)
  • snapshot_set_execute(id)


Proposed Snapshot Sets Commands

Here are details of the proposed commands, with the parameter values and descriptions. The parameters have been modeled after the existing snapshot_blkdev command.


snapshot_set_create

Creates a new set, with the given id. Once a set is created, new devices and be added to that set.

Parameter Description
id numeric id to identify the set



snapshot_set_forget

Removes a snapshot set - the snapshot set id will no longer be associated with any devices, and all devices previously added to this set will be removed. Note: this does not destroy any data, but simply dequeues and devices from the snapshot queue

Parameter Description
id numeric id to identify the set


snapshot_set_add

Adds a new device to the snapshot set identified by a given id. All devices added to a specific snapshot set will be the devices used to take a snapshot when the snapshot_set_execute command is issued.

Parameter Description
id numeric id of the set
device block device to snapshot
snapshot-file target snapshot file
format format of snapshot image, valid formats are QCOW2 & QED. If not specified, the image will default to QCOW2.



snapshot_set_execute

Performs the snapshot of the identified set. If a snapshot of any device fails, then all devices in the set will be reverted, and no snapshot will exist for any of the devices in the set. Snapshot is an all-or-none proposition of the set. The snapshot set can be cleared, or remembered for later reuse

Parameter Description
id numeric id to identify the set
forget 'false' to keep the set, or 'true' to forget the set. If not specified, the set will be forgotten after the snapshots have been attempted (whether they passed or failed) - i.e., 'id' will now become invalid.



Example Snapshot Sets Command Sequence

Below we have an example command sequence of an arbitrary number of devices added to a snapshot set, and a snapshot performed of the entire set with the set forgotten at the end of the snapshot:

Guest         Manager                                             QEMU
-------       --------                                           -------
  |               |                                                 |
  |               |                                                 |
  |               o---  snapshot_set_create(1234) --------------->> |
  |               |                                                 |
  |               |                                                 |
  |               o---  snapshot_set_add(1234, "virtio0",           |
  |               |                        "/some/place/my-image0", |
  |               |                        "qcow2" )  ----------->> |
  |               |                                                 |
  |               |                                                 |
  |               o---  snapshot_set_add(1234, "virtio0",           |
  |               |                        "/some/place/my-image0", |
  |               |                        "qcow2" )  ----------->> |
  |               |                                                 |
  |               |                                                 |
  .               .                                                 .
  .               .                                                 .
  .               .                                                 .
  |               o---  snapshot_set_add(1234, "virtioX",           |
  |               |                        "/some/place/my-imageX", |
  |               |                        "qcow2" )  ----------->> |
  |               |                                                 |
  |               |                                                 |
  *<--- freeze ---o                                                 |
  |               |                                                 |
  |               o--- snapshot_set_execute(id) ----------------->> |
  |               |                                                 |
  *<--- thaw -----o                                                 |
  |               |                                                 |
  |               |                                                 |
  |               |                                                 |
  =               =                                                 =