2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

kcmp: Dump task's objects shared with CLONE_ flags

Just dump their IDs and check they are not shared. For future.
IO and SEMUNDO is not there since tasks may have NO such objects
and currently we cannot detect whether they have them equal or
both don't have.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2012-04-09 18:02:00 +04:00
parent 3386535491
commit 1d6578bbd5
3 changed files with 75 additions and 1 deletions

View File

@@ -21,7 +21,7 @@
#include "types.h"
#include "list.h"
#include "file-ids.h"
#include "kcmp-ids.h"
#include "compiler.h"
#include "crtools.h"
#include "syscall.h"
@@ -853,6 +853,51 @@ static int dump_task_core(struct core_entry *core, int fd_core)
return write_img(fd_core, core);
}
static DECLARE_KCMP_TREE(vm_tree, KCMP_VM);
static DECLARE_KCMP_TREE(fs_tree, KCMP_FS);
static DECLARE_KCMP_TREE(files_tree, KCMP_FILES);
static DECLARE_KCMP_TREE(sighand_tree, KCMP_SIGHAND);
static int dump_task_kobj_ids(pid_t pid, struct core_entry *core)
{
int new;
struct kid_elem elem;
elem.pid = pid;
elem.idx = 0; /* really 0 for all */
elem.genid = 0; /* FIXME optimize */
new = 0;
core->ids.vm_id = kid_generate_gen(&vm_tree, &elem, &new);
if (!core->ids.vm_id || !new) {
pr_err("Can't make VM id for %d\n", pid);
return -1;
}
new = 0;
core->ids.fs_id = kid_generate_gen(&fs_tree, &elem, &new);
if (!core->ids.fs_id || !new) {
pr_err("Can't make FS id for %d\n", pid);
return -1;
}
new = 0;
core->ids.files_id = kid_generate_gen(&files_tree, &elem, &new);
if (!core->ids.files_id || !new) {
pr_err("Can't make FILES id for %d\n", pid);
return -1;
}
new = 0;
core->ids.sighand_id = kid_generate_gen(&sighand_tree, &elem, &new);
if (!core->ids.sighand_id || !new) {
pr_err("Can't make IO id for %d\n", pid);
return -1;
}
return 0;
}
static int dump_task_core_all(pid_t pid, const struct proc_pid_stat *stat,
const struct parasite_dump_misc *misc, const struct parasite_ctl *ctl,
const struct cr_fdset *cr_fdset)
@@ -868,6 +913,10 @@ static int dump_task_core_all(pid_t pid, const struct proc_pid_stat *stat,
if (!core)
goto err;
ret = dump_task_kobj_ids(pid, core);
if (ret)
goto err_free;
pr_info("Dumping GP/FPU registers ... ");
ret = get_task_regs(pid, core, ctl);
if (ret)

View File

@@ -479,6 +479,22 @@ err:
return;
}
static void show_core_ids(int fd)
{
struct core_ids_entry cie;
lseek(fd, GET_FILE_OFF(struct core_entry, ids), SEEK_SET);
if (read_img(fd, &cie) < 0)
goto err;
pr_msg("\tVM: %x\n", cie.vm_id);
pr_msg("\tFS: %x\n", cie.fs_id);
pr_msg("\tFILES: %x\n", cie.files_id);
pr_msg("\tSIGHAND: %x\n", cie.sighand_id);
err:
return;
}
void show_core(int fd_core, struct cr_options *o)
{
struct stat stat;
@@ -498,6 +514,7 @@ void show_core(int fd_core, struct cr_options *o)
show_core_regs(fd_core);
show_core_rest(fd_core);
show_core_ids(fd_core);
out:
pr_img_tail(CR_FD_CORE);
}

View File

@@ -370,12 +370,20 @@ struct mm_entry {
u32 exe_file_id;
} __packed;
struct core_ids_entry {
u32 vm_id;
u32 files_id;
u32 fs_id;
u32 sighand_id;
} __packed;
struct core_entry {
union {
struct {
struct image_header header;
struct task_core_entry tc;
struct ckpt_arch_entry arch;
struct core_ids_entry ids;
u64 clear_tid_address;
};
u8 __core_pad[CKPT_CORE_SIZE];