mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
files: Move reg files into files image
Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
@@ -866,6 +866,7 @@ static int create_link_remap(char *path, int len, int lfd,
|
||||
const struct stat *st)
|
||||
{
|
||||
char link_name[PATH_MAX], *tmp;
|
||||
FileEntry fe = FILE_ENTRY__INIT;
|
||||
RegFileEntry rfe = REG_FILE_ENTRY__INIT;
|
||||
FownEntry fwn = FOWN_ENTRY__INIT;
|
||||
int mntns_root;
|
||||
@@ -924,7 +925,11 @@ again:
|
||||
if (note_link_remap(link_name, nsid))
|
||||
return -1;
|
||||
|
||||
return pb_write_one(img_from_set(glob_imgset, CR_FD_REG_FILES), &rfe, PB_REG_FILE);
|
||||
fe.type = FD_TYPES__REG;
|
||||
fe.id = rfe.id;
|
||||
fe.reg = &rfe;
|
||||
|
||||
return pb_write_one(img_from_set(glob_imgset, CR_FD_FILES), &fe, PB_FILE);
|
||||
}
|
||||
|
||||
static int dump_linked_remap(char *path, int len, const struct stat *ost,
|
||||
@@ -1249,7 +1254,7 @@ int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
|
||||
struct ns_id *nsid;
|
||||
struct cr_img *rimg;
|
||||
char ext_id[64];
|
||||
|
||||
FileEntry fe = FILE_ENTRY__INIT;
|
||||
RegFileEntry rfe = REG_FILE_ENTRY__INIT;
|
||||
|
||||
if (!p->link) {
|
||||
@@ -1309,8 +1314,12 @@ ext:
|
||||
rfe.size = p->stat.st_size;
|
||||
}
|
||||
|
||||
rimg = img_from_set(glob_imgset, CR_FD_REG_FILES);
|
||||
return pb_write_one(rimg, &rfe, PB_REG_FILE);
|
||||
fe.type = FD_TYPES__REG;
|
||||
fe.id = rfe.id;
|
||||
fe.reg = &rfe;
|
||||
|
||||
rimg = img_from_set(glob_imgset, CR_FD_FILES);
|
||||
return pb_write_one(rimg, &fe, PB_FILE);
|
||||
}
|
||||
|
||||
const struct fdtype_ops regfile_dump_ops = {
|
||||
@@ -1933,7 +1942,7 @@ static int collect_one_regfile(void *o, ProtobufCMessage *base, struct cr_img *i
|
||||
return file_desc_add(&rfi->d, rfi->rfe->id, ®_desc_ops);
|
||||
}
|
||||
|
||||
static struct collect_image_info reg_file_cinfo = {
|
||||
struct collect_image_info reg_file_cinfo = {
|
||||
.fd_type = CR_FD_REG_FILES,
|
||||
.pb_type = PB_REG_FILE,
|
||||
.priv_size = sizeof(struct reg_file_info),
|
||||
@@ -1943,7 +1952,7 @@ static struct collect_image_info reg_file_cinfo = {
|
||||
|
||||
int collect_remaps_and_regfiles(void)
|
||||
{
|
||||
if (collect_image(®_file_cinfo))
|
||||
if (!files_collected() && collect_image(®_file_cinfo))
|
||||
return -1;
|
||||
|
||||
if (collect_image(&remap_cinfo))
|
||||
|
15
criu/files.c
15
criu/files.c
@@ -1664,6 +1664,17 @@ int open_transport_socket(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int collect_one_file_entry(FileEntry *fe, u_int32_t id, ProtobufCMessage *base,
|
||||
struct collect_image_info *cinfo)
|
||||
{
|
||||
if (fe->id != id) {
|
||||
pr_err("ID mismatch %u != %u\n", fe->id, id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return collect_entry(base, cinfo);
|
||||
}
|
||||
|
||||
static int collect_one_file(void *o, ProtobufCMessage *base, struct cr_img *i)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -1674,6 +1685,9 @@ static int collect_one_file(void *o, ProtobufCMessage *base, struct cr_img *i)
|
||||
default:
|
||||
pr_err("Unknown file type %d\n", fe->type);
|
||||
return -1;
|
||||
case FD_TYPES__REG:
|
||||
ret = collect_one_file_entry(fe, fe->reg->id, &fe->reg->base, ®_file_cinfo);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1684,6 +1698,7 @@ struct collect_image_info files_cinfo = {
|
||||
.pb_type = PB_FILE,
|
||||
.priv_size = 0,
|
||||
.collect = collect_one_file,
|
||||
.flags = COLLECT_NOFREE,
|
||||
};
|
||||
|
||||
int prepare_files(void)
|
||||
|
@@ -44,6 +44,7 @@ extern int collect_filemap(struct vma_area *);
|
||||
extern void filemap_ctx_init(bool auto_close);
|
||||
extern void filemap_ctx_fini(void);
|
||||
|
||||
extern struct collect_image_info reg_file_cinfo;
|
||||
extern int collect_remaps_and_regfiles(void);
|
||||
|
||||
extern void delete_link_remaps(void);
|
||||
|
@@ -56,7 +56,6 @@ enum {
|
||||
_CR_FD_GLOB_FROM,
|
||||
CR_FD_FILES,
|
||||
CR_FD_SK_QUEUES,
|
||||
CR_FD_REG_FILES,
|
||||
CR_FD_EXT_FILES,
|
||||
CR_FD_NS_FILES,
|
||||
CR_FD_INETSK,
|
||||
@@ -106,6 +105,7 @@ enum {
|
||||
CR_FD_INOTIFY_WD,
|
||||
CR_FD_FANOTIFY_MARK,
|
||||
CR_FD_EVENTPOLL_TFD,
|
||||
CR_FD_REG_FILES,
|
||||
|
||||
CR_FD_AUTOFS,
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
syntax = "proto2";
|
||||
|
||||
import "regfile.proto";
|
||||
|
||||
enum fd_types {
|
||||
UND = 0;
|
||||
REG = 1;
|
||||
@@ -31,4 +33,5 @@ message fdinfo_entry {
|
||||
message file_entry {
|
||||
required fd_types type = 1;
|
||||
required uint32 id = 2;
|
||||
optional reg_file_entry reg = 3;
|
||||
}
|
||||
|
Reference in New Issue
Block a user