Re: [PATCH RFC 5/5] lxc: adds save and restore support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 21, 2016 at 03:37:27PM +0000, Katerina Koukiou wrote:
> Add support for saving an lxc domain's state into files with lxcDomainSave
> and restore from file with lxcDomainRestore.
> Usage: virsh save [domain-name] [domain-id or domain-uuid] [directory name]
> 
> Signed-off-by: Katerina Koukiou <k.koukiou@xxxxxxxxx>
> ---
>  src/lxc/lxc_driver.c | 234 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 234 insertions(+)
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index bd47c91..cc05eef 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -84,6 +84,7 @@
>  #include "virhostdev.h"
>  #include "netdev_bandwidth_conf.h"
>  
> +#include "lxc_criu.h"
>  #define VIR_FROM_THIS VIR_FROM_LXC
>  
>  VIR_LOG_INIT("lxc.lxc_driver");
> @@ -3205,6 +3206,235 @@ static int lxcDomainResume(virDomainPtr dom)
>  }
>  
>  static int
> +lxcDoDomainSave(virLXCDriverPtr driver, virDomainObjPtr vm,
> +                const char *to)
> +{
> +    int ret = -1;
> +    virCapsPtr caps = NULL;
> +    uint32_t xml_len = -1;
> +    char *xml = NULL;
> +    char xmlLen[33];
> +    char *xml_image_path = NULL;
> +    char *str = NULL;
> +
> +    if (!(caps = virLXCDriverGetCapabilities(driver, false)))
> +        goto cleanup;
> +
> +    if ((xml = virDomainDefFormat(vm->def, caps, 0)) == NULL)
> +        goto cleanup;
> +
> +    if ((ret = lxcCriuDump(driver, vm, to)) != 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Failed to checkpoint domain with CRIU"));
> +        goto cleanup;
> +    }
> +
> +    virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF,
> +                         VIR_DOMAIN_SHUTOFF_SAVED);
> +
> +    if (virAsprintf(&xml_image_path, "%s/xml-image", to) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Failed to write image path"));
> +        goto cleanup;
> +    }

The 'to' argument to virDomainSave is defined to be a filename,
not a directory. So as mentioned in previous patch, you need to
get all the dump state into that file, both XML and container
state.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]