Commit 5afbbe5c authored by rbruno@gsd.inesc-id.pt's avatar rbruno@gsd.inesc-id.pt Committed by Pavel Emelyanov

page-xfer: Splice data into image by chunks

This is needed for the case when the target descriptor is image
cache/proxy socket.
Signed-off-by: 's avatarRodrigo Bruno <rbruno@gsd.inesc-id.pt>
Signed-off-by: 's avatarKaterina Koukiou <k.koukiou@gmail.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 86b9170f
...@@ -170,15 +170,17 @@ static int write_pages_loc(struct page_xfer *xfer, ...@@ -170,15 +170,17 @@ static int write_pages_loc(struct page_xfer *xfer,
int p, unsigned long len) int p, unsigned long len)
{ {
ssize_t ret; ssize_t ret;
ssize_t curr = 0;
ret = splice(p, NULL, img_raw_fd(xfer->pi), NULL, len, SPLICE_F_MOVE); while (1) {
if (ret == -1) { ret = splice(p, NULL, img_raw_fd(xfer->pi), NULL, len, SPLICE_F_MOVE);
pr_perror("Unable to spice data"); if (ret == -1) {
return -1; pr_perror("Unable to spice data");
} return -1;
if (ret != len) { }
pr_err("Only %zu of %lu bytes have been spliced\n", ret, len); curr += ret;
return -1; if (curr == len)
break;
} }
return 0; return 0;
......
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