]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
managedsave: prohibit use on transient domains
authorEric Blake <eblake@redhat.com>
Wed, 10 Aug 2011 14:51:36 +0000 (08:51 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 11 Aug 2011 03:50:02 +0000 (21:50 -0600)
Transient domains reject attempts to set autostart, and using
virDomainCreate to restart a domain only works on persistent
domains.  Therefore, managed save makes no sense on transient
domains, and should be rejected up front rather than creating
an otherwise unrecoverable managed save file.

Besides, transient domains imply that a lot more management is
being done by the upper layer; this includes the assumption
that the upper layer is okay managing the saved state file
created by virDomainSave, and does not need to use managed save.

* src/libvirt.c: Document that transient domains are incompatible
with managed save.
* src/qemu/qemu_driver.c (qemuDomainManagedSave): Enforce it.
* src/libxl/libxl_driver.c (libxlDomainManagedSave): Likewise.

src/libvirt.c
src/libxl/libxl_driver.c
src/qemu/qemu_driver.c

index c154c7d1440d02c46904ae0deabdeba06bc0761c..c8af3e1e811546eb578e1550d6bfae84a0f9fd77 100644 (file)
@@ -15285,6 +15285,9 @@ error:
  * the saved state itself, and will reuse it once the domain is being
  * restarted (automatically or via an explicit libvirt call).
  * As a result any running domain is sure to not have a managed saved image.
+ * This also implies that managed save only works on persistent domains,
+ * since the domain must still exist in order to use virDomainCreate() to
+ * restart it.
  *
  * If @flags includes VIR_DOMAIN_SAVE_BYPASS_CACHE, then libvirt will
  * attempt to bypass the file system cache while creating the file, or
index 7cb362065b11823a9c6c65c5c0caaae088265dc3..516148f740d65cb994ddd4d83560bf7a6fe2bae5 100644 (file)
@@ -2132,6 +2132,11 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
         libxlError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
         goto cleanup;
     }
+    if (!vm->persistent) {
+        libxlError(VIR_ERR_OPERATION_INVALID, "%s",
+                   _("cannot do managed save for transient domain"));
+        goto cleanup;
+    }
 
     name = libxlDomainManagedSavePath(driver, vm);
     if (name == NULL)
index 0d6470da6559a503a932428d878afa8189a8ded6..19e749f1eb6b1dc37a057a9215d4e824371c173d 100644 (file)
@@ -2582,6 +2582,11 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
                         "%s", _("domain is not running"));
         goto cleanup;
     }
+    if (!vm->persistent) {
+        qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                        _("cannot do managed save for transient domain"));
+        goto cleanup;
+    }
 
     name = qemuDomainManagedSavePath(driver, vm);
     if (name == NULL)