[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/4] migration: simplify writev vs. non-writev logic
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 4/4] migration: simplify writev vs. non-writev logic |
Date: |
Mon, 8 Apr 2013 13:29:57 +0200 |
Check f->iovcnt in add_to_iovec, f->buf_index in qemu_put_buffer/byte.
Signed-off-by: Paolo Bonzini <address@hidden>
---
savevm.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/savevm.c b/savevm.c
index a2f6bc0..63f4c82 100644
--- a/savevm.c
+++ b/savevm.c
@@ -626,7 +626,7 @@ static void add_to_iovec(QEMUFile *f, const uint8_t *buf,
int size)
f->iov[f->iovcnt++].iov_len = size;
}
- if (f->buf_index >= IO_BUF_SIZE || f->iovcnt >= MAX_IOV_SIZE) {
+ if (f->iovcnt >= MAX_IOV_SIZE) {
qemu_fflush(f);
}
}
@@ -662,12 +662,10 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int
size)
f->bytes_xfer += size;
if (f->ops->writev_buffer) {
add_to_iovec(f, f->buf + f->buf_index, l);
- f->buf_index += l;
- } else {
- f->buf_index += l;
- if (f->buf_index == IO_BUF_SIZE) {
- qemu_fflush(f);
- }
+ }
+ f->buf_index += l;
+ if (f->buf_index == IO_BUF_SIZE) {
+ qemu_fflush(f);
}
if (qemu_file_get_error(f)) {
break;
@@ -687,12 +685,10 @@ void qemu_put_byte(QEMUFile *f, int v)
f->bytes_xfer++;
if (f->ops->writev_buffer) {
add_to_iovec(f, f->buf + f->buf_index, 1);
- f->buf_index++;
- } else {
- f->buf_index++;
- if (f->buf_index == IO_BUF_SIZE) {
- qemu_fflush(f);
- }
+ }
+ f->buf_index++;
+ if (f->buf_index == IO_BUF_SIZE) {
+ qemu_fflush(f);
}
}
--
1.8.2
- Re: [Qemu-devel] [PATCH 1/4] migration: set f->is_write and flush in add_to_iovec, (continued)
[Qemu-devel] [PATCH 2/4] migration: use a single I/O operation when writev_buffer is not defined, Paolo Bonzini, 2013/04/08
[Qemu-devel] [PATCH 4/4] migration: simplify writev vs. non-writev logic,
Paolo Bonzini <=
Re: [Qemu-devel] [PATCH 0/4] QEMUFile improvements and simplifications, Juan Quintela, 2013/04/09
Re: [Qemu-devel] [PATCH 0/4] QEMUFile improvements and simplifications, Liuji (Jeremy), 2013/04/10