[CRIU] [PATCH 03/24] parasite: Extend tid_state_s structure
Andrey Vagin
avagin at openvz.org
Wed May 22 16:08:04 EDT 2013
From: Cyrill Gorcunov <gorcunov at openvz.org>
In daemon mode each thread will require own stack
to run on, thus add @stack member.
Also we will need an @real member to identify each
thread uniquely, @real stands here for "real" pid
which we refer to in main crtools module.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
include/parasite.h | 1 +
parasite-syscall.c | 5 +++++
pie/parasite.c | 9 ++++++---
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/include/parasite.h b/include/parasite.h
index d3fa28a..2c4965b 100644
--- a/include/parasite.h
+++ b/include/parasite.h
@@ -47,6 +47,7 @@ struct parasite_init_args {
struct sockaddr_un p_addr;
int nr_threads;
+ pid_t real;
};
struct parasite_log_args {
diff --git a/parasite-syscall.c b/parasite-syscall.c
index b7891fe..68caf32 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -296,6 +296,7 @@ static int parasite_init(struct parasite_ctl *ctl, pid_t pid, int nr_threads)
args->h_addr_len = gen_parasite_saddr(&args->h_addr, getpid());
args->p_addr_len = gen_parasite_saddr(&args->p_addr, pid);
args->nr_threads = nr_threads;
+ args->real = pid;
if (sock == -1) {
int rst = -1;
@@ -532,12 +533,16 @@ int parasite_get_proc_fd_seized(struct parasite_ctl *ctl)
int parasite_init_threads_seized(struct parasite_ctl *ctl, struct pstree_item *item)
{
+ struct parasite_init_args *args;
int ret = 0, i;
+ args = parasite_args(ctl, struct parasite_init_args);
+
for (i = 0; i < item->nr_threads; i++) {
if (item->pid.real == item->threads[i].real)
continue;
+ args->real = item->threads[i].real;
ret = parasite_execute_trap_by_pid(PARASITE_CMD_INIT_THREAD, ctl,
item->threads[i].real);
if (ret) {
diff --git a/pie/parasite.c b/pie/parasite.c
index 7d505ec..dcb4a60 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -17,9 +17,11 @@
static int tsock = -1;
static struct tid_state_s {
+ pid_t real;
pid_t tid;
bool use_sig_blocked;
k_rtsigset_t sig_blocked;
+ unsigned char stack[PARASITE_STACK_SIZE] __aligned(8);
} *tid_state;
static unsigned int nr_tid_state;
@@ -212,7 +214,7 @@ static int dump_thread(struct parasite_dump_thread *args)
return 0;
}
-static int init_thread(void)
+static int init_thread(struct parasite_init_args *args)
{
k_rtsigset_t to_block;
int ret;
@@ -227,6 +229,7 @@ static int init_thread(void)
if (ret >= 0)
tid_state[next_tid_state].use_sig_blocked = true;
tid_state[next_tid_state].tid = sys_gettid();
+ tid_state[next_tid_state].real = args->real;
next_tid_state++;
@@ -264,7 +267,7 @@ static int init(struct parasite_init_args *args)
nr_tid_state = args->nr_threads;
- ret = init_thread();
+ ret = init_thread(args);
if (ret < 0)
return ret;
@@ -436,7 +439,7 @@ int __used parasite_service(unsigned int cmd, void *args)
case PARASITE_CMD_INIT:
return init(args);
case PARASITE_CMD_INIT_THREAD:
- return init_thread();
+ return init_thread(args);
case PARASITE_CMD_FINI:
return fini();
case PARASITE_CMD_FINI_THREAD:
--
1.8.2
More information about the CRIU
mailing list