[CRIU] [PATCH] scripts: set CRIU_IMAGE_DIR when running scripts
Pavel Emelyanov
xemul at parallels.com
Tue Aug 12 07:31:45 PDT 2014
On 08/12/2014 06:22 PM, Tycho Andersen wrote:
> When doing a restore for LXC, we store some other metadata (which bridge a veth
> was on) in the image directory so that the restore script can correctly unlock
> a network device and attach it to the right interface. This patch is needed so
> that the script can find this metadata.
>
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
> util.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/util.c b/util.c
> index a180ea5..4ff8768 100644
> --- a/util.c
> +++ b/util.c
> @@ -460,6 +460,7 @@ int run_scripts(char *action)
> {
> struct script *script;
> int ret = 0;
> + char image_dir[PATH_MAX];
Odd enough, but we have a magic constant PSFDS that says "how much
would the path to /proc/self/fd/%d occupy on the stack" :)
>
> pr_debug("Running %s scripts\n", action);
>
> @@ -468,6 +469,12 @@ int run_scripts(char *action)
> return -1;
> }
>
> + sprintf(image_dir, "/proc/%ld/fd/%d", (long) getpid(), get_service_fd(IMG_FD_OFF));
Maybe /proc/self/fd/%d would be nicer? This would allow using the
PSFDS above :)
> + if (setenv("CRTOOLS_IMAGE_DIR", image_dir, 1)) {
> + pr_perror("Can't set CRTOOLS_IMAGE_DIR=%s", image_dir);
> + return -1;
> + }
> +
> list_for_each_entry(script, &opts.scripts, node) {
> if (script->path == SCRIPT_RPC_NOTIFY) {
> pr_debug("\tRPC\n");
>
More information about the CRIU
mailing list