[lxc-devel] [PATCH] c/r: check for criu images in the checkpoint directory
Serge Hallyn
serge.hallyn at ubuntu.com
Fri Apr 24 21:30:44 UTC 2015
Quoting Tycho Andersen (tycho.andersen at canonical.com):
> CRIU can get confused if there are two dumps that are written to the same
> directory, so we make some minimal effort to prevent people from doing this.
> This is a better alternative than forcing liblxc to create the directory, since
> it is mostly race free (and neither solution is bullet proof anyway if someone
> rsyncs some bad images over the top of the good ones).
>
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> ---
> src/lxc/lxccontainer.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index dbcee99..8999f44 100644
> --- a/src/lxc/lxccontainer.c
> +++ b/src/lxc/lxccontainer.c
> @@ -3683,6 +3683,7 @@ static bool do_lxcapi_checkpoint(struct lxc_container *c, char *directory, bool
> {
> pid_t pid;
> int status;
> + char path[PATH_MAX];
>
> if (!criu_ok(c))
> return false;
> @@ -3690,6 +3691,15 @@ static bool do_lxcapi_checkpoint(struct lxc_container *c, char *directory, bool
> if (mkdir(directory, 0700) < 0 && errno != EEXIST)
> return false;
>
> + status = snprintf(path, sizeof(path), "%s/inventory.img", directory);
> + if (status < 0 || status >= sizeof(path))
> + return false;
> +
> + if (access(path, F_OK) == 0) {
> + ERROR("please use a fresh directory for the dump directory\n");
> + return false;
> + }
> +
> if (!dump_net_info(c, directory))
> return false;
>
> --
> 2.1.4
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
More information about the lxc-devel
mailing list