[CRIU] [PATCH] dump: open global image files with global helpers

Kinsbursky Stanislav skinsbursky at openvz.org
Mon Mar 19 13:39:25 EDT 2012


Now global image files has not pid numbers in it's name.

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>

---
 cr-dump.c         |    5 +++--
 cr-restore.c      |    4 ++--
 cr-show.c         |    2 +-
 include/crtools.h |    4 ++--
 sockets.c         |    2 +-
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 39afb4e..de467e9 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1433,7 +1433,7 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
 
 	collect_sockets();
 
-	cr_fdset = cr_dump_fdset_open(pid, CR_FD_DESC_USE(CR_FD_PSTREE), cr_fdset);
+	cr_fdset = cr_glob_fdset_open(CR_FD_DESC_PSTREE, NULL);
 	if (!cr_fdset)
 		goto err;
 	if (dump_pstree(pid, &pstree_list, cr_fdset))
@@ -1451,8 +1451,9 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
 		 * them in "global" image.
 		 * That's why we open the file with tree leader's pid for any
 		 * of it's children.
+		 * The file will be created only if it's not exist.
 		 */
-		if (!cr_dump_fdset_open(pid, CR_FD_DESC_USE(CR_FD_SK_QUEUES), cr_fdset))
+		if (!cr_glob_fdset_open(CR_FD_DESC_SK_QUEUES, cr_fdset))
 			goto err;
 
 		if (dump_one_task(item, cr_fdset))
diff --git a/cr-restore.c b/cr-restore.c
index 71e5de1..d48385e 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1320,7 +1320,7 @@ static int restore_task_with_children(void *_arg)
 
 	pr_info("%d: Starting restore\n", me->pid);
 
-	fd = open_image_ro_nocheck(FMT_FNAME_PSTREE, pstree_pid);
+	fd = open_glob_image_ro_nocheck(FMT_FNAME_PSTREE);
 	if (fd < 0) {
 		pr_perror("%d: Can't reopen pstree image", me->pid);
 		exit(1);
@@ -1443,7 +1443,7 @@ static int restore_all_tasks(pid_t pid, struct cr_options *opts)
 	int pstree_fd = -1;
 	u32 type = 0;
 
-	pstree_fd = open_image_ro(CR_FD_PSTREE, pstree_pid);
+	pstree_fd = open_glob_image_ro(CR_FD_PSTREE);
 	if (pstree_fd < 0)
 		return -1;
 
diff --git a/cr-show.c b/cr-show.c
index eeb7042..2852389 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -551,7 +551,7 @@ static int cr_show_all(unsigned long pid, struct cr_options *opts)
 	LIST_HEAD(pstree_list);
 	int i, ret = -1;
 
-	cr_fdset = cr_show_fdset_open(pid, CR_FD_DESC_PSTREE | CR_FD_DESC_SK_QUEUES);
+	cr_fdset = cr_glob_fdset_open(CR_FD_DESC_PSTREE | CR_FD_DESC_SK_QUEUES, NULL);
 	if (!cr_fdset)
 		goto out;
 
diff --git a/include/crtools.h b/include/crtools.h
index af82b43..2275f8c 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -79,7 +79,7 @@ extern struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX];
 #define FMT_FNAME_CORE		"core-%d.img"
 #define FMT_FNAME_CORE_OUT	"core-%d.img.out"
 #define FMT_FNAME_PIPES		"pipes-%d.img"
-#define FMT_FNAME_PSTREE	"pstree-%d.img"
+#define FMT_FNAME_PSTREE	"pstree.img"
 #define FMT_FNAME_SHMEM		"shmem-%d.img"
 #define FMT_FNAME_SIGACTS	"sigacts-%d.img"
 #define FMT_FNAME_UNIXSK	"unixsk-%d.img"
@@ -91,7 +91,7 @@ extern struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX];
 #define FMT_FNAME_IPCNS_SHM	"ipcns-shm-%d.img"
 #define FMT_FNAME_IPCNS_MSG	"ipcns-msg-%d.img"
 #define FMT_FNAME_IPCNS_SEM	"ipcns-sem-%d.img"
-#define FMT_FNAME_SK_QUEUES	"sk-queues-%d.img"
+#define FMT_FNAME_SK_QUEUES	"sk-queues.img"
 
 /*
  * FIXME -- this is required for legacy image copy only.
diff --git a/sockets.c b/sockets.c
index f1896fa..8bf4c15 100644
--- a/sockets.c
+++ b/sockets.c
@@ -1186,7 +1186,7 @@ err:
 	if (ret)
 		return ret;
 
-	unix_pool.img_fd = open_image_ro(CR_FD_SK_QUEUES, pstree_pid);
+	unix_pool.img_fd = open_glob_image_ro(CR_FD_SK_QUEUES);
 	if (unix_pool.img_fd < 0)
 		return -1;
 	ret = read_sockets_queues(&unix_pool);



More information about the CRIU mailing list