All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junjie Cao <junjie.cao@intel.com>
To: qemu-devel@nongnu.org
Cc: peterx@redhat.com, farosas@suse.de, junjie.cao@intel.com
Subject: [PATCH 2/3] migration/file: switch file_write_ramblock_iov to pwritev_all
Date: Tue, 21 Apr 2026 04:13:16 +0800	[thread overview]
Message-ID: <20260420201317.30199-3-junjie.cao@intel.com> (raw)
In-Reply-To: <20260420201317.30199-1-junjie.cao@intel.com>

file_write_ramblock_iov() uses single-shot qio_channel_pwritev() and
only checks for ret < 0.  A short write (0 <= ret < requested) would be
treated as success.

Switch to qio_channel_pwritev_all() which retries until all bytes are
written or an error occurs.

Fixes: f427d90b98 ("migration/multifd: Support outgoing mapped-ram stream format")
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
---
 migration/file.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/migration/file.c b/migration/file.c
index 0853188601..3729728dfe 100644
--- a/migration/file.c
+++ b/migration/file.c
@@ -200,7 +200,7 @@ void file_connect_incoming(FileMigrationArgs *file_args, Error **errp)
 int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov,
                             int niov, MultiFDPages_t *pages, Error **errp)
 {
-    ssize_t ret = 0;
+    int ret = 0;
     int i, slice_idx, slice_num;
     uintptr_t base, next, offset;
     size_t len;
@@ -239,8 +239,8 @@ int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov,
             break;
         }
 
-        ret = qio_channel_pwritev(ioc, &iov[slice_idx], slice_num,
-                                  block->pages_offset + offset, errp);
+        ret = qio_channel_pwritev_all(ioc, &iov[slice_idx], slice_num,
+                                      block->pages_offset + offset, errp);
         if (ret < 0) {
             break;
         }
@@ -249,7 +249,7 @@ int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov,
         slice_num = 0;
     }
 
-    return (ret < 0) ? ret : 0;
+    return ret;
 }
 
 int multifd_file_recv_data(MultiFDRecvParams *p, Error **errp)
-- 
2.43.0



  parent reply	other threads:[~2026-04-20 12:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 20:13 [PATCH 0/3] migration: switch remaining positioned I/O to _all helpers Junjie Cao
2026-04-20 20:13 ` [PATCH 1/3] migration/qemu-file: switch buffer_at functions to positioned I/O " Junjie Cao
2026-04-20 20:13 ` Junjie Cao [this message]
2026-04-20 20:13 ` [PATCH 3/3] migration/qemu-file: drop incorrect const from qemu_get_buffer_at buf Junjie Cao
2026-04-20 17:34   ` Philippe Mathieu-Daudé
2026-04-21 14:20 ` [PATCH 0/3] migration: switch remaining positioned I/O to _all helpers Peter Xu
2026-04-26  8:27 ` Michael Tokarev
2026-04-27 13:16   ` Peter Xu
2026-04-27 22:36     ` Junjie Cao

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=20260420201317.30199-3-junjie.cao@intel.com \
    --to=junjie.cao@intel.com \
    --cc=farosas@suse.de \
    --cc=peterx@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.