[CRIU] [PATCH] page-read: add print error in case of bad or corrupted image
Tikhomirov Pavel
snorcht at gmail.com
Tue Nov 19 02:14:36 PST 2013
add it instead of BUG_ON
we should print error if flag isn't assigned
---
include/page-read.h | 2 ++
page-read.c | 13 ++++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/include/page-read.h b/include/page-read.h
index b19ea69..5ad6325 100644
--- a/include/page-read.h
+++ b/include/page-read.h
@@ -66,4 +66,6 @@ struct page_read {
};
int open_page_read(int pid, struct page_read *);
+
+#define DO_NOT_PRINT_ERROR 1
#endif
diff --git a/page-read.c b/page-read.c
index 3dde366..43f1b2a 100644
--- a/page-read.c
+++ b/page-read.c
@@ -83,7 +83,7 @@ static void skip_pagemap_pages(struct page_read *pr, unsigned long len)
pr->cvaddr += len;
}
-static int read_pagemap_page_from_parent(struct page_read *pr, unsigned long vaddr, void *buf)
+static int read_pagemap_page_from_parent(struct page_read *pr, unsigned long vaddr, void *buf, int flags)
{
int ret;
struct iovec iov;
@@ -96,7 +96,12 @@ static int read_pagemap_page_from_parent(struct page_read *pr, unsigned long vad
while (1) {
unsigned long iov_end;
- BUG_ON(vaddr < pr->cvaddr);
+ if (vaddr < pr->cvaddr) {
+ if (!flags & DO_NOT_PRINT_ERROR)
+ pr_err("Missing %lu in parent pagemap, current iov: base=%lu,len=%lu\n",
+ vaddr, (unsigned long)iov.iov_base, iov.iov_len);
+ return -1;
+ }
iov_end = (unsigned long)iov.iov_base + iov.iov_len;
if (iov_end <= vaddr) {
@@ -121,7 +126,9 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, void *bu
if (pr->pe->in_parent) {
pr_debug("\tpr%u Read page %lx from parent\n", pr->id, vaddr);
- ret = read_pagemap_page_from_parent(pr->parent, vaddr, buf);
+ ret = read_pagemap_page_from_parent(pr->parent, vaddr, buf, 0);
+ if (ret == -1)
+ return ret;
} else {
pr_debug("\tpr%u Read page %lx from self %lx/%"PRIx64"\n", pr->id,
vaddr, pr->cvaddr, lseek(pr->fd_pg, 0, SEEK_CUR));
--
1.7.9.5
More information about the CRIU
mailing list