[CRIU] [PATCH 8/8] tty: Kill prepare_shared_tty
Pavel Emelyanov
xemul at virtuozzo.com
Thu May 18 02:37:01 PDT 2017
The routine in question just sets up the mutex to access
/dev/ptmx. This initialization can be done when we collect
a single tty.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/cr-restore.c | 3 ---
criu/include/tty.h | 1 -
criu/tty.c | 12 +++++++++++-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 2179fd3..21ba39e 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1701,9 +1701,6 @@ static int restore_task_with_children(void *_arg)
/* Restore root task */
if (current->parent == NULL) {
- if (prepare_shared_tty())
- goto err;
-
if (join_namespaces()) {
pr_perror("Join namespaces failed");
goto err;
diff --git a/criu/include/tty.h b/criu/include/tty.h
index 5ad8b09..5550a72 100644
--- a/criu/include/tty.h
+++ b/criu/include/tty.h
@@ -27,7 +27,6 @@ extern int dump_verify_tty_sids(void);
extern struct collect_image_info tty_info_cinfo;
extern struct collect_image_info tty_cinfo;
extern struct collect_image_info tty_cdata;
-extern int prepare_shared_tty(void);
struct mount_info;
extern int devpts_restore(struct mount_info *pm);
diff --git a/criu/tty.c b/criu/tty.c
index 7888444..cf21cbd 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -326,8 +326,11 @@ static mutex_t *tty_mutex;
static bool tty_is_master(struct tty_info *info);
-int prepare_shared_tty(void)
+static int init_tty_mutex(void)
{
+ if (tty_mutex)
+ return 0;
+
tty_mutex = shmalloc(sizeof(*tty_mutex));
if (!tty_mutex) {
pr_err("Can't create ptmx index mutex\n");
@@ -1638,6 +1641,13 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
if (add_post_prepare_cb_once(prep_tty_restore, NULL))
return -1;
+ /*
+ * Call it explicitly. Post-callbacks will be called after
+ * namespaces preparation, while the latter needs this mutex.
+ */
+ if (init_tty_mutex())
+ return -1;
+
info->fdstore_id = -1;
list_add(&info->list, &all_ttys);
return file_desc_add(&info->d, info->tfe->id, &tty_desc_ops);
--
2.1.4
More information about the CRIU
mailing list