Commit 2a33c4d5 authored by Pavel Emelyanov's avatar Pavel Emelyanov

mem: Remove zero page from the end of mem image files

This was required when pages were stored in elf files for
exec. Now we can stop reading it on eof.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b4edfa78
......@@ -1466,10 +1466,6 @@ static int cr_dump_shmem(void)
if (pfn != nrpages)
goto err_close;
err = write_img(fd, &zero_page_entry);
if (err < 0)
goto err_close;
close(fd);
munmap(addr, si->size);
xfree(map);
......
......@@ -472,11 +472,8 @@ static int restore_shmem_content(void *addr, struct shmem_info *si)
}
while (1) {
ret = read_img_buf(fd, &offset, sizeof(offset));
if (ret < 0)
break;
if (final_page_va(offset))
ret = read_img_buf_eof(fd, &offset, sizeof(offset));
if (ret <= 0)
break;
if (offset + PAGE_SIZE > si->size)
......
......@@ -202,9 +202,7 @@ void show_pages(int fd_pages, struct cr_options *o)
while (1) {
struct page_entry e;
if (read_img(fd_pages, &e) < 0)
break;
if (final_page_entry(&e))
if (read_img_eof(fd_pages, &e) <= 0)
break;
print_data(e.va, e.data, PAGE_IMAGE_SIZE);
......@@ -217,12 +215,11 @@ void show_pages(int fd_pages, struct cr_options *o)
pr_msg("\t");
for (i = 0; i < DEF_PAGES_PER_LINE; i++) {
if (read_img(fd_pages, &e) < 0)
goto out;
if (final_page_entry(&e)) {
if (read_img_eof(fd_pages, &e) <= 0) {
pr_msg("\n");
goto out;
}
pr_msg("%16lx ", e.va);
}
pr_msg("\n");
......
......@@ -24,7 +24,6 @@
#include "ipc_ns.h"
static struct cr_options opts;
struct page_entry zero_page_entry = {.va = ~0LL};
/*
* The cr fd set is the set of files where the information
......
......@@ -8,7 +8,6 @@
#include "util.h"
#include "image.h"
extern struct page_entry zero_page_entry;
extern void free_pstree(struct list_head *pstree_list);
#define CR_FD_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)
......
......@@ -195,9 +195,6 @@ struct page_entry {
u8 data[PAGE_IMAGE_SIZE];
} __packed;
#define final_page_va(va) ((va) == ~0LL)
#define final_page_entry(page_entry) (final_page_va((page_entry)->va))
struct sa_entry {
u64 sigaction;
u64 flags;
......
......@@ -536,9 +536,6 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a
parasite_execute(PARASITE_CMD_DUMPPAGES_FINI, ctl, NULL, 0);
if (write_img(fdset_fd(cr_fdset, CR_FD_PAGES), &zero_page_entry))
goto out;
pr_info("\n");
pr_info("Summary: %16li pages dumped\n", nrpages_dumped);
ret = 0;
......
......@@ -370,13 +370,12 @@ long restore_task(struct task_restore_core_args *args)
ret = sys_read(args->fd_pages, &va, sizeof(va));
if (!ret)
break;
if (ret != sizeof(va)) {
write_num_n(__LINE__);
write_num_n(ret);
goto core_restore_end;
}
if (final_page_va(va))
break;
ret = sys_read(args->fd_pages, (void *)va, PAGE_SIZE);
if (ret != PAGE_SIZE) {
......
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