checkpoint/restart of PTYs
Subsystems (5)
This short series adds support for checkpoint and restart of PTYs. It is mildly tested on top of ckpt-v17-dev (with test/pty from user-cr).
I'm not an expert on PTYs, TTYs, line disciplines and the like, comments are mostly welcome:
* Only handles PTYs related to open files (no signal->...)
* What (additional) values we need to sanitize on restart ?
* What additional locking should be in place ? (especially checkpoint)
* Need to save/restore echo buffer (and position) ?
* /dev/ptmx and /dev/pts/... paths are currently hardcoded
* For restart without restoring PIDs, need to ensure the session and pgrp are either -1 (none) or limited to a PID value that belongs to the restarted subtree.
* For restart with restoring PIDs, need to create on-the-fly session and/or pgrp PIDs that do not exist (e.g. of a dead process). This is also necessary to correctly restore pgrp, regardless of PTYs.
* Other security concerns ? ...
* and probably more :p
Oren.
RFC PATCH 1/3 c/r: [objhash] add ckpt_obj_reserve()
In reply to a message not in the archiveUse ckpt_obj_reserve() during checkpoint to reserve an objref that will not be otherwise used for any other object in checkpoint. Such an objref can be useful for restart to add objects that were not there at checkpoint.
One use case for this is ptys (subsequent patches): when restoring a master pty, we create a file pointer, which must be kept somewhere and later cleaned up. The hash is a good place to store it.
--- checkpoint/objhash.c | 20 +++++++++++++++++++- include/linux/checkpoint.h | 1 + 2 files changed, 20 insertions(+), 1 deletions(-)
checkpoint/objhash.c +19 -1
@@ -465,6 +465,11 @@ static struct ckpt_obj *obj_find_by_objref(struct ckpt_ctx *ctx, int objref)return NULL ; } +static inline int obj_alloc_objref (struct ckpt_ctx *ctx) +{ +return ctx->obj_hash->next_free_objref++; +} +/** * ckpt_obj_new - add an object to the obj_hash * @ctx: checkpoint context
@@ -498,7 +503,7 @@ static struct ckpt_obj *obj_new(struct ckpt_ctx *ctx, void *ptr,if (!objref) {/* use @obj->ptr to index, assign objref (checkpoint) */ - obj->objref = ctx->obj_hash->next_free_objref++;; + obj->objref =obj_alloc_objref (ctx); i =hash_long ((unsigned long ) ptr,CKPT_OBJ_HASH_NBITS ); }else {/* use @obj->objref to index (restart) */
@@ -637,6 +642,19 @@ int ckpt_obj_lookup_add(struct ckpt_ctx *ctx, void *ptr, }/** +* ckpt_obj_reserve - reserve an objref +* @ctx: checkpoint context +* +* The reserved objref will not be used for subsequent objects. This +* gives an objref that can be safely used during restart without a +* matching object in checkpoint. [used during checkpoint]. +*/ +int ckpt_obj_reserve (struct ckpt_ctx *ctx) +{ +return obj_alloc_objref (ctx); +} + +/** * checkpoint_obj - if not already in hash, add object and checkpoint * @ctx: checkpoint context * @ptr: pointer to object
include/linux/checkpoint.h +1 -0
@@ -121,6 +121,7 @@ extern void *ckpt_obj_fetch(struct ckpt_ctx *ctx, int objref, enum obj_type type);extern int ckpt_obj_insert (struct ckpt_ctx *ctx,void *ptr,int objref,enum obj_type type); +extern int ckpt_obj_reserve (struct ckpt_ctx *ctx);extern void ckpt_ctx_get (struct ckpt_ctx *ctx);extern void ckpt_ctx_put (struct ckpt_ctx *ctx);
Signature · 1 line
1.6.0.4
RFC PATCH 2/3 c/r: [pty 1/2] allow allocation of desired pty slave
In reply to a message not in the archiveDuring restart, we need to allocate pty slaves with the same identifiers as recorded during checkpoint. Modify the allocation code to allow an in-kernel caller to request a specific slave identifier.
For this, add a new field to task_struct - 'required_id'. It will hold the desired identifier when restoring a (master) pty.
The code in ptmx_open() will use this value only for tasks that try to open /dev/ptmx that are restarting (PF_RESTARTING), and if the value isn't CKPT_REQUIRED_NONE (-1).
--- checkpoint/sys.c | 7 +++++++ drivers/char/pty.c | 9 +++++++-- fs/devpts/inode.c | 10 ++++++++-- include/linux/checkpoint.h | 2 ++ include/linux/devpts_fs.h | 2 +- include/linux/sched.h | 1 + 6 files changed, 26 insertions(+), 5 deletions(-)
checkpoint/sys.c +7 -0
@@ -339,6 +339,13 @@ SYSCALL_DEFINE3(restart, pid_t, pid, int, fd, unsigned long, flags)return ret; } +static int __init checkpoint_init (void ) +{ + init_task.required_id =CKPT_REQUIRED_NONE ; +return 0 ; +} +__initcall (checkpoint_init); +/* 'ckpt_debug_level' controls the verbosity level of c/r code */ #ifdef CONFIG_CHECKPOINT_DEBUG
drivers/char/pty.c +7 -2
@@ -633,12 +633,17 @@ static int __ptmx_open(struct inode *inode, struct file *filp) {struct tty_struct *tty;int retval; -int index; +int index =0 ;nonseekable_open (inode, filp); +#ifdef CONFIG_CHECKPOINT +/* when restarting, request specific index */ +if (current->flags &PF_RESTARTING ) + index = (int ) current->required_id; +#endif /* find a device that is not in use. */ - index =devpts_new_index (inode); + index =devpts_new_index (inode, index);if (index <0 )return index;
fs/devpts/inode.c +8 -2
@@ -433,7 +433,7 @@ static struct file_system_type devpts_fs_type = {* to the System V naming convention */ -int devpts_new_index (struct inode *ptmx_inode) +int devpts_new_index (struct inode *ptmx_inode,int req_idx) {struct super_block *sb =pts_sb_from_inode (ptmx_inode);struct pts_fs_info *fsi =DEVPTS_SB (sb);
@@ -445,7 +445,8 @@ retry:return -ENOMEM ;mutex_lock (&allocated_ptys_lock); - ida_ret =ida_get_new (&fsi->allocated_ptys, &index); + index = (req_idx >=0 ? req_idx :0 ); + ida_ret =ida_get_new_above (&fsi->allocated_ptys, index, &index);if (ida_ret <0 ) {mutex_unlock (&allocated_ptys_lock);if (ida_ret == -EAGAIN )
@@ -453,6 +454,11 @@ retry:return -EIO ; } +if (req_idx >=0 && index != req_idx) { +ida_remove (&fsi->allocated_ptys, index); +mutex_unlock (&allocated_ptys_lock); +return -EBUSY ; + }if (index >= pty_limit) {ida_remove (&fsi->allocated_ptys, index);mutex_unlock (&allocated_ptys_lock);
include/linux/checkpoint.h +2 -0
@@ -46,6 +46,8 @@#define CHECKPOINT_USER_FLAGS CHECKPOINT_SUBTREE#define RESTART_USER_FLAGS (RESTART_TASKSELF | RESTART_FROZEN) +#define CKPT_REQUIRED_NONE ((unsigned long) -1L) +extern void exit_checkpoint (struct task_struct *tsk);extern int ckpt_kwrite (struct ckpt_ctx *ctx,void *buf,int count);
include/linux/devpts_fs.h +1 -1
@@ -17,7 +17,7 @@#ifdef CONFIG_UNIX98_PTYS -int devpts_new_index (struct inode *ptmx_inode); +int devpts_new_index (struct inode *ptmx_inode,int req_idx);void devpts_kill_index (struct inode *ptmx_inode,int idx);/* mknod in devpts */ int devpts_pty_new (struct inode *ptmx_inode,struct tty_struct *tty);
include/linux/sched.h +1 -0
@@ -1481,6 +1481,7 @@ struct task_struct {#endif /* CONFIG_TRACING */ #ifdef CONFIG_CHECKPOINT struct ckpt_ctx *checkpoint_ctx; +unsigned long required_id;#endif };
Signature · 1 line
1.6.0.4
RFC PATCH 3/3 c/r: [pty 2/2] support for pseudo terminals
In reply to a message not in the archiveThis patch adds support for checkpoint and restart of pseudo terminals (PTYs). Since PTYs are shared (pointed to by file, and signal), they are managed via objhash.
PTYs are master/slave pairs; The code arranges for the master to always be checkpointed first, followed by the slave. This is important since during restart both ends are created when restoring the master.
In this patch only UNIX98 style PTYs are supported.
Currently only PTYs that are referenced by open files are handled. Thus PTYs checkpoint starts with a file in tty_file_checkpoint(). It will first checkpoint the master and slave PTYs via tty_checkpoint(), and then complete the saving of the file descriptor. This means that in the image file, the order of objects is: master-tty, slave-tty, file-desc.
During restart, to restore the master side, we open the /dev/ptmx device and get a file handle. But at this point we don't know the designated objref for this file, because the file is due later on in the image stream. On the other hand, we can't just fput() the file because it will close the PTY too.
Instead, when we checkpoint the master PTY, we _reserve_ an objref for the file (which won't be further used in checkpoint). Then at restart, use it to insert the file to objhash.
TODO:
* Better sanitize input from checkpoint image on restore
* Check the locking when saving/restoring tty_struct state
* Echo position/buffer isn't saved (is it needed ?)
* Handle multiple devpts mounts (namespaces)
* Handle case where session/pgrp do not exist on restart
* Paths of ptmx and slaves are hard coded (/dev/ptmx, /dev/pts/...)
--- arch/x86/include/asm/checkpoint_hdr.h | 9 + checkpoint/files.c | 6 + checkpoint/objhash.c | 26 ++ drivers/char/pty.c | 2 +- drivers/char/tty_io.c | 511 ++++++++++++++++++++++++++++++++- include/linux/checkpoint.h | 5 + include/linux/checkpoint_hdr.h | 76 +++++ include/linux/tty.h | 6 + 8 files changed, 639 insertions(+), 2 deletions(-)
arch/x86/include/asm/checkpoint_hdr.h +9 -0
@@ -56,6 +56,15 @@ enum {#endif #endif +#define CKPT_TTY_NCC 8 +#ifdef __KERNEL__ +#include <linux/tty.h> +#if CKPT_TTY_NCC !=NCC +#error CKPT_TTY_NCC size is wrong per asm-generic/termios.h +#endif +#endif + +struct ckpt_hdr_header_arch {struct ckpt_hdr h;/* FIXME: add HAVE_HWFP */
checkpoint/files.c +6 -0
@@ -572,6 +572,12 @@ static struct restore_file_ops restore_file_ops[] = { .file_type = CKPT_FILE_SOCKET, .restore = sock_file_restore, }, +/* tty */ + { + .file_name = "TTY", + .file_type = CKPT_FILE_TTY, + .restore = tty_file_restore, + }, };static struct file *do_restore_file (struct ckpt_ctx *ctx)
checkpoint/objhash.c +26 -0
@@ -246,6 +246,22 @@ static void obj_sock_drop(void *ptr)sock_put ((struct sock *) ptr); } +static int obj_tty_grab (void *ptr) +{ +tty_kref_get ((struct tty_struct *) ptr); +return 0 ; +} + +static void obj_tty_drop (void *ptr) +{ +tty_kref_put ((struct tty_struct *) ptr); +} + +static int obj_tty_users (void *ptr) +{ +return atomic_read (&((struct tty_struct *) ptr)->kref.refcount); +} +static struct ckpt_obj_ops ckpt_obj_ops[] = {/* ignored object */ {
@@ -382,6 +398,16 @@ static struct ckpt_obj_ops ckpt_obj_ops[] = { .ref_drop = obj_sock_drop, .ref_grab = obj_sock_grab, }, +/* struct tty_struct */ + { + .obj_name = "TTY", + .obj_type = CKPT_OBJ_TTY, + .ref_drop = obj_tty_drop, + .ref_grab = obj_tty_grab, + .ref_users = obj_tty_users, + .checkpoint = checkpoint_tty, + .restore = restore_tty, + }, };
drivers/char/pty.c +1 -1
@@ -633,7 +633,7 @@ static int __ptmx_open(struct inode *inode, struct file *filp) {struct tty_struct *tty;int retval; -int index =0 ; +int index =-1 ;nonseekable_open (inode, filp);
drivers/char/tty_io.c +510 -1
547 lines not on this page · raw message
include/linux/checkpoint.h +5 -0
@@ -265,6 +265,11 @@ extern int restore_obj_signal(struct ckpt_ctx *ctx, int signal_objref);extern int checkpoint_task_signal (struct ckpt_ctx *ctx,struct task_struct *t);extern int restore_task_signal (struct ckpt_ctx *ctx); +/* ttys */ +extern int checkpoint_tty (struct ckpt_ctx *ctx,void *ptr); +extern void *restore_tty (struct ckpt_ctx *ctx); + +/* useful macros to copy fields and buffers to/from ckpt_hdr_xxx structures */ #define CKPT_CPT 1#define CKPT_RST 2
include/linux/checkpoint_hdr.h +76 -0
100 lines not on this page · raw message
include/linux/tty.h +6 -0
@@ -467,6 +467,12 @@ extern void tty_ldisc_begin(void);/* This last one is just for the tty layer internals and shouldn't be used elsewhere */ extern void tty_ldisc_enable (struct tty_struct *tty); +#ifdef CONFIG_CHECKPOINT +struct ckpt_ctx ; +struct ckpt_hdr_file ; +extern struct file *tty_file_restore (struct ckpt_ctx *ctx, +struct ckpt_hdr_file *ptr); +#endif /* n_tty.c */ extern struct tty_ldisc_ops tty_ldisc_N_TTY;
Signature · 1 line
1.6.0.4
Re: [RFC][PATCH 2/3] c/r: [pty 1/2] allow allocation of desired pty slave
In reply to a message not in the archiveQuoted 6 lines · Oren Laadan
During restart, we need to allocate pty slaves with the same identifiers as recorded during checkpoint. Modify the allocation code to allow an in-kernel caller to request a specific slave identifier.
For this, add a new field to
task_struct- 'required_id'. It will hold the desired identifier when restoring a (master) pty.
This is really unfortunate.
I assume you left the rather generic name 'required_id' because you intend to use it for other calls as well? Which is even more unfortunate...
I know I'm generally the one who pushes for re-using existing helpers as much as possible, both to avoid missing existing security checks, and to prevent future code changes which forget to update the c/r code.
But in this case I don't think re-using fopen to ask the kernel to create a new device with more info than fopen usually gets is right. Unfortunately, actually coming up with 'the right way' is escaping me at the moment :)
Though... then again... your code is hardcoded for devpts and opening /dev/ptmx anyway, so surely we can create a new helper which takes a devpts_ns and index and returns the new devpts tty_struct without using the current->required_id?
Then, if we ever want to support a tty type other than unix98, maybe we can more generally split up more like:
1. add 'struct tty_struct *make_tty(struct tty_driver *driver, void *data) to tty_operations. It is undefined for all but devpts.
2. for devpts, the void *data includes an int devpts_ns_id and index
3. the container-level checkpoint stores a relation between pathnames and devpts_ns_id. devpts_ns_id is valid only for one checkpoint image. The pathname is where that devpts_ns is mounted. If we ever start checkpointing and restoring fs mounts from kernel, then we can tweak this treatment. For now it is assumed (and verified) that at restart, pathname is in fact where a devpts instance is mounted.
4. the tty_struct itself is checkpointed and restored. It is restored using make_tty() in tty_operations, and for devpts the void *data is a struct storing the devpts_ns_id and index.
5. when a struct file for a devpts is restored, the tty_struct will already have been re-created. The tty_struct's objref is stored in the file struct checkpoint data.
It requires more finagling of the file/inode/tty_struct relationship though... But I don't see required_id being acceptable upstream.
Of course I've been wrong about such things before.
-serge
Re: [RFC][PATCH 2/3] c/r: [pty 1/2] allow allocation of desired pty slave
In reply to a message not in the archiveQuoted 9 lines · Serge E. Hallyn
Quoted 6 lines · Oren Laadan
During restart, we need to allocate pty slaves with the same identifiers as recorded during checkpoint. Modify the allocation code to allow an in-kernel caller to request a specific slave identifier.
For this, add a new field to
task_struct- 'required_id'. It will hold the desired identifier when restoring a (master) pty.This is really unfortunate.
:(
Quoted 4 lines
I assume you left the rather generic name '
required_id' because you intend to use it for other calls as well? Which is even more unfortunate...
:'(
Quoted 11 lines
I know I'm generally the one who pushes for re-using existing helpers as much as possible, both to avoid missing existing security checks, and to prevent future code changes which forget to update the c/r code.
But in this case I don't think re-using fopen to ask the kernel to create a new device with more info than fopen usually gets is right. Unfortunately, actually coming up with 'the right way' is escaping me at the moment :)
Quoted 4 lines
Though... then again... your code is hardcoded for devpts and opening
/dev/ptmxanyway, so surely we can create a new helper which takes adevpts_nsand index and returns the new devptstty_structwithout using thecurrent->required_id?
The problem is that the way pty works: the index allocation takes place inside ptmx_open(). As it is, I can't find of a way to directly transfer a piece of data to it, because all we do is call filp_open().
For this, we need add new functionality for pty code to
a) Allocate a master PTY without the corresponding file; this function will be called from ptmx_open() and from restart code, and will accept the "desired index" variable.
b) Attach an existing (master) PTY to a file pointer. This will also be called from ptmx_open() and from restart code.
and
c) For restart only, manually do the work of filp_open() to create a file, dentry, inode etc. This is what I really wanted to avoid.
Quoted 3 lines
Then, if we ever want to support a tty type other than unix98, maybe we can more generally split up more like:
Other tty types have index that is indicated by the device minor number (e.g. old style PTYs) or no index considerations :)
Oren.
Quoted 28 lines
1. add 'struct
tty_struct*make_tty(structtty_driver*driver, void *data) totty_operations. It is undefined for all but devpts.
2. for devpts, the void *data includes an intdevpts_ns_idand index
3. the container-level checkpoint stores a relation between pathnames anddevpts_ns_id.devpts_ns_idis valid only for one checkpoint image. The pathname is where thatdevpts_nsis mounted. If we ever start checkpointing and restoring fs mounts from kernel, then we can tweak this treatment. For now it is assumed (and verified) that at restart, pathname is in fact where a devpts instance is mounted.
4. thetty_structitself is checkpointed and restored. It is restored usingmake_tty()intty_operations, and for devpts the void *data is a struct storing thedevpts_ns_idand index.
5. when a struct file for a devpts is restored, thetty_structwill already have been re-created. The tty_struct's objref is stored in the file struct checkpoint data.It requires more finagling of the file/inode/tty_struct relationship though... But I don't see
required_idbeing acceptable upstream.Of course I've been wrong about such things before.
-serge
Re: [RFC][PATCH 3/3] c/r: [pty 2/2] support for pseudo terminals
In reply to a message not in the archiveAll right, I'm not sure how to go about this - i want to have a conversation involving patches without making it seem like I want any of the patches pushed yet :) To get this working on s390, I needed the two attached patches. Then the testcase under git://git.sr71.net/~hallyn/cr_tests.git
under cr_tests/pty/ passes with your code.
I'd still like to get a more invasive approach working where we directly ask the pty code to create the pty with the right index. I'm playing with it right now, but of course having some trouble figuring out what to do for the master end and how best to construct a filp to pass to the main pty_create function. I'll take a few more stabs and send out what I have later (or announce defeat).
There is certainly something to be said for the un-invasiveness of your approach (and that it works).
In either case, we will need to figure out how to deal with devpts namespaces. Perhaps we separately checkpoint a 'devpts_mnt'. It just stores the mountpoint of the mount. At restart, we don't recreate those, we just confirm that the mountpoints still exist. Then, each pty entry has a ref to its devpts mount, and we use the mountpoint to construct ${mountpoint}/ptmx and pass that to filp_open() or ptmx_create)( to create the pty entry.
-serge
From 552f3df7802a8833276a0aac69b92c1bce385dbf Mon Sep 17 00:00:00 2001
From: Serge E. Hallyn <serue-r/[email protected]>
Date: Tue, 1 Sep 2009 12:36:28 -0400
Subject: [PATCH 1/2] pty cr: s390: define CKPT_TTY_NCC
--- arch/s390/include/asm/checkpoint_hdr.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
arch/s390/include/asm/checkpoint_hdr.h +8 -0
@@ -90,6 +90,14 @@ struct ckpt_hdr_mm_context {#endif #endif +#define CKPT_TTY_NCC 8 +#ifdef __KERNEL__ +#include <linux/tty.h> +#if CKPT_TTY_NCC !=NCC +#error CKPT_TTY_NCC size is wrong per asm-generic/termios.h +#endif +#endif +struct ckpt_hdr_header_arch {struct ckpt_hdr h; };
Signature · 1 line
1.6.1
From 68b12cb69f2741052eba60658404e4eec221d112 Mon Sep 17 00:00:00 2001
From: Serge E. Hallyn <serue-r/[email protected]>
Date: Tue, 1 Sep 2009 21:34:12 -0400
Subject: [PATCH 2/2] cr: bugfixes of oren's code
--- drivers/char/tty_io.c | 6 +++++- include/linux/checkpoint_hdr.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/char/tty_io.c +5 -1
@@ -2730,7 +2730,11 @@ static int checkpoint_tty_ldisc(struct ckpt_ctx *ctx, struct tty_struct *tty) h->column = tty->column; h->datalen = tty->read_cnt; h->canon_column = tty->canon_column; - h->canon_datalen = tty->canon_head - tty->read_tail; + h->canon_datalen = tty->canon_head; +if (tty->canon_head > tty->read_tail) + h->canon_datalen -= tty->read_tail; +else + h->canon_datalen +=N_TTY_BUF_SIZE - tty->read_tail; h->canon_data = tty->canon_data; datalen = tty->read_cnt;
include/linux/checkpoint_hdr.h +1 -1
@@ -688,7 +688,7 @@ struct ckpt_hdr_ldisc_n_tty {struct ckpt_hdr h;__u32 column; -__u32 datalen; +__s32 datalen;__u32 canon_column;__u32 canon_datalen;__u32 canon_data;
Signature · 1 line
1.6.1
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Re: [RFC][PATCH 3/3] c/r: [pty 2/2] support for pseudo terminals
In reply to a message not in the archiveThanks for the patches (the first was already in). I'll leave out the change to signed type, though.
Quoted 16 lines · Serge E. Hallyn
All right, I'm not sure how to go about this - i want to have a conversation involving patches without making it seem like I want any of the patches pushed yet :) To get this working on s390, I needed the two attached patches. Then the testcase under
git://git.sr71.net/~hallyn/cr_tests.git
under cr_tests/pty/ passes with your code.I'd still like to get a more invasive approach working where we directly ask the pty code to create the pty with the right index. I'm playing with it right now, but of course having some trouble figuring out what to do for the master end and how best to construct a filp to pass to the main
pty_createfunction. I'll take a few more stabs and send out what I have later (or announce defeat).There is certainly something to be said for the un-invasiveness of your approach (and that it works).
Quoted 7 lines
In either case, we will need to figure out how to deal with devpts namespaces. Perhaps we separately checkpoint a '
devpts_mnt'. It just stores the mountpoint of the mount. At restart, we don't recreate those, we just confirm that the mountpoints still exist. Then, each pty entry has a ref to its devpts mount, and we use the mountpoint to construct ${mountpoint}/ptmx and pass that tofilp_open()or ptmx_create)( to create the pty entry.
Yes, I was thinking along these lines. I think it's very much related to the whole mount-namespaces issues; I guess it's time to address both.
Oren.
Re: [RFC][PATCH 3/3] c/r: [pty 2/2] support for pseudo terminals
In reply to a message not in the archiveQuoted 3 lines · Oren Laadan
Thanks for the patches (the first was already in). I'll leave out the change to signed type, though.
Yup, "oops".
Quoted 25 lines
Quoted 16 lines · Serge E. Hallyn
All right, I'm not sure how to go about this - i want to have a conversation involving patches without making it seem like I want any of the patches pushed yet :) To get this working on s390, I needed the two attached patches. Then the testcase under
git://git.sr71.net/~hallyn/cr_tests.git
under cr_tests/pty/ passes with your code.I'd still like to get a more invasive approach working where we directly ask the pty code to create the pty with the right index. I'm playing with it right now, but of course having some trouble figuring out what to do for the master end and how best to construct a filp to pass to the main
pty_createfunction. I'll take a few more stabs and send out what I have later (or announce defeat).There is certainly something to be said for the un-invasiveness of your approach (and that it works).
Quoted 7 lines
In either case, we will need to figure out how to deal with devpts namespaces. Perhaps we separately checkpoint a '
devpts_mnt'. It just stores the mountpoint of the mount. At restart, we don't recreate those, we just confirm that the mountpoints still exist. Then, each pty entry has a ref to its devpts mount, and we use the mountpoint to construct ${mountpoint}/ptmx and pass that tofilp_open()or ptmx_create)( to create the pty entry.
Quoted 3 lines
Yes, I was thinking along these lines. I think it's very much related to the whole mount-namespaces issues; I guess it's time to address both.
Ooooh, I'm not sure it is :) In fact my approach to devpts should artfully avoid having to address generic mounts namespaces :)
Well, if we *were* to address mountsns now, I'd suggest we simply store meaningful /proc/pid/mountinfo data for each task in the checkpoint image, and just verify it at restart, returning error if they're not the same. That way we can continue to defer the decision on whether mktree or the kernel will restore mounts.
-serge
Re: [RFC][PATCH 3/3] c/r: [pty 2/2] support for pseudo terminals
In reply to a message not in the archiveQuoted 30 lines · Serge E. Hallyn
Quoted 2 lines · Oren Laadan
Thanks for the patches (the first was already in). I'll leave out the change to signed type, though.
Yup, "oops".
Quoted 24 lines
Quoted 23 lines · Serge E. Hallyn
All right, I'm not sure how to go about this - i want to have a conversation involving patches without making it seem like I want any of the patches pushed yet :) To get this working on s390, I needed the two attached patches. Then the testcase under
git://git.sr71.net/~hallyn/cr_tests.git
under cr_tests/pty/ passes with your code.I'd still like to get a more invasive approach working where we directly ask the pty code to create the pty with the right index. I'm playing with it right now, but of course having some trouble figuring out what to do for the master end and how best to construct a filp to pass to the main
pty_createfunction. I'll take a few more stabs and send out what I have later (or announce defeat).There is certainly something to be said for the un-invasiveness of your approach (and that it works).
In either case, we will need to figure out how to deal with devpts namespaces. Perhaps we separately checkpoint a '
devpts_mnt'. It just stores the mountpoint of the mount. At restart, we don't recreate those, we just confirm that the mountpoints still exist. Then, each pty entry has a ref to its devpts mount, and we use the mountpoint to construct ${mountpoint}/ptmx and pass that tofilp_open()or ptmx_create)( to create the pty entry.
Quoted 6 lines
Quoted 3 lines
Yes, I was thinking along these lines. I think it's very much related to the whole mount-namespaces issues; I guess it's time to address both.
Ooooh, I'm not sure it is :) In fact my approach to devpts should artfully avoid having to address generic mounts namespaces :)
lol .. I suppose I misinterpreted then. Perhaps you can take a stab at it ?
Quoted 6 lines
Well, if we *were* to address mountsns now, I'd suggest we simply store meaningful
/proc/pid/mountinfodata for each task in the checkpoint image, and just verify it at restart, returning error if they're not the same. That way we can continue to defer the decision on whether mktree or the kernel will restore mounts.
What is "meaningful" data, and how would you "verify" it ?
At restart the mount data may be substantially (and intentionally) different. For instance, what used to be a local mount at checkpoint may be an NFS mount at restart....
Oren.
Re: [RFC][PATCH 3/3] c/r: [pty 2/2] support for pseudo terminals
In reply to a message not in the archiveQuoted 37 lines · Oren Laadan
Quoted 34 lines · Serge E. Hallyn
Quoted 2 lines · Oren Laadan
Thanks for the patches (the first was already in). I'll leave out the change to signed type, though.
Yup, "oops".
Quoted 27 lines
Quoted 16 lines · Serge E. Hallyn
All right, I'm not sure how to go about this - i want to have a conversation involving patches without making it seem like I want any of the patches pushed yet :) To get this working on s390, I needed the two attached patches. Then the testcase under
git://git.sr71.net/~hallyn/cr_tests.git
under cr_tests/pty/ passes with your code.I'd still like to get a more invasive approach working where we directly ask the pty code to create the pty with the right index. I'm playing with it right now, but of course having some trouble figuring out what to do for the master end and how best to construct a filp to pass to the main
pty_createfunction. I'll take a few more stabs and send out what I have later (or announce defeat).There is certainly something to be said for the un-invasiveness of your approach (and that it works).
Quoted 7 lines
In either case, we will need to figure out how to deal with devpts namespaces. Perhaps we separately checkpoint a '
devpts_mnt'. It just stores the mountpoint of the mount. At restart, we don't recreate those, we just confirm that the mountpoints still exist. Then, each pty entry has a ref to its devpts mount, and we use the mountpoint to construct ${mountpoint}/ptmx and pass that tofilp_open()or ptmx_create)( to create the pty entry.Yes, I was thinking along these lines. I think it's very much related to the whole mount-namespaces issues; I guess it's time to address both.
Quoted 5 lines
Quoted 2 lines
Ooooh, I'm not sure it is :) In fact my approach to devpts should artfully avoid having to address generic mounts namespaces :)
lol .. I suppose I misinterpreted then. Perhaps you can take a stab at it ?
Sure, should be pretty simple. May wait until next week though, if only to wait for comments on the requested_id vs. ptmx_create().
OTOH - if we're going to consider spitting out full mountinfo in the ckpt image (per below), then I'll wait until we've discussed that more too.
Quoted 7 lines
Quoted 5 lines
Well, if we *were* to address mountsns now, I'd suggest we simply store meaningful
/proc/pid/mountinfodata for each task in the checkpoint image, and just verify it at restart, returning error if they're not the same. That way we can continue to defer the decision on whether mktree or the kernel will restore mounts.What is "meaningful" data, and how would you "verify" it ?
Meaningful data is, for each task,
mount ns id
for each mount,
mount source, targets, types, propagation (peer group and relation to it).
Also for the container init, whether its netns is shared with its parent, and any mounts which are new in it over its parent.
Quoted 3 lines
At restart the mount data may be substantially (and intentionally) different. For instance, what used to be a local mount at checkpoint may be an NFS mount at restart....
Yup. OTOH if a task in the container did
'mount --bind dataset.bak/b dataset/a'
then that should be safe to repeat.
Whereas the nfs mount presumably is for the whole job's fs, which likely was not mounted by the job itself.
-serge