提交 0046c45b 编写于 作者: J Juan Quintela

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: NAnthony Liguori <aliguori@us.ibm.com>
上级 cfce6d89
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册