[CRIU] [PATCH 2/3] criu: pagemap: add reset method

Mike Rapoport rppt at linux.vnet.ibm.com
Sun Jun 26 21:53:21 PDT 2016


Rather than do open/close to reset pagemap, just update it's state.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/include/pagemap.h |  1 +
 criu/pagemap.c         | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h
index 5e6c4b2..b973caf 100644
--- a/criu/include/pagemap.h
+++ b/criu/include/pagemap.h
@@ -53,6 +53,7 @@ struct page_read {
 	void (*close)(struct page_read *);
 	void (*skip_pages)(struct page_read *, unsigned long len);
 	int (*seek_page)(struct page_read *pr, unsigned long vaddr, bool warn);
+	void (*reset)(struct page_read *pr);
 
 	/* Private data of reader */
 	struct cr_img *pmi;
diff --git a/criu/pagemap.c b/criu/pagemap.c
index 7babca3..0118bad 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -317,6 +317,19 @@ static void close_page_read(struct page_read *pr)
 		free_pagemaps(pr);
 }
 
+static void reset_pagemap(struct page_read *pr)
+{
+	pr->cvaddr = 0;
+	pr->pi_off = 0;
+	pr->curr_pme = 0;
+	pr->pe = NULL;
+
+	/* FIXME: take care of bunch */
+
+	if (pr->parent)
+		reset_pagemap(pr->parent);
+}
+
 static int try_open_parent(int dfd, int pid, struct page_read *pr, int pr_flags)
 {
 	int pfd, ret;
@@ -467,6 +480,7 @@ int open_page_read_at(int dfd, int pid, struct page_read *pr, int pr_flags)
 	pr->close = close_page_read;
 	pr->skip_pages = skip_pagemap_pages;
 	pr->seek_page = seek_pagemap_page;
+	pr->reset = reset_pagemap;
 	pr->id = ids++;
 
 	pr_debug("Opened page read %u (parent %u)\n",
-- 
1.9.1



More information about the CRIU mailing list