[CRIU] [PATCH 2/9] fd: Dynamically allocate args for the array of fds to drain

Pavel Emelyanov xemul at parallels.com
Fri Mar 1 11:02:34 EST 2013


Just make use of previous patch. The creds dumping args are tuned to
fit one page (minimal static args size).

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>

---
 cr-dump.c                  |  2 +-
 include/parasite-syscall.h |  3 ++-
 include/parasite.h         |  4 ++--
 parasite-syscall.c         | 13 +++++++++----
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 4c3d064..0486327 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1281,7 +1281,7 @@ static int dump_one_task(struct pstree_item *item)
 	}
 
 	ret = -1;
-	parasite_ctl = parasite_infect_seized(pid, item, &vma_area_list);
+	parasite_ctl = parasite_infect_seized(pid, item, &vma_area_list, dfds);
 	if (!parasite_ctl) {
 		pr_err("Can't infect (pid: %d) with parasite\n", pid);
 		goto err;
diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index ee5743e..ca7ff68 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -53,7 +53,8 @@ struct pstree_item;
 extern int parasite_cure_seized(struct parasite_ctl *ctl, struct pstree_item *item);
 extern struct parasite_ctl *parasite_infect_seized(pid_t pid,
 						   struct pstree_item *item,
-						   struct list_head *vma_area_list);
+						   struct list_head *vma_area_list,
+						   struct parasite_drain_fd *dfds);
 extern struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct list_head *vma_area_list);
 extern int parasite_map_exchange(struct parasite_ctl *ctl, unsigned long size);
 
diff --git a/include/parasite.h b/include/parasite.h
index 66a559e..8badb5a 100644
--- a/include/parasite.h
+++ b/include/parasite.h
@@ -2,7 +2,7 @@
 #define __CR_PARASITE_H__
 
 #define PARASITE_STACK_SIZE	(16 << 10)
-#define PARASITE_ARG_SIZE_MIN	( 1 << 13)
+#define PARASITE_ARG_SIZE_MIN	( 1 << 12)
 
 #define PARASITE_MAX_SIZE	(64 << 10)
 
@@ -87,7 +87,7 @@ struct parasite_dump_misc {
 	u32 umask;
 };
 
-#define PARASITE_MAX_GROUPS	(PAGE_SIZE / sizeof(unsigned int))
+#define PARASITE_MAX_GROUPS	(PAGE_SIZE / sizeof(unsigned int) - 2 * sizeof(unsigned))
 
 struct parasite_dump_creds {
 	unsigned int		secbits;
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 03b5546..2f29bc6 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -794,12 +794,17 @@ int parasite_map_exchange(struct parasite_ctl *ctl, unsigned long size)
 	return 0;
 }
 
-static unsigned long parasite_args_size(void)
+static unsigned long parasite_args_size(struct parasite_drain_fd *dfds)
 {
-	return PARASITE_ARG_SIZE_MIN;
+	unsigned long size = PARASITE_ARG_SIZE_MIN;
+
+	size = max(size, (unsigned long)drain_fds_size(dfds));
+
+	return size;
 }
 
-struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item, struct list_head *vma_area_list)
+struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
+		struct list_head *vma_area_list, struct parasite_drain_fd *dfds)
 {
 	int ret;
 	struct parasite_ctl *ctl;
@@ -815,7 +820,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 	 * without using ptrace at all.
 	 */
 
-	ctl->args_size = parasite_args_size();
+	ctl->args_size = parasite_args_size(dfds);
 	ret = parasite_map_exchange(ctl, parasite_size + ctl->args_size);
 	if (ret)
 		goto err_restore;
-- 
1.7.11.7


More information about the CRIU mailing list