From 80e146da2076d8a828590176d57c8eabbe78017c Mon Sep 17 00:00:00 2001 From: Mike Rapoport Date: Mon, 27 Jun 2016 07:53:21 +0300 Subject: [PATCH] criu: pagemap: add reset method Rather than do open/close to reset pagemap, just update it's state. Signed-off-by: Mike Rapoport Acked-by: Adrian Reber Signed-off-by: Pavel Emelyanov --- 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 eddcc37d2..b993c4759 100644 --- a/criu/include/pagemap.h +++ b/criu/include/pagemap.h @@ -52,6 +52,7 @@ struct page_read { void (*skip_pages)(struct page_read *, unsigned long len); int (*sync)(struct page_read *pr); int (*seek_pagemap)(struct page_read *pr, unsigned long vaddr); + void (*reset)(struct page_read *pr); /* Whether or not pages can be read in PIE code */ bool pieok; diff --git a/criu/pagemap.c b/criu/pagemap.c index 126dce6ae..dc42731ae 100644 --- a/criu/pagemap.c +++ b/criu/pagemap.c @@ -547,6 +547,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 = -1; + 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; @@ -701,6 +714,7 @@ int open_page_read_at(int dfd, int pid, struct page_read *pr, int pr_flags) pr->skip_pages = skip_pagemap_pages; pr->sync = process_async_reads; pr->seek_pagemap = seek_pagemap; + pr->reset = reset_pagemap; pr->id = ids++; if (!pr->parent) pr->pieok = true;