[CRIU] [PATCH 19/24] dump: reseve space and construc sigframes for parasites

Andrey Vagin avagin at openvz.org
Wed May 22 16:08:20 EDT 2013


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

diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index e4b0618..ef500c9 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -13,6 +13,9 @@ struct parasite_thread_ctl
 
 	k_rtsigset_t		sig_blocked;
 	bool			use_sig_blocked;
+
+	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 af21184..0a4df22 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)
 {
@@ -946,7 +948,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,
@@ -972,10 +974,22 @@ 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);
+	ret = parasite_map_exchange(ctl, parasite_size +
+				ctl->args_size +
+				item->nr_threads * RESTORE_STACK_SIGFRAME);
 	if (ret)
 		goto err_restore;
 
+	for (i = 0; i < item->nr_threads; i++) {
+		struct parasite_thread_ctl *thread = &ctl->threads[i];
+
+		thread->sigframe = ctl->local_map + parasite_size + ctl->args_size + i * RESTORE_STACK_SIGFRAME;
+		thread->rsigframe = ctl->remote_map + parasite_size + ctl->args_size + i * RESTORE_STACK_SIGFRAME;
+
+		if (construct_sigframe(thread->sigframe, thread->rsigframe, item->core[i]))
+			goto err_restore;
+	}
+
 	pr_info("Putting parasite blob into %p->%p\n", ctl->local_map, ctl->remote_map);
 	memcpy(ctl->local_map, parasite_blob, sizeof(parasite_blob));
 
-- 
1.8.2



More information about the CRIU mailing list