[lxc-devel] [lxc/master] Allow passing action scripts to CRIU

brauner on Github lxc-bot at linuxcontainers.org
Tue Mar 27 20:34:29 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 435 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180327/759b27e1/attachment.bin>
-------------- next part --------------
From 590197542e3fa3a5a4b0f1d5e5dfc02d7d86759a Mon Sep 17 00:00:00 2001
From: Eytan Heidingsfeld <eytanh at gmail.com>
Date: Sun, 25 Mar 2018 21:10:21 +0000
Subject: [PATCH] Allow passing action scripts to CRIU

Closes #2236.

Signed-off-by: Eytan Heidingsfeld <eytanh at gmail.com>
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/tools/lxc_checkpoint.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/lxc/tools/lxc_checkpoint.c b/src/lxc/tools/lxc_checkpoint.c
index 3eec94dce..3d8050526 100644
--- a/src/lxc/tools/lxc_checkpoint.c
+++ b/src/lxc/tools/lxc_checkpoint.c
@@ -36,11 +36,13 @@ static bool do_restore = false;
 static bool daemonize_set = false;
 static bool pre_dump = false;
 static char *predump_dir = NULL;
+static char *actionscript_path = NULL;
 
 #define OPT_PREDUMP_DIR OPT_USAGE + 1
 
 static const struct option my_longopts[] = {
 	{"checkpoint-dir", required_argument, 0, 'D'},
+	{"action-script", required_argument, 0, 'A'},
 	{"stop", no_argument, 0, 's'},
 	{"verbose", no_argument, 0, 'v'},
 	{"restore", no_argument, 0, 'r'},
@@ -83,6 +85,11 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
 		if (!checkpoint_dir)
 			return -1;
 		break;
+        case 'A':
+		actionscript_path = strdup(arg);
+		if (!actionscript_path)
+			return -1;
+		break;
 	case 's':
 		stop = true;
 		break;
@@ -126,6 +133,7 @@ Options :\n\
   -r, --restore             Restore container\n\
   -D, --checkpoint-dir=DIR  directory to save the checkpoint in\n\
   -v, --verbose             Enable verbose criu logs\n\
+  -A, --action-script=PATH  Path to criu action script\n\
   Checkpoint options:\n\
   -s, --stop                Stop the container after checkpointing.\n\
   -p, --pre-dump            Only pre-dump the memory of the container.\n\
@@ -182,13 +190,23 @@ static bool checkpoint(struct lxc_container *c)
 
 static bool restore_finalize(struct lxc_container *c)
 {
-	bool ret = c->restore(c, checkpoint_dir, verbose);
-	if (!ret) {
+	struct migrate_opts opts;
+	bool ret;
+
+	memset(&opts, 0, sizeof(opts));
+
+	opts.directory = checkpoint_dir;
+	opts.verbose = verbose;
+	opts.stop = stop;
+	opts.action_script = actionscript_path;
+	ret = c->migrate(c, MIGRATE_RESTORE, &opts, sizeof(opts));
+	if (ret) {
 		fprintf(stderr, "Restoring %s failed.\n", my_args.name);
+		return false;
 	}
 
 	lxc_container_put(c);
-	return ret;
+	return true;
 }
 
 static bool restore(struct lxc_container *c)
@@ -289,6 +307,9 @@ int main(int argc, char *argv[])
 		ret = restore(c);
 	else
 		ret = checkpoint(c);
+	free(actionscript_path);
+	free(checkpoint_dir);
+	free(predump_dir);
 
 	if (!ret)
 		exit(EXIT_FAILURE);


More information about the lxc-devel mailing list