]> xenbits.xensource.com Git - libvirt.git/commitdiff
snapshot: forbid snapshot on autodestroy domain
authorEric Blake <eblake@redhat.com>
Fri, 26 Aug 2011 23:29:18 +0000 (17:29 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 30 Aug 2011 17:03:54 +0000 (11:03 -0600)
There is no reason to forbid pausing an autodestroy domain
(not to mention that 'virsh start --paused --autodestroy'
succeeds in creating a paused autodestroy domain).

Meanwhile, qemu was failing to enforce the API documentation that
autodestroy domains cannot be saved.  And while the original
documentation only mentioned save/restore, snapshots are another
form of saving that are close enough in semantics as to make no
sense on one-shot domains.

* src/qemu/qemu_driver.c (qemudDomainSuspend): Drop bogus check.
(qemuDomainSaveInternal, qemuDomainSnapshotCreateXML): Forbid
saves of autodestroy domains.
* src/libvirt.c (virDomainCreateWithFlags, virDomainCreateXML):
Document snapshot interaction.

src/libvirt.c
src/qemu/qemu_driver.c

index 80c8b7cd017151aaa6ccb89910a3332532a8b446..e4a21b6b22b7891144010e7ee3719535dedfa251 100644 (file)
@@ -1822,7 +1822,7 @@ virDomainGetConnect (virDomainPtr dom)
  * object is finally released. This will also happen if the
  * client application crashes / loses its connection to the
  * libvirtd daemon. Any domains marked for auto destroy will
- * block attempts at migration or save-to-file
+ * block attempts at migration, save-to-file, or snapshots.
  *
  * Returns a new domain object or NULL in case of failure
  */
@@ -7073,7 +7073,7 @@ error:
  * object is finally released. This will also happen if the
  * client application crashes / loses its connection to the
  * libvirtd daemon. Any domains marked for auto destroy will
- * block attempts at migration or save-to-file
+ * block attempts at migration, save-to-file, or snapshots.
  *
  * If the VIR_DOMAIN_START_BYPASS_CACHE flag is set, and there is a
  * managed save file for this domain (created by virDomainManagedSave()),
index 5033998703773f5598554847b6120b8cc466bbc1..4e8c69187dc41a6536340a2a5dc4343f97b9bb68 100644 (file)
@@ -1361,12 +1361,6 @@ static int qemudDomainSuspend(virDomainPtr dom) {
         goto cleanup;
     }
 
-    if (qemuProcessAutoDestroyActive(driver, vm)) {
-        qemuReportError(VIR_ERR_OPERATION_INVALID,
-                        "%s", _("domain is marked for auto destroy"));
-        goto cleanup;
-    }
-
     priv = vm->privateData;
 
     if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) {
@@ -2226,6 +2220,12 @@ qemuDomainSaveInternal(struct qemud_driver *driver, virDomainPtr dom,
     int directFlag = 0;
     virFileDirectFdPtr directFd = NULL;
 
+    if (qemuProcessAutoDestroyActive(driver, vm)) {
+        qemuReportError(VIR_ERR_OPERATION_INVALID,
+                        "%s", _("domain is marked for auto destroy"));
+        return -1;
+    }
+
     memset(&header, 0, sizeof(header));
     memcpy(header.magic, QEMUD_SAVE_MAGIC, sizeof(header.magic));
     header.version = QEMUD_SAVE_VERSION;
@@ -8481,6 +8481,12 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
         goto cleanup;
     }
 
+    if (qemuProcessAutoDestroyActive(driver, vm)) {
+        qemuReportError(VIR_ERR_OPERATION_INVALID,
+                        "%s", _("domain is marked for auto destroy"));
+        goto cleanup;
+    }
+
     /* in a perfect world, we would allow qemu to tell us this.  The problem
      * is that qemu only does this check device-by-device; so if you had a
      * domain that booted from a large qcow2 device, but had a secondary raw