qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH RFC] qemu-file: output data directly if possible
@ 2011-10-09 23:56 Michael S. Tsirkin
  2011-10-10  7:42 ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2011-10-09 23:56 UTC (permalink / raw)
  To: qemu-devel

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 <mst@redhat.com>

---

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)

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-11  9:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-09 23:56 [Qemu-devel] [PATCH RFC] qemu-file: output data directly if possible Michael S. Tsirkin
2011-10-10  7:42 ` Paolo Bonzini
2011-10-10 13:16   ` Michael S. Tsirkin
2011-10-10  9:25     ` Paolo Bonzini
2011-10-11  9:19     ` Juan Quintela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).