[CRIU] [PATCH 1/3] plugin: add DUMP_VZCT and RESTORE_VZCT hooks to c/r custom VZCT props

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Feb 18 02:02:13 PST 2016


Put them just before post-dump and post restore scripts respectively

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/cr-dump.c             | 12 +++++++++++-
 criu/cr-restore.c          | 10 ++++++++++
 criu/include/criu-plugin.h |  5 +++++
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 27cc1d6..9704592 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -1519,9 +1519,18 @@ static int cr_dump_finish(int ret)
 	if (bfd_flush_images())
 		ret = -1;
 
+	post_dump_ret = run_plugins(DUMP_VZCT);
+	if (post_dump_ret != 0) {
+		if (post_dump_ret == -ENOTSUP)
+			post_dump_ret = 0;
+		else
+			pr_err("Post dump plugin VZCT failed with %d\n",
+			       post_dump_ret);
+	}
+
 	cr_plugin_fini(CR_PLUGIN_STAGE__DUMP, ret);
 
-	if (!ret) {
+	if (!ret && !post_dump_ret) {
 		/*
 		 * It might be a migration case, where we're asked
 		 * to dump everything, then some script transfer
@@ -1608,6 +1617,7 @@ int cr_dump_tasks(pid_t pid)
 		pr_err("Pre dump script failed with %d!\n", pre_dump_ret);
 		goto err;
 	}
+
 	if (init_stats(DUMP_STATS))
 		goto err;
 
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 67032a3..60bd41d 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -2039,6 +2039,16 @@ static int restore_root_task(struct pstree_item *init)
 	if (ret < 0)
 		goto out_kill;
 
+	ret = run_plugins(RESTORE_VZCT);
+	if (ret != 0) {
+		if (ret != -ENOTSUP) {
+			pr_err("Aborting restore due to VZCT plugin ret code %d\n", ret);
+			timing_stop(TIME_RESTORE);
+			write_stats(RESTORE_STATS);
+			goto out_kill;
+		}
+	}
+
 	ret = run_scripts(ACT_POST_RESTORE);
 	if (ret != 0) {
 		pr_err("Aborting restore due to post-restore script ret code %d\n", ret);
diff --git a/criu/include/criu-plugin.h b/criu/include/criu-plugin.h
index b76f5f8..689a1ef 100644
--- a/criu/include/criu-plugin.h
+++ b/criu/include/criu-plugin.h
@@ -50,6 +50,9 @@ enum {
 
 	CR_PLUGIN_HOOK__DUMP_EXT_LINK		= 6,
 
+	CR_PLUGIN_HOOK__DUMP_VZCT		= 7,
+	CR_PLUGIN_HOOK__RESTORE_VZCT		= 8,
+
 	CR_PLUGIN_HOOK__MAX
 };
 
@@ -63,6 +66,8 @@ DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_EXT_FILE, int id);
 DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_MOUNT, char *mountpoint, int id);
 DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_EXT_MOUNT, int id, char *mountpoint, char *old_root, int *is_file);
 DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_LINK, int index, int type, char *kind);
+DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_VZCT);
+DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_VZCT);
 
 enum {
 	CR_PLUGIN_STAGE__DUMP,
-- 
1.9.3



More information about the CRIU mailing list