[libvirt] managedsave vs. transient domains

How in the world is managedsave supposed to work on transient domains? The moment you save a domain, the qemu process is ended; but ending the qemu process means that a transient domain no longer has any state tracked by libvirt. Should libvirt be temporarily defining a domain when creating a managedsave of a transient domain? Seeing as how persistent domains cannot be marked autostart, does this mean that you have to use 'virsh start dom' rather than autostart to restart a transient domain with managedsave state? Or should managedsave be prohibited on transient domains, and only exist as a possibility for persistent ones? After all, qemuDomainHasManagedSaveImage() will always return false for a running domain - a managed save state file only exists if you have shut down the domain into managed state file with plans to later start from that file. Personally, I'm leaning towards the latter - just like virDomainSetAutostart fails on transient domains, I think virDomainManagedSave should likewise fail on transient domains, and that applications that favor transient domains should also be managing state files themselves, via virDomainSave[Flags], rather than relying on virDomainManagedSave. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

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. * 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. --- As evidence to my bias towards prohibiting managed save on transient domains... src/libvirt.c | 3 +++ src/libxl/libxl_driver.c | 5 +++++ src/qemu/qemu_driver.c | 5 +++++ 3 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index c154c7d..c8af3e1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 7cb3620..516148f 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -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) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ac323b6..c6c3901 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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) -- 1.7.4.4

On Wed, Aug 10, 2011 at 08:54:20AM -0600, Eric Blake wrote:
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.
* 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. ---
As evidence to my bias towards prohibiting managed save on transient domains...
src/libvirt.c | 3 +++ src/libxl/libxl_driver.c | 5 +++++ src/qemu/qemu_driver.c | 5 +++++ 3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index c154c7d..c8af3e1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 7cb3620..516148f 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -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) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ac323b6..c6c3901 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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)
ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 08/10/2011 08:19 PM, Daniel Veillard wrote:
On Wed, Aug 10, 2011 at 08:54:20AM -0600, Eric Blake wrote:
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.
* 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. ---
ACK
Pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Daniel Veillard
-
Eric Blake