[CRIU] [PATCH 5/5] dump: use global image for sockets queues image
file
Kinsbursky Stanislav
skinsbursky at openvz.org
Fri Mar 23 10:42:14 EDT 2012
From: Stanislav Kinsbursky <skinsbursky at openvz.org>
v2: added unlink of global files prior to dump stage.
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
cr-dump.c | 20 +++++++++++++++++++-
cr-show.c | 2 +-
include/crtools.h | 2 +-
sockets.c | 2 +-
4 files changed, 22 insertions(+), 4 deletions(-)
-------------- next part --------------
diff --git a/cr-dump.c b/cr-dump.c
index 8202801..10f3ac2 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1462,6 +1462,20 @@ err:
return -1;
}
+static int unlink_global_image_files(void)
+{
+ char path[PATH_MAX];
+
+ snprintf(path, PATH_MAX, fdset_template[CR_FD_SK_QUEUES].fmt);
+ if (unlinkat(image_dir_fd, path, 0) && errno != ENOENT)
+ goto err;
+ return 0;
+
+err:
+ pr_perror("Unable to unlink %s", path);
+ return -1;
+}
+
int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
{
LIST_HEAD(pstree_list);
@@ -1497,6 +1511,9 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
if (!shmems)
goto err;
+ if (unlink_global_image_files())
+ goto err;
+
list_for_each_entry(item, &pstree_list, list) {
struct cr_fdset *cr_fdset = NULL;
@@ -1510,8 +1527,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-show.c b/cr-show.c
index 4898a87..3832b49 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -531,7 +531,7 @@ static int cr_show_all(unsigned long pid, struct cr_options *opts)
if (ret)
goto out;
- cr_fdset = cr_show_fdset_open(pid, CR_FD_DESC_SK_QUEUES);
+ cr_fdset = cr_glob_fdset_open(CR_FD_DESC_SK_QUEUES, NULL);
if (!cr_fdset)
goto out;
diff --git a/include/crtools.h b/include/crtools.h
index 42f7f2f..5949d78 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -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