diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-04-08 13:29:57 +0200 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2013-04-09 15:00:13 +0200 |
commit | 4d1172472cdf28a444321ca8b165ce7326eb919e (patch) | |
tree | b73d38dceda0b4a43da6f2fbc5c64ba23d841d16 /savevm.c | |
parent | d9658c4732a88efc42ab43bda69ae9f62559205b (diff) |
migration: simplify writev vs. non-writev logic
Check f->iovcnt in add_to_iovec, f->buf_index in qemu_put_buffer/byte.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'savevm.c')
-rw-r--r-- | savevm.c | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -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); } } |