return;
}
- if (f->is_write && f->iovcnt > 0) {
- if (f->ops->writev_buffer) {
+ if (f->ops->writev_buffer) {
+ if (f->iovcnt > 0) {
- ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt);
+ ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos);
- if (ret >= 0) {
- f->pos += ret;
- }
- } else {
- for (i = 0; i < f->iovcnt && ret >= 0; i++) {
- ret = f->ops->put_buffer(f->opaque, f->iov[i].iov_base, f->pos,
- f->iov[i].iov_len);
- if (ret >= 0) {
- f->pos += ret;
- }
- }
}
- f->buf_index = 0;
- f->iovcnt = 0;
+ } else {
+ if (f->buf_index > 0) {
+ ret = f->ops->put_buffer(f->opaque, f->buf, f->pos, f->buf_index);
+ }
+ }
+ if (ret >= 0) {
+ f->pos += ret;
}
+ f->buf_index = 0;
+ f->iovcnt = 0;
if (ret < 0) {
qemu_file_set_error(f, ret);
}