Commit 7842fa1d authored by Andrei Vagin's avatar Andrei Vagin Committed by Andrei Vagin

criu: dump and restore a thread name

Reported-by: 's avatar志平 林 <larry.lin@outlook.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 682610a9
......@@ -716,6 +716,9 @@ int dump_thread_core(int pid, CoreEntry *core, const struct parasite_dump_thread
tc->has_pdeath_sig = true;
tc->pdeath_sig = ti->pdeath_sig;
}
tc->comm = xstrdup(ti->comm);
if (tc->comm == NULL)
return -1;
}
if (!ret)
ret = seccomp_dump_thread(pid, tc);
......
......@@ -3461,6 +3461,11 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
if (construct_sigframe(sigframe, sigframe, blkset, tcore))
goto err;
if (thread_args[i].comm)
strncpy(thread_args[i].comm, tcore->thread_core->comm, TASK_COMM_LEN);
else
strncpy(thread_args[i].comm, core->tc->comm, TASK_COMM_LEN);
if (thread_args[i].pid != pid)
core_entry__free_unpacked(tcore, NULL);
......
......@@ -170,6 +170,7 @@ struct parasite_dump_thread {
tls_t tls;
stack_t sas;
int pdeath_sig;
char comm[TASK_COMM_LEN];
struct parasite_dump_creds creds[0];
};
......
......@@ -110,6 +110,8 @@ struct thread_restore_args {
void *seccomp_filters_data;
unsigned int seccomp_filters_n;
bool seccomp_force_tsync;
char comm[TASK_COMM_LEN];
} __aligned(64);
typedef long (*thread_restore_fcall_t) (struct thread_restore_args *args);
......
......@@ -172,16 +172,28 @@ static int dump_thread_common(struct parasite_dump_thread *ti)
arch_get_tls(&ti->tls);
ret = sys_prctl(PR_GET_TID_ADDRESS, (unsigned long) &ti->tid_addr, 0, 0, 0);
if (ret)
if (ret) {
pr_err("Unable to get the clear_child_tid address: %d\n", ret);
goto out;
}
ret = sys_sigaltstack(NULL, &ti->sas);
if (ret)
if (ret) {
pr_err("Unable to get signal stack context: %d\n", ret);
goto out;
}
ret = sys_prctl(PR_GET_PDEATHSIG, (unsigned long)&ti->pdeath_sig, 0, 0, 0);
if (ret)
if (ret) {
pr_err("Unable to get the parent death signal: %d\n", ret);
goto out;
}
ret = sys_prctl(PR_GET_NAME, (unsigned long) &ti->comm, 0, 0, 0);
if (ret) {
pr_err("Unable to get the thread name: %d\n", ret);
goto out;
}
ret = dump_creds(ti->creds);
out:
......
......@@ -554,6 +554,12 @@ long __export_restore_thread(struct thread_restore_args *args)
if (restore_thread_common(args))
goto core_restore_end;
ret = sys_prctl(PR_SET_NAME, (unsigned long) &args->comm, 0, 0, 0);
if (ret) {
pr_err("Unable to set a thread name: %d\n", ret);
goto core_restore_end;
}
pr_info("%ld: Restored\n", sys_gettid());
restore_finish_stage(task_entries_local, CR_STATE_RESTORE);
......
......@@ -86,6 +86,8 @@ message thread_core_entry {
optional seccomp_mode seccomp_mode = 11;
optional uint32 seccomp_filter = 12;
optional string comm = 13;
}
message task_rlimits_entry {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment