thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
0727d3
From c1fd32d93ae42fcf3c1a25f4d56e669f251087d8 Mon Sep 17 00:00:00 2001
0727d3
From: Leonardo Bras <leobras@redhat.com>
0727d3
Date: Mon, 20 Jun 2022 02:39:43 -0300
0727d3
Subject: [PATCH 25/37] QIOChannelSocket: Fix zero-copy send so socket flush
0727d3
 works
0727d3
MIME-Version: 1.0
0727d3
Content-Type: text/plain; charset=UTF-8
0727d3
Content-Transfer-Encoding: 8bit
0727d3
0727d3
RH-Author: Leonardo Brás <leobras@redhat.com>
0727d3
RH-MergeRequest: 191: MSG_ZEROCOPY + Multifd @ rhel8.7
0727d3
RH-Commit: [25/26] 3ede94f3269e21c3ace073ed1a6f24696315bcbb
0727d3
RH-Bugzilla: 2072049
0727d3
RH-Acked-by: Peter Xu <peterx@redhat.com>
0727d3
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
0727d3
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
0727d3
Somewhere between v6 and v7 the of the zero-copy-send patchset a crucial
0727d3
part of the flushing mechanism got missing: incrementing zero_copy_queued.
0727d3
0727d3
Without that, the flushing interface becomes a no-op, and there is no
0727d3
guarantee the buffer is really sent.
0727d3
0727d3
This can go as bad as causing a corruption in RAM during migration.
0727d3
0727d3
Fixes: 2bc58ffc2926 ("QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX")
0727d3
Reported-by: 徐闯 <xuchuangxclwt@bytedance.com>
0727d3
Signed-off-by: Leonardo Bras <leobras@redhat.com>
0727d3
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
0727d3
Reviewed-by: Peter Xu <peterx@redhat.com>
0727d3
Reviewed-by: Juan Quintela <quintela@redhat.com>
0727d3
Signed-off-by: Juan Quintela <quintela@redhat.com>
0727d3
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0727d3
(cherry picked from commit 4f5a09714c983a3471fd12e3c7f3196e95c650c1)
0727d3
Signed-off-by: Leonardo Bras <leobras@redhat.com>
0727d3
---
0727d3
 io/channel-socket.c | 5 +++++
0727d3
 1 file changed, 5 insertions(+)
0727d3
0727d3
diff --git a/io/channel-socket.c b/io/channel-socket.c
0727d3
index 7d37b39de7..df858da924 100644
0727d3
--- a/io/channel-socket.c
0727d3
+++ b/io/channel-socket.c
0727d3
@@ -612,6 +612,11 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
0727d3
                          "Unable to write to socket");
0727d3
         return -1;
0727d3
     }
0727d3
+
0727d3
+    if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
0727d3
+        sioc->zero_copy_queued++;
0727d3
+    }
0727d3
+
0727d3
     return ret;
0727d3
 }
0727d3
 #else /* WIN32 */
0727d3
-- 
0727d3
2.35.3
0727d3