2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

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: Rodrigo Bruno <rbruno@gsd.inesc-id.pt>
Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
rbruno@gsd.inesc-id.pt 2017-02-11 04:34:43 +01:00 committed by Pavel Emelyanov
parent 86b9170ff3
commit 5afbbe5ce2

View File

@ -170,15 +170,17 @@ static int write_pages_loc(struct page_xfer *xfer,
int p, unsigned long len)
{
ssize_t ret;
ssize_t curr = 0;
ret = splice(p, NULL, img_raw_fd(xfer->pi), NULL, len, SPLICE_F_MOVE);
if (ret == -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);
return -1;
while (1) {
ret = splice(p, NULL, img_raw_fd(xfer->pi), NULL, len, SPLICE_F_MOVE);
if (ret == -1) {
pr_perror("Unable to spice data");
return -1;
}
curr += ret;
if (curr == len)
break;
}
return 0;