Commit 380df8a6 authored by Andrei Vagin's avatar Andrei Vagin Committed by Andrew Vagin

inventory: save dump_uptime for criu dump if track_mem is set

A set of images from criu dump can be used as a previous point, when we
are doing snapshots. In this case, each point contains a full set of
images.

https://github.com/checkpoint-restore/criu/issues/479

v2: return -1 if invertory_save_uptime failed

Cc: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
Reviewed-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent c49eab36
......@@ -1472,10 +1472,14 @@ static int cr_pre_dump_finish(int ret)
* Restore registers for tasks only. The threads have not been
* infected. Therefore, the thread register sets have not been changed.
*/
if (arch_set_thread_regs(root_item, false) < 0)
ret = arch_set_thread_regs(root_item, false);
if (ret)
goto err;
ret = invertory_save_uptime(&he);
if (ret)
goto err;
prepare_inventory_pre_dump(&he);
pstree_switch_state(root_item, TASK_ALIVE);
timing_stop(TIME_FROZEN);
......@@ -1882,6 +1886,10 @@ int cr_dump_tasks(pid_t pid)
if (ret)
goto err;
ret = invertory_save_uptime(&he);
if (ret)
goto err;
ret = write_img_inventory(&he);
if (ret)
goto err;
......
......@@ -106,14 +106,20 @@ int write_img_inventory(InventoryEntry *he)
return 0;
}
void prepare_inventory_pre_dump(InventoryEntry *he)
int invertory_save_uptime(InventoryEntry *he)
{
pr_info("Perparing image inventory for pre-dump (version %u)\n", CRTOOLS_IMAGES_V1);
if (!opts.track_mem)
return 0;
he->img_version = CRTOOLS_IMAGES_V1_1;
/*
* dump_uptime is used to detect whether a process was handled
* before or it is a new process with the same pid.
*/
if (parse_uptime(&he->dump_uptime))
return -1;
if (!parse_uptime(&he->dump_uptime))
he->has_dump_uptime = true;
he->has_dump_uptime = true;
return 0;
}
InventoryEntry *get_parent_inventory(void)
......
......@@ -12,7 +12,7 @@
extern int check_img_inventory(void);
extern int write_img_inventory(InventoryEntry *he);
extern void prepare_inventory_pre_dump(InventoryEntry *he);
extern int invertory_save_uptime(InventoryEntry *he);
extern InventoryEntry *get_parent_inventory(void);
extern int prepare_inventory(InventoryEntry *he);
struct pprep_head {
......
......@@ -299,6 +299,12 @@ static int detect_pid_reuse(struct pstree_item *item,
unsigned long long tps; /* ticks per second */
int ret;
if (!parent_ie) {
pr_err("Pid-reuse detection failed: no parent inventory, " \
"check warnings in get_parent_stats\n");
return -1;
}
tps = sysconf(_SC_CLK_TCK);
if (tps == -1) {
pr_perror("Failed to get clock ticks via sysconf");
......@@ -312,12 +318,6 @@ static int detect_pid_reuse(struct pstree_item *item,
return -1;
}
if (!parent_ie) {
pr_err("Pid-reuse detection failed: no parent inventory, " \
"check warnings in get_parent_stats\n");
return -1;
}
dump_ticks = parent_ie->dump_uptime/(USEC_PER_SEC/tps);
if (pps->start_time >= dump_ticks) {
......
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