All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 2/4] savevm: Implement block_writev_buffer()
Date: Fri,  5 Apr 2013 21:27:54 +0200	[thread overview]
Message-ID: <1365190076-20268-3-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1365190076-20268-1-git-send-email-kwolf@redhat.com>

Instead of breaking up RAM state into many small chunks, pass the iovec
to the block layer for better performance.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/migration/qemu-file.h |  2 +-
 savevm.c                      | 25 +++++++++++++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index 623c434..7519464 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -55,7 +55,7 @@ typedef int (QEMUFileGetFD)(void *opaque);
  * This function writes an iovec to file.
  */
 typedef ssize_t (QEMUFileWritevBufferFunc)(void *opaque, struct iovec *iov,
-                                           int iovcnt);
+                                           int iovcnt, int64_t pos);
 
 typedef struct QEMUFileOps {
     QEMUFilePutBufferFunc *put_buffer;
diff --git a/savevm.c b/savevm.c
index b1d8988..88fe985 100644
--- a/savevm.c
+++ b/savevm.c
@@ -176,7 +176,8 @@ static void coroutine_fn yield_until_fd_readable(int fd)
     qemu_coroutine_yield();
 }
 
-static ssize_t socket_writev_buffer(void *opaque, struct iovec *iov, int iovcnt)
+static ssize_t socket_writev_buffer(void *opaque, struct iovec *iov, int iovcnt,
+                                    int64_t pos)
 {
     QEMUFileSocket *s = opaque;
     ssize_t len;
@@ -458,6 +459,21 @@ fail:
     return NULL;
 }
 
+static ssize_t block_writev_buffer(void *opaque, struct iovec *iov, int iovcnt,
+                                   int64_t pos)
+{
+    int ret;
+    QEMUIOVector qiov;
+
+    qemu_iovec_init_external(&qiov, iov, iovcnt);
+    ret = bdrv_writev_vmstate(opaque, &qiov, pos);
+    if (ret < 0) {
+        return ret;
+    }
+
+    return qiov.size;
+}
+
 static int block_put_buffer(void *opaque, const uint8_t *buf,
                            int64_t pos, int size)
 {
@@ -481,8 +497,9 @@ static const QEMUFileOps bdrv_read_ops = {
 };
 
 static const QEMUFileOps bdrv_write_ops = {
-    .put_buffer = block_put_buffer,
-    .close =      bdrv_fclose
+    .put_buffer     = block_put_buffer,
+    .writev_buffer  = block_writev_buffer,
+    .close          = bdrv_fclose
 };
 
 static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable)
@@ -533,7 +550,7 @@ static void qemu_fflush(QEMUFile *f)
 
     if (f->is_write && f->iovcnt > 0) {
         if (f->ops->writev_buffer) {
-            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;
             }
-- 
1.8.1.4

  parent reply	other threads:[~2013-04-05 19:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-05 19:27 [Qemu-devel] [PATCH 0/4] block: Vectored bdrv_writev_vmstate Kevin Wolf
2013-04-05 19:27 ` [Qemu-devel] [PATCH 1/4] block: Introduce bdrv_writev_vmstate Kevin Wolf
2013-04-05 19:27 ` Kevin Wolf [this message]
2013-04-05 19:27 ` [Qemu-devel] [PATCH 3/4] block: Introduce bdrv_pwritev() for qcow2_save_vmstate Kevin Wolf
2013-04-05 19:27 ` [Qemu-devel] [PATCH 4/4] qemu-iotests: A few more bdrv_pread/pwrite tests Kevin Wolf
2013-04-08 16:03 ` [Qemu-devel] [PATCH 0/4] block: Vectored bdrv_writev_vmstate Stefan Hajnoczi
2013-04-08 16:18   ` Paolo Bonzini
2013-04-09  8:04     ` Kevin Wolf
2013-04-09  8:08       ` Paolo Bonzini
2013-04-09  8:30         ` Stefan Hajnoczi
2013-04-09 12:30 ` Stefan Hajnoczi

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=1365190076-20268-3-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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.