c/r: Add UTS support
This is the latest version of my patch set with changes in support of feedback on version 6.
A message that is not in the archive (sent off-list or not yet received): 1239033956-25898-1-git-send-email-danms-r/[email protected]
PATCH 1/3 Make cr_may_checkpoint_task() check each namespace individually
--- checkpoint/checkpoint.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
checkpoint/checkpoint.c +13 -2
@@ -302,8 +302,19 @@ static int cr_may_checkpoint_task(struct task_struct *t, struct cr_ctx *ctx)if (t != current && !frozen (t))return -EBUSY ; -/* FIXME: change this for nested containers */ -if (task_nsproxy (t) != ctx->root_nsproxy) +if (task_nsproxy (t)->uts_ns != ctx->root_nsproxy->uts_ns) +return -EPERM ; + +if (task_nsproxy (t)->ipc_ns != ctx->root_nsproxy->ipc_ns) +return -EPERM ; + +if (task_nsproxy (t)->mnt_ns != ctx->root_nsproxy->mnt_ns) +return -EPERM ; + +if (task_nsproxy (t)->pid_ns != ctx->root_nsproxy->pid_ns) +return -EPERM ; + +if (task_nsproxy (t)->net_ns != ctx->root_nsproxy->net_ns)return -EPERM ;return 0 ;
Signature · 1 line
1.5.6.3
PATCH 2/3 c/r: Add UTS support (v7)
In reply to a message not in the archiveThis patch adds a "phase" of checkpoint that saves out information about any namespaces the task(s) may have. Do this by tracking the namespace objects of the tasks and making sure that tasks with the same namespace that follow get properly referenced in the checkpoint stream.
I tested this with single and multiple task restore, on top of Oren's v13 tree.
Changes:
- Remove the kernel restore path
- Punt on nested namespaces
- Use __NEW_UTS_LEN in nodename and domainname buffers
- Add a note to Documentation/checkpoint/internals.txt to indicate where in the save/restore process the UTS information is kept
- Store (and track) the objref of the namespace itself instead of the nsproxy (based on comments from Dave on IRC)
- Remove explicit check for non-root nsproxy
- Store the nodename and domainname lengths and use cr_write_string() to store the actual name strings
- Catch failure of cr_obj_add_ptr() in cr_write_namespaces()
- Remove "types" bitfield and use the "is this new" flag to determine whether or not we should write out a new ns descriptor
- Replace kernel restore path
- Move the namespace information to be directly after the task information record
- Update Documentation to reflect new location of namespace info
- Support checkpoint and restart of nested UTS namespaces
- Check nodename and domainname length on restart (!)
- memset() the nodename and domainname buffers on restart
- Change uts to newuts in cr_write_namespaces()
- Check return values of cr_hbuf_get()
--- Documentation/checkpoint/internals.txt | 1 + checkpoint/Makefile | 1 + checkpoint/checkpoint.c | 73 ++++++++++++++++++++- checkpoint/objhash.c | 7 ++ checkpoint/restart.c | 111 ++++++++++++++++++++++++++++++++ include/linux/checkpoint.h | 1 + include/linux/checkpoint_hdr.h | 11 +++ 7 files changed, 202 insertions(+), 3 deletions(-)
Documentation/checkpoint/internals.txt +1 -0
@@ -17,6 +17,7 @@ The order of operations, both save and restore, is as follows: -> thread state: elements of thread_struct and thread_info -> CPU state: registers etc, including FPU -> memory state: memory address space layout and contents + -> namespace information -> filesystem state: [TBD] filesystem namespace state, chroot, cwd, etc -> files state: open file descriptors and their state -> signals state: [TBD] pending signals and signal handling state
checkpoint/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_CHECKPOINT) += sys.o checkpoint.o restart.o objhash.o \ ckpt_mem.o rstr_mem.o ckpt_file.o rstr_file.o +EXTRA_CFLAGS += -DDEBUG
checkpoint/checkpoint.c +70 -3
91 lines not on this page · raw message
checkpoint/objhash.c +7 -0
@@ -12,6 +12,7 @@#include <linux/file.h> #include <linux/hash.h> #include <linux/checkpoint.h> +#include <linux/utsname.h> struct cr_objref {int objref;
@@ -38,6 +39,9 @@ static void cr_obj_ref_drop(struct cr_objref *obj)case CR_OBJ_INODE :iput ((struct inode *) obj->ptr);break ; +case CR_OBJ_UTSNS : +put_uts_ns ((struct uts_namespace *) obj->ptr); +break ;default :BUG (); }
@@ -55,6 +59,9 @@ static int cr_obj_ref_grab(struct cr_objref *obj)if (!igrab ((struct inode *) obj->ptr)) ret = -EBADF ;break ; +case CR_OBJ_UTSNS : +get_uts_ns ((struct uts_namespace *) obj->ptr); +break ;default :BUG (); }
checkpoint/restart.c +111 -0
129 lines not on this page · raw message
include/linux/checkpoint.h +1 -0
@@ -75,6 +75,7 @@ extern void cr_ctx_put(struct cr_ctx *ctx);enum {CR_OBJ_FILE =1 ,CR_OBJ_INODE , +CR_OBJ_UTSNS ,CR_OBJ_MAX };
include/linux/checkpoint_hdr.h +11 -0
@@ -48,6 +48,8 @@ enum {CR_HDR_TASK ,CR_HDR_THREAD ,CR_HDR_CPU , +CR_HDR_NS , +CR_HDR_UTSNS ,CR_HDR_MM =201 , CR_HDR_VMA,
@@ -184,4 +186,13 @@ struct cr_hdr_fd_pipe {__s32 nr_bufs; } __attribute__((aligned(8))); +struct cr_hdr_namespaces { +__u32 uts_ref; +}; + +struct cr_hdr_utsns { +__u32 nodename_len; +__u32 domainname_len; +}; +#endif /* _CHECKPOINT_CKPT_HDR_H_ */
Signature · 1 line
1.5.6.3
PATCH 3/3 Stub implementation of IPC namespace c/r (v3)
In reply to a message not in the archiveChanges:
- Update to match UTS changes
- Change ipc to newipc
- Check return value of cr_hbuf_get()
--- checkpoint/checkpoint.c | 30 ++++++++++++++++++++++++ checkpoint/objhash.c | 7 +++++ checkpoint/restart.c | 49 ++++++++++++++++++++++++++++++++++++++++ include/linux/checkpoint.h | 1 + include/linux/checkpoint_hdr.h | 6 +++++ 5 files changed, 93 insertions(+), 0 deletions(-)
checkpoint/checkpoint.c +30 -0
@@ -243,6 +243,24 @@ static int cr_write_utsns(struct cr_ctx *ctx, struct new_utsname *name)return ret; } +static int cr_write_ipcns (struct cr_ctx *ctx,struct ipc_namespace *ipc) +{ +struct cr_hdr h; +struct cr_hdr_ipcns *hh =cr_hbuf_get (ctx,sizeof (*hh)); +int ret; + +if (!hh) +return -ENOMEM ; + + h.type =CR_HDR_IPCNS ; + h.len =sizeof (*hh); + + ret =cr_write_obj (ctx, &h, hh); +cr_hbuf_put (ctx,sizeof (*hh)); + +return ret; +} +static int cr_write_namespaces (struct cr_ctx *ctx,struct task_struct *t) {struct cr_hdr h;
@@ -250,6 +268,7 @@ static int cr_write_namespaces(struct cr_ctx *ctx, struct task_struct *t)struct nsproxy *nsp = t->nsproxy;int ret;int newuts; +int newipc;if (!hh)return -ENOMEM ;
@@ -262,6 +281,11 @@ static int cr_write_namespaces(struct cr_ctx *ctx, struct task_struct *t)if (newuts <0 ) goto out; + newipc =cr_obj_add_ptr (ctx, nsp->ipc_ns, &hh->ipc_ref, +CR_OBJ_IPCNS ,0 ); +if (newipc <0 ) + goto out; + ret =cr_write_obj (ctx, &h, hh);if (ret) goto out;
@@ -272,6 +296,12 @@ static int cr_write_namespaces(struct cr_ctx *ctx, struct task_struct *t) goto out; } +if (newipc) { + ret =cr_write_ipcns (ctx, nsp->ipc_ns); +if (ret <0 ) + goto out; + } +/* FIXME: Write other namespaces here */ out:cr_hbuf_put (ctx,sizeof (*hh));
checkpoint/objhash.c +7 -0
@@ -13,6 +13,7 @@#include <linux/hash.h> #include <linux/checkpoint.h> #include <linux/utsname.h> +#include <linux/ipc_namespace.h> struct cr_objref {int objref;
@@ -42,6 +43,9 @@ static void cr_obj_ref_drop(struct cr_objref *obj)case CR_OBJ_UTSNS :put_uts_ns ((struct uts_namespace *) obj->ptr);break ; +case CR_OBJ_IPCNS : +put_ipc_ns ((struct ipc_namespace *) obj->ptr); +break ;default :BUG (); }
@@ -62,6 +66,9 @@ static int cr_obj_ref_grab(struct cr_objref *obj)case CR_OBJ_UTSNS :get_uts_ns ((struct uts_namespace *) obj->ptr);break ; +case CR_OBJ_IPCNS : +get_ipc_ns ((struct ipc_namespace *) obj->ptr); +break ;default :BUG (); }
checkpoint/restart.c +49 -0
67 lines not on this page · raw message
include/linux/checkpoint.h +1 -0
@@ -76,6 +76,7 @@ enum {CR_OBJ_FILE =1 ,CR_OBJ_INODE ,CR_OBJ_UTSNS , +CR_OBJ_IPCNS , CR_OBJ_MAX };
include/linux/checkpoint_hdr.h +6 -0
@@ -50,6 +50,7 @@ enum {CR_HDR_CPU ,CR_HDR_NS ,CR_HDR_UTSNS , +CR_HDR_IPCNS ,CR_HDR_MM =201 , CR_HDR_VMA,
@@ -188,6 +189,7 @@ struct cr_hdr_fd_pipe {struct cr_hdr_namespaces {__u32 uts_ref; +__u32 ipc_ref; };struct cr_hdr_utsns {
@@ -195,4 +197,8 @@ struct cr_hdr_utsns { __u32 domainname_len; }; +struct cr_hdr_ipcns { +/* FIXME: Fill this in */ +}; +#endif /* _CHECKPOINT_CKPT_HDR_H_ */
Signature · 1 line
1.5.6.3
Hmm.. I already integrated the previous version to the current dev branch (see branch ckpt-v14-rc3-dev ; there are several changed untested so I didn't release yet, but you can take a look at the three corresponding patches.
BTW, in branch v14-rc3-dev of the userspace tool there is a version of 'mktree' with the full algorithm for userspace task creation.
Oren.
Quoted 9 lines · Dan Smith
This is the latest version of my patch set with changes in support of feedback on version 6.
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
A message that is not in the archive (sent off-list or not yet received): [email protected]
OL> Hmm.. I already integrated the previous version to the current dev OL> branch (see branch ckpt-v14-rc3-dev ; there are several changed OL> untested so I didn't release yet, but you can take a look at the OL> three corresponding patches.
Okay, I can send a delta against rc3.
OL> BTW, in branch v14-rc3-dev of the userspace tool there is a OL> version of 'mktree' with the full algorithm for userspace task OL> creation.
Cool.
Signature · 3 lines
Dan Smith IBM Linux Technology Center email: danms-r/[email protected]