thebeanogamer / rpms / qemu-kvm

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