mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 00:58:31 +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:
parent
da21d2d17a
commit
688ffa50f1
5 changed files with 20 additions and 1 deletions
|
|
@ -1563,6 +1563,7 @@ static int setup_alarm_handler()
|
|||
|
||||
static int cr_pre_dump_finish(int ret)
|
||||
{
|
||||
InventoryEntry he = INVENTORY_ENTRY__INIT;
|
||||
struct pstree_item *item;
|
||||
|
||||
/*
|
||||
|
|
@ -1571,6 +1572,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);
|
||||
|
|
@ -1621,6 +1624,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
|
|
@ -17,6 +17,7 @@
|
|||
#include "images/inventory.pb-c.h"
|
||||
#include "images/pagemap.pb-c.h"
|
||||
#include "img-remote.h"
|
||||
#include "proc_parse.h"
|
||||
|
||||
bool ns_per_id = false;
|
||||
bool img_common_magic = true;
|
||||
|
|
@ -112,6 +113,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 *);
|
||||
|
|
|
|||
|
|
@ -2715,7 +2715,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;
|
||||
|
|
|
|||
|
|
@ -16,4 +16,5 @@ message inventory_entry {
|
|||
optional uint32 root_cg_set = 5;
|
||||
optional lsmtype lsmtype = 6;
|
||||
optional bool check_only = 7;
|
||||
optional uint64 dump_uptime = 8;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue