aboutsummaryrefslogtreecommitdiffstats
path: root/savevm.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2011-09-30 19:28:45 +0200
committerJuan Quintela <quintela@redhat.com>2011-10-20 13:23:11 +0200
commit0046c45bc1c70b5b985822f8639bb718f6d535a5 (patch)
treeef6d66e2a0143971fb3607edf62ef6e595bbbbcc /savevm.c
parentcfce6d8934243871c4dc6d0c5248b0b27a1b8d80 (diff)
savevm: teach qemu_fill_buffer to do partial refills
We will need on next patch to be able to lookahead on next patch v2: rename "used" to "pending" (Alex Williams) Signed-off-by: Juan Quintela<quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'savevm.c')
-rw-r--r--savevm.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/savevm.c b/savevm.c
index bf4d0e76c..aa6fef08a 100644
--- a/savevm.c
+++ b/savevm.c
@@ -455,6 +455,7 @@ void qemu_fflush(QEMUFile *f)
static void qemu_fill_buffer(QEMUFile *f)
{
int len;
+ int pending;
if (!f->get_buffer)
return;
@@ -462,10 +463,17 @@ static void qemu_fill_buffer(QEMUFile *f)
if (f->is_write)
abort();
- len = f->get_buffer(f->opaque, f->buf, f->buf_offset, IO_BUF_SIZE);
+ pending = f->buf_size - f->buf_index;
+ if (pending > 0) {
+ memmove(f->buf, f->buf + f->buf_index, pending);
+ }
+ f->buf_index = 0;
+ f->buf_size = pending;
+
+ len = f->get_buffer(f->opaque, f->buf + pending, f->buf_offset,
+ IO_BUF_SIZE - pending);
if (len > 0) {
- f->buf_index = 0;
- f->buf_size = len;
+ f->buf_size += len;
f->buf_offset += len;
} else if (len != -EAGAIN)
f->has_error = 1;