All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfio/migration: Use qemu_put_buffer_async to avoid an extra copy
@ 2026-11-20 16:20 Jie Song
  2026-11-26 12:52 ` Fabiano Rosas
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jie Song @ 2026-11-20 16:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex, clg, peterx, farosas, avihaih, Jie Song

From: Jie Song <songjie_yewu@cmss.chinamobile.com>

Replace qemu_put_buffer with qemu_put_buffer_async + qemu_fflush in
vfio_save_block to avoid an unnecessary memcpy of device state data
through QEMUFile's 32 KiB internal buffer.

With qemu_put_buffer_async, the data_buffer pointer is added directly
to the iov array. Since the next read overwrites the same buffer,
flush immediately so that the channel has consumed the data before
the buffer is reused.

Signed-off-by: Jie Song <songjie_yewu@cmss.chinamobile.com>
---
 hw/vfio/migration.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 69d50cebdd..e363250b79 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -476,7 +476,8 @@ static ssize_t vfio_save_block(QEMUFile *f, VFIOMigration *migration)
 
     qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE);
     qemu_put_be64(f, data_size);
-    qemu_put_buffer(f, migration->data_buffer, data_size);
+    qemu_put_buffer_async(f, migration->data_buffer, data_size, false);
+    qemu_fflush(f);
     vfio_migration_add_bytes_transferred(data_size);
 
     trace_vfio_save_block(migration->vbasedev->name, data_size);
-- 
2.48.1



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

end of thread, other threads:[~2026-11-30  7:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 16:20 [PATCH] vfio/migration: Use qemu_put_buffer_async to avoid an extra copy Jie Song
2026-11-26 12:52 ` Fabiano Rosas
2026-11-27 12:49 ` Peter Xu
2026-11-30  7:56 ` Cédric Le Goater

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.