[CRIU] [PATCH 18/21] dump: reseve space and construc sigframes for parasites

Andrey Vagin avagin at openvz.org
Fri May 24 08:20:21 EDT 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/parasite-syscall.h |  2 ++
 parasite-syscall.c         | 17 +++++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index ac3bc3f..6ad61c8 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -16,6 +16,8 @@ struct parasite_thread_ctl
 	bool			use_sig_blocked;
 
 	void			*rstack;
+	struct rt_sigframe	*sigframe;
+	struct rt_sigframe	*rsigframe;				/* address in a parasite */
 };
 
 /* parasite control block */
diff --git a/parasite-syscall.c b/parasite-syscall.c
index e206fb9..d62e9fd 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -23,14 +23,16 @@
 #include "pstree.h"
 #include "net.h"
 #include "mem.h"
+#include "restorer.h"
 
 #include <string.h>
 #include <stdlib.h>
 
 #include "asm/parasite-syscall.h"
 #include "asm/dump.h"
+#include "asm/restorer.h"
 
-#define parasite_size		(round_up(sizeof(parasite_blob), sizeof(long)))
+#define parasite_size		(round_up(sizeof(parasite_blob), PAGE_SIZE))
 
 static int can_run_syscall(unsigned long ip, unsigned long start, unsigned long end)
 {
@@ -947,7 +949,7 @@ static unsigned long parasite_args_size(struct vm_area_list *vmas, struct parasi
 		size = max(size, (unsigned long)drain_fds_size(dfds));
 	size = max(size, (unsigned long)dump_pages_args_size(vmas));
 
-	return size;
+	return round_up(size, PAGE_SIZE);
 }
 
 struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
@@ -975,6 +977,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 
 	ctl->args_size = parasite_args_size(vma_area_list, dfds);
 	ret = parasite_map_exchange(ctl, parasite_size + ctl->args_size +
+					 item->nr_threads * RESTORE_STACK_SIGFRAME +
 					 item->nr_threads * PARASITE_STACK_SIZE);
 	if (ret)
 		goto err_restore;
@@ -991,8 +994,11 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 	for (i = 0; i < item->nr_threads; i++) {
 		struct parasite_thread_ctl *thread = &ctl->threads[i];
 
-		thread->rstack = ctl->remote_map + p;
-		p += PARASITE_STACK_SIZE;
+		thread->rstack		= ctl->remote_map + p;
+		thread->rsigframe	= ctl->remote_map + p + PARASITE_STACK_SIZE;
+		thread->sigframe	= ctl->local_map  + p + PARASITE_STACK_SIZE;
+
+		p += PARASITE_STACK_SIZE + RESTORE_STACK_SIGFRAME;
 	}
 
 	ret = parasite_init(ctl, pid, item->nr_threads);
@@ -1031,6 +1037,9 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 				&thread->sig_blocked, sizeof(k_rtsigset_t));
 			item->core[i]->thread_core->has_blk_sigset = true;
 		}
+
+		if (construct_sigframe(thread->sigframe, thread->rsigframe, item->core[i]))
+			goto err_restore;
 	}
 
 	return ctl;
-- 
1.8.2



More information about the CRIU mailing list