[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC] qemu-file: output data directly if possible
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PATCH RFC] qemu-file: output data directly if possible |
Date: |
Sun, 9 Oct 2011 21:56:29 -0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
qemu file currently always buffers up data before writing it out.
At least for memory this is probably not a good idea:
writing out to file would be cheaper. Let's do
that if we can, which should be the common case. If we can't, buffer.
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
Completely untested, this is just thinking aloud.
Shouldn't the below save us a data copy in the
common case, helping speed up migration?
Please comment.
diff --git a/qemu-file.c b/qemu-file.c
index 761f2a9..6d30151 100644
--- a/qemu-file.c
+++ b/qemu-file.c
@@ -142,6 +142,16 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int
size)
abort();
}
+ if (!f->has_error && size > 0 && !f->buf_index) {
+ int len = f->put_buffer(f->opaque, buf, 0, size);
+ if (len >= 0) {
+ size -= len;
+ buf += len;
+ } else {
+ f->has_error = 1;
+ }
+ }
+
while (!f->has_error && size > 0) {
l = IO_BUF_SIZE - f->buf_index;
if (l > size)
- [Qemu-devel] [PATCH RFC] qemu-file: output data directly if possible,
Michael S. Tsirkin <=