mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
inventory: save uptime to know when dump had happened
We want to use a simple fact: If we have an alive process in a pstree we want to dump, and a starttime of that process is less than pre-dump's timestamp (taken while all processes were freezed), then these exact process existed (100% sure) at the time of these pre-dump and the process' memory was dumped in images. So save inventory image on pre-dump and put there an uptime. https://jira.sw.ru/browse/PSBM-67502 v9: improve comment, put uptime to ivnentory image as 1) where is no stats in parent images directory if --work-dir option is set to something different then images directory, 2) stats-dump is not an image and it is a bad practice to put there data required for restoring. v10:s/u_int64_t/uint64_t/ Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
b610f28ada
commit
5451fc230d
@@ -1472,6 +1472,7 @@ static int setup_alarm_handler()
|
||||
|
||||
static int cr_pre_dump_finish(int ret)
|
||||
{
|
||||
InventoryEntry he = INVENTORY_ENTRY__INIT;
|
||||
struct pstree_item *item;
|
||||
|
||||
/*
|
||||
@@ -1480,6 +1481,8 @@ static int cr_pre_dump_finish(int ret)
|
||||
*/
|
||||
if (arch_set_thread_regs(root_item, false) < 0)
|
||||
goto err;
|
||||
|
||||
prepare_inventory_pre_dump(&he);
|
||||
pstree_switch_state(root_item, TASK_ALIVE);
|
||||
|
||||
timing_stop(TIME_FROZEN);
|
||||
@@ -1527,6 +1530,9 @@ err:
|
||||
if (bfd_flush_images())
|
||||
ret = -1;
|
||||
|
||||
if (write_img_inventory(&he))
|
||||
ret = -1;
|
||||
|
||||
if (ret)
|
||||
pr_err("Pre-dumping FAILED.\n");
|
||||
else {
|
||||
|
11
criu/image.c
11
criu/image.c
@@ -16,6 +16,7 @@
|
||||
#include "xmalloc.h"
|
||||
#include "images/inventory.pb-c.h"
|
||||
#include "images/pagemap.pb-c.h"
|
||||
#include "proc_parse.h"
|
||||
|
||||
bool ns_per_id = false;
|
||||
bool img_common_magic = true;
|
||||
@@ -105,6 +106,16 @@ int write_img_inventory(InventoryEntry *he)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void prepare_inventory_pre_dump(InventoryEntry *he)
|
||||
{
|
||||
pr_info("Perparing image inventory for pre-dump (version %u)\n", CRTOOLS_IMAGES_V1);
|
||||
|
||||
he->img_version = CRTOOLS_IMAGES_V1_1;
|
||||
|
||||
if (!parse_uptime(&he->dump_uptime))
|
||||
he->has_dump_uptime = true;
|
||||
}
|
||||
|
||||
int prepare_inventory(InventoryEntry *he)
|
||||
{
|
||||
struct pid pid;
|
||||
|
@@ -12,6 +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 prepare_inventory(InventoryEntry *he);
|
||||
struct pprep_head {
|
||||
int (*actor)(struct pprep_head *);
|
||||
|
@@ -2632,7 +2632,7 @@ err:
|
||||
|
||||
#define CSEC_PER_SEC 100
|
||||
|
||||
__maybe_unused int parse_uptime(uint64_t *upt)
|
||||
int parse_uptime(uint64_t *upt)
|
||||
{
|
||||
unsigned long sec, csec;
|
||||
FILE *f;
|
||||
|
@@ -15,4 +15,5 @@ message inventory_entry {
|
||||
optional bool ns_per_id = 4;
|
||||
optional uint32 root_cg_set = 5;
|
||||
optional lsmtype lsmtype = 6;
|
||||
optional uint64 dump_uptime = 8;
|
||||
}
|
||||
|
Reference in New Issue
Block a user