]> xenbits.xensource.com Git - libvirt.git/commitdiff
snapshot: add flag for requesting disk snapshot
authorEric Blake <eblake@redhat.com>
Sat, 20 Aug 2011 04:03:38 +0000 (22:03 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 5 Sep 2011 13:03:04 +0000 (07:03 -0600)
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.

include/libvirt/libvirt.h.in
src/esx/esx_driver.c
src/libvirt.c
src/qemu/qemu_driver.c
src/vbox/vbox_tmpl.c

index 4292736f8ac388e4df103a9a3e5acca8cb7ff617..157bef2045849e9c06021e788a7bb9f530e753de 100644 (file)
@@ -2581,6 +2581,8 @@ typedef enum {
                                                           remembering it */
     VIR_DOMAIN_SNAPSHOT_CREATE_HALT        = (1 << 3), /* Stop running guest
                                                           after snapshot */
+    VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY   = (1 << 4), /* disk snapshot, not
+                                                          system checkpoint */
 } virDomainSnapshotCreateFlags;
 
 /* Take a snapshot of the current VM state */
index 18edc454fd0765028d915a494c95357f616edf9f..f1102eac32389d2cab24a7791e3038d6b6e932ea 100644 (file)
@@ -4226,6 +4226,12 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
         return NULL;
     }
 
+    if (def->ndisks) {
+        ESX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                  _("disk snapshots not supported yet"));
+        return NULL;
+    }
+
     if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
           (priv->primary, domain->uuid, NULL, &virtualMachine,
            priv->parsedUri->autoAnswer) < 0 ||
index b29779ef7da0884c4f8842c13407a77635c7f957..89d1539e7ef21802c1b4c250026622f3343271ce 100644 (file)
@@ -15643,6 +15643,12 @@ error:
  * running after the snapshot.  This flag is invalid on transient domains,
  * 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.
  */
 virDomainSnapshotPtr
index d1c8659fcb7e7e8704101cea777a37d6c9001d0b..3a68862f5d9655bf65312f6e49bf647893c215fb 100644 (file)
@@ -8899,6 +8899,12 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
     if (!qemuDomainSnapshotIsAllowed(vm))
         goto cleanup;
 
+    if (def->ndisks) {
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                        _("disk snapshots not supported yet"));
+        goto cleanup;
+    }
+
     if (!(snap = virDomainSnapshotAssignDef(&vm->snapshots, def)))
         goto cleanup;
     def = NULL;
index cbe34e8f5eb2b444c3956c1547c4370a71e82964..0e4364f67e47ac71490e7714beb0db6dac227f64 100644 (file)
@@ -5661,6 +5661,12 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
     if (!(def = virDomainSnapshotDefParseString(xmlDesc, NULL, 0, 0)))
         goto cleanup;
 
+    if (def->ndisks) {
+        vboxError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                  _("disk snapshots not supported yet"));
+        goto cleanup;
+    }
+
     vboxIIDFromUUID(&domiid, dom->uuid);
     rc = VBOX_OBJECT_GET_MACHINE(domiid.value, &machine);
     if (NS_FAILED(rc)) {