From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH RFC] qemu-file: output data directly if possible
Date: Sun, 9 Oct 2011 21:56:29 -0200 [thread overview]
Message-ID: <20111009235629.GB9542@redhat.com> (raw)
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)
next reply other threads:[~2011-10-09 19:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-09 23:56 Michael S. Tsirkin [this message]
2011-10-10 7:42 ` [Qemu-devel] [PATCH RFC] qemu-file: output data directly if possible Paolo Bonzini
2011-10-10 13:16 ` Michael S. Tsirkin
2011-10-10 9:25 ` Paolo Bonzini
2011-10-11 9:19 ` Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111009235629.GB9542@redhat.com \
--to=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.