[CRIU] [PATCH v2] pagemap: fix reading pages from socket for --remote case
Mike Rapoport
rppt at linux.vnet.ibm.com
Sat Apr 22 23:12:27 PDT 2017
When --remote option is specified, read_local_page tries to pread from a
socket, and fails with "Illegal seek" error.
Restore single pread call for regular image files case and use read syscall
instead of pread for the --remote case.
Generally-approved-by: Rodrigo Bruno <rbruno at gsd.inesc-id.pt>
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
v2: simplify call to pread in non-remote case, it does not need 'curr'
criu/pagemap.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/criu/pagemap.c b/criu/pagemap.c
index 6c741b4..d72c6c4 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -265,15 +265,23 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
return -1;
pr_debug("\tpr%d-%u Read page from self %lx/%"PRIx64"\n", pr->pid, pr->id, pr->cvaddr, pr->pi_off);
- while (1) {
- ret = pread(fd, buf + curr, len - curr, pr->pi_off + curr);
- if (ret < 1) {
+ if (!opts.remote) {
+ ret = pread(fd, buf, len, pr->pi_off);
+ if (ret != len) {
pr_perror("Can't read mapping page %d", ret);
return -1;
}
- curr += ret;
- if (curr == len)
- break;
+ } else {
+ while (1) {
+ ret = read(fd, buf + curr, len - curr);
+ if (ret < 0) {
+ pr_perror("Can't read mapping page %d", ret);
+ return -1;
+ }
+ curr += ret;
+ if (curr == len)
+ break;
+ }
}
if (opts.auto_dedup) {
--
1.9.1
More information about the CRIU
mailing list