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