snapshot: add flag for requesting disk snapshot

Prior to this patch, <domainsnapshot>/<disks> was ignored.  This
changes it to be an error unless an explicit disk snapshot is
requested (a future patch may relax things if it turns out to
be useful to have a <disks> specification alongside a system
checkpoint).

* include/libvirt/libvirt.h.in
(VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY): New flag.
* src/libvirt.c (virDomainSnapshotCreateXML): Document it.
* src/esx/esx_driver.c (esxDomainSnapshotCreateXML): Disk
snapshots not supported yet.
* src/vbox/vbox_tmpl.c (vboxDomainSnapshotCreateXML): Likewise.
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Likewise.
This commit is contained in:
Eric Blake 2011-08-19 22:03:38 -06:00
parent 88a993b129
commit e03a62b456
5 changed files with 26 additions and 0 deletions

View File

@ -2581,6 +2581,8 @@ typedef enum {
remembering it */ remembering it */
VIR_DOMAIN_SNAPSHOT_CREATE_HALT = (1 << 3), /* Stop running guest VIR_DOMAIN_SNAPSHOT_CREATE_HALT = (1 << 3), /* Stop running guest
after snapshot */ after snapshot */
VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY = (1 << 4), /* disk snapshot, not
system checkpoint */
} virDomainSnapshotCreateFlags; } virDomainSnapshotCreateFlags;
/* Take a snapshot of the current VM state */ /* Take a snapshot of the current VM state */

View File

@ -4226,6 +4226,12 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
return NULL; return NULL;
} }
if (def->ndisks) {
ESX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk snapshots not supported yet"));
return NULL;
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
(priv->primary, domain->uuid, NULL, &virtualMachine, (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->parsedUri->autoAnswer) < 0 || priv->parsedUri->autoAnswer) < 0 ||

View File

@ -15643,6 +15643,12 @@ error:
* running after the snapshot. This flag is invalid on transient domains, * running after the snapshot. This flag is invalid on transient domains,
* and is incompatible with VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE. * and is incompatible with VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE.
* *
* If @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY, then the
* snapshot will be limited to the disks described in @xmlDesc, and no
* VM state will be saved. For an active guest, the disk image may be
* inconsistent (as if power had been pulled), and specifying this
* with the VIR_DOMAIN_SNAPSHOT_CREATE_HALT flag risks data loss.
*
* Returns an (opaque) virDomainSnapshotPtr on success, NULL on failure. * Returns an (opaque) virDomainSnapshotPtr on success, NULL on failure.
*/ */
virDomainSnapshotPtr virDomainSnapshotPtr

View File

@ -8899,6 +8899,12 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
if (!qemuDomainSnapshotIsAllowed(vm)) if (!qemuDomainSnapshotIsAllowed(vm))
goto cleanup; goto cleanup;
if (def->ndisks) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk snapshots not supported yet"));
goto cleanup;
}
if (!(snap = virDomainSnapshotAssignDef(&vm->snapshots, def))) if (!(snap = virDomainSnapshotAssignDef(&vm->snapshots, def)))
goto cleanup; goto cleanup;
def = NULL; def = NULL;

View File

@ -5661,6 +5661,12 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
if (!(def = virDomainSnapshotDefParseString(xmlDesc, NULL, 0, 0))) if (!(def = virDomainSnapshotDefParseString(xmlDesc, NULL, 0, 0)))
goto cleanup; goto cleanup;
if (def->ndisks) {
vboxError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk snapshots not supported yet"));
goto cleanup;
}
vboxIIDFromUUID(&domiid, dom->uuid); vboxIIDFromUUID(&domiid, dom->uuid);
rc = VBOX_OBJECT_GET_MACHINE(domiid.value, &machine); rc = VBOX_OBJECT_GET_MACHINE(domiid.value, &machine);
if (NS_FAILED(rc)) { if (NS_FAILED(rc)) {