mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 05:48:05 +00:00
page_read: Make it possible to get pages.img ID from page_read
The pages.img will need to get opened one more time w/o the pagemap.img. Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
aebbdbf1ef
commit
b43f7aa615
14
criu/image.c
14
criu/image.c
@ -461,29 +461,27 @@ void up_page_ids_base(void)
|
||||
page_ids += 0x10000;
|
||||
}
|
||||
|
||||
struct cr_img *open_pages_image_at(int dfd, unsigned long flags, struct cr_img *pmi)
|
||||
struct cr_img *open_pages_image_at(int dfd, unsigned long flags, struct cr_img *pmi, u32 *id)
|
||||
{
|
||||
unsigned id;
|
||||
|
||||
if (flags == O_RDONLY || flags == O_RDWR) {
|
||||
PagemapHead *h;
|
||||
if (pb_read_one(pmi, &h, PB_PAGEMAP_HEAD) < 0)
|
||||
return NULL;
|
||||
id = h->pages_id;
|
||||
*id = h->pages_id;
|
||||
pagemap_head__free_unpacked(h, NULL);
|
||||
} else {
|
||||
PagemapHead h = PAGEMAP_HEAD__INIT;
|
||||
id = h.pages_id = page_ids++;
|
||||
*id = h.pages_id = page_ids++;
|
||||
if (pb_write_one(pmi, &h, PB_PAGEMAP_HEAD) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return open_image_at(dfd, CR_FD_PAGES, flags, id);
|
||||
return open_image_at(dfd, CR_FD_PAGES, flags, *id);
|
||||
}
|
||||
|
||||
struct cr_img *open_pages_image(unsigned long flags, struct cr_img *pmi)
|
||||
struct cr_img *open_pages_image(unsigned long flags, struct cr_img *pmi, u32 *id)
|
||||
{
|
||||
return open_pages_image_at(get_service_fd(IMG_FD_OFF), flags, pmi);
|
||||
return open_pages_image_at(get_service_fd(IMG_FD_OFF), flags, pmi, id);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -150,8 +150,8 @@ extern void close_image_dir(void);
|
||||
extern struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...);
|
||||
#define open_image(typ, flags, ...) open_image_at(-1, typ, flags, ##__VA_ARGS__)
|
||||
extern int open_image_lazy(struct cr_img *img);
|
||||
extern struct cr_img *open_pages_image(unsigned long flags, struct cr_img *pmi);
|
||||
extern struct cr_img *open_pages_image_at(int dfd, unsigned long flags, struct cr_img *pmi);
|
||||
extern struct cr_img *open_pages_image(unsigned long flags, struct cr_img *pmi, u32 *pages_id);
|
||||
extern struct cr_img *open_pages_image_at(int dfd, unsigned long flags, struct cr_img *pmi, u32 *pages_id);
|
||||
extern void up_page_ids_base(void);
|
||||
|
||||
extern struct cr_img *img_from_fd(int fd); /* for cr-show mostly */
|
||||
|
@ -55,6 +55,7 @@ struct page_read {
|
||||
/* Private data of reader */
|
||||
struct cr_img *pmi;
|
||||
struct cr_img *pi;
|
||||
u32 pages_img_id;
|
||||
|
||||
PagemapEntry *pe; /* current pagemap we are on */
|
||||
struct page_read *parent; /* parent pagemap (if ->in_parent
|
||||
|
@ -267,11 +267,13 @@ static void close_page_xfer(struct page_xfer *xfer)
|
||||
|
||||
static int open_page_local_xfer(struct page_xfer *xfer, int fd_type, long id)
|
||||
{
|
||||
u32 pages_id;
|
||||
|
||||
xfer->pmi = open_image(fd_type, O_DUMP, id);
|
||||
if (!xfer->pmi)
|
||||
return -1;
|
||||
|
||||
xfer->pi = open_pages_image(O_DUMP, xfer->pmi);
|
||||
xfer->pi = open_pages_image(O_DUMP, xfer->pmi, &pages_id);
|
||||
if (!xfer->pi) {
|
||||
close_image(xfer->pmi);
|
||||
return -1;
|
||||
|
@ -655,7 +655,7 @@ int open_page_read_at(int dfd, int pid, struct page_read *pr, int pr_flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
pr->pi = open_pages_image_at(dfd, flags, pr->pmi);
|
||||
pr->pi = open_pages_image_at(dfd, flags, pr->pmi, &pr->pages_img_id);
|
||||
if (!pr->pi) {
|
||||
close_page_read(pr);
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user