mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
criu: dump and restore a thread name
Reported-by: 志平 林 <larry.lin@outlook.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
682610a9fa
commit
7842fa1df2
@@ -716,6 +716,9 @@ int dump_thread_core(int pid, CoreEntry *core, const struct parasite_dump_thread
|
|||||||
tc->has_pdeath_sig = true;
|
tc->has_pdeath_sig = true;
|
||||||
tc->pdeath_sig = ti->pdeath_sig;
|
tc->pdeath_sig = ti->pdeath_sig;
|
||||||
}
|
}
|
||||||
|
tc->comm = xstrdup(ti->comm);
|
||||||
|
if (tc->comm == NULL)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = seccomp_dump_thread(pid, tc);
|
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))
|
if (construct_sigframe(sigframe, sigframe, blkset, tcore))
|
||||||
goto err;
|
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)
|
if (thread_args[i].pid != pid)
|
||||||
core_entry__free_unpacked(tcore, NULL);
|
core_entry__free_unpacked(tcore, NULL);
|
||||||
|
|
||||||
|
@@ -170,6 +170,7 @@ struct parasite_dump_thread {
|
|||||||
tls_t tls;
|
tls_t tls;
|
||||||
stack_t sas;
|
stack_t sas;
|
||||||
int pdeath_sig;
|
int pdeath_sig;
|
||||||
|
char comm[TASK_COMM_LEN];
|
||||||
struct parasite_dump_creds creds[0];
|
struct parasite_dump_creds creds[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -110,6 +110,8 @@ struct thread_restore_args {
|
|||||||
void *seccomp_filters_data;
|
void *seccomp_filters_data;
|
||||||
unsigned int seccomp_filters_n;
|
unsigned int seccomp_filters_n;
|
||||||
bool seccomp_force_tsync;
|
bool seccomp_force_tsync;
|
||||||
|
|
||||||
|
char comm[TASK_COMM_LEN];
|
||||||
} __aligned(64);
|
} __aligned(64);
|
||||||
|
|
||||||
typedef long (*thread_restore_fcall_t) (struct thread_restore_args *args);
|
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);
|
arch_get_tls(&ti->tls);
|
||||||
ret = sys_prctl(PR_GET_TID_ADDRESS, (unsigned long) &ti->tid_addr, 0, 0, 0);
|
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;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = sys_sigaltstack(NULL, &ti->sas);
|
ret = sys_sigaltstack(NULL, &ti->sas);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
pr_err("Unable to get signal stack context: %d\n", ret);
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = sys_prctl(PR_GET_PDEATHSIG, (unsigned long)&ti->pdeath_sig, 0, 0, 0);
|
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;
|
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);
|
ret = dump_creds(ti->creds);
|
||||||
out:
|
out:
|
||||||
|
@@ -554,6 +554,12 @@ long __export_restore_thread(struct thread_restore_args *args)
|
|||||||
if (restore_thread_common(args))
|
if (restore_thread_common(args))
|
||||||
goto core_restore_end;
|
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());
|
pr_info("%ld: Restored\n", sys_gettid());
|
||||||
|
|
||||||
restore_finish_stage(task_entries_local, CR_STATE_RESTORE);
|
restore_finish_stage(task_entries_local, CR_STATE_RESTORE);
|
||||||
|
@@ -86,6 +86,8 @@ message thread_core_entry {
|
|||||||
|
|
||||||
optional seccomp_mode seccomp_mode = 11;
|
optional seccomp_mode seccomp_mode = 11;
|
||||||
optional uint32 seccomp_filter = 12;
|
optional uint32 seccomp_filter = 12;
|
||||||
|
|
||||||
|
optional string comm = 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
message task_rlimits_entry {
|
message task_rlimits_entry {
|
||||||
|
Reference in New Issue
Block a user