On Wed, Apr 22, 2015 at 01:16:08PM -0600, Tycho Andersen wrote:
> CRIU can get confused if more than one c/r is done in the same directory, so 
> we
> should require lxcapi so that it refuses to dump to a directory with criu
> images already in it.

Hmm, actually I'm not sure this is the best way to do this. If users
(e.g. LXD) use some sort of mechanism to generate a temporary
directory name we could race if the same name is tried twice in a row.
Instead, maybe it's just best to stat() for the key criu image file
(inventory.img), and die if it's there.

Thoughts?

> This won't help if the user copies a checkpoint over another, but at least the
> common case will be caught.
> 
> Signed-off-by: Tycho Andersen <[email protected]>
> ---
>  src/lxc/lxccontainer.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index dbcee99..4a290f1 100644
> --- a/src/lxc/lxccontainer.c
> +++ b/src/lxc/lxccontainer.c
> @@ -3687,8 +3687,13 @@ static bool do_lxcapi_checkpoint(struct lxc_container 
> *c, char *directory, bool
>       if (!criu_ok(c))
>               return false;
>  
> -     if (mkdir(directory, 0700) < 0 && errno != EEXIST)
> +     if (mkdir(directory, 0700) < 0) {
> +             if (errno == EEXIST)
> +                     ERROR("please use a new directory for criu state");
> +             else
> +                     SYSERROR("mkdir failed");
>               return false;
> +     }
>  
>       if (!dump_net_info(c, directory))
>               return false;
> -- 
> 2.1.4
> 
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to