|
|
719b13 |
From f1e21f3d46e1481a5cdd2f297831742b5b2d8ecf Mon Sep 17 00:00:00 2001
|
|
|
719b13 |
From: Leonardo Bras <leobras@redhat.com>
|
|
|
719b13 |
Date: Mon, 20 Jun 2022 02:39:42 -0300
|
|
|
719b13 |
Subject: [PATCH 24/34] QIOChannelSocket: Introduce assert and reduce ifdefs to
|
|
|
719b13 |
improve readability
|
|
|
719b13 |
MIME-Version: 1.0
|
|
|
719b13 |
Content-Type: text/plain; charset=UTF-8
|
|
|
719b13 |
Content-Transfer-Encoding: 8bit
|
|
|
719b13 |
|
|
|
719b13 |
RH-Author: Leonardo Brás <leobras@redhat.com>
|
|
|
719b13 |
RH-MergeRequest: 185: MSG_ZEROCOPY + Multifd @ rhel8.6
|
|
|
719b13 |
RH-Commit: [24/34] 0dcd79e1e89c881e56c3ef2e421910176b03d881
|
|
|
719b13 |
RH-Bugzilla: 2117252
|
|
|
719b13 |
RH-Acked-by: quintela1 <quintela@redhat.com>
|
|
|
719b13 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
719b13 |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
719b13 |
|
|
|
719b13 |
During implementation of MSG_ZEROCOPY feature, a lot of #ifdefs were
|
|
|
719b13 |
introduced, particularly at qio_channel_socket_writev().
|
|
|
719b13 |
|
|
|
719b13 |
Rewrite some of those changes so it's easier to read.
|
|
|
719b13 |
|
|
|
719b13 |
Also, introduce an assert to help detect incorrect zero-copy usage is when
|
|
|
719b13 |
it's disabled on build.
|
|
|
719b13 |
|
|
|
719b13 |
Signed-off-by: Leonardo Bras <leobras@redhat.com>
|
|
|
719b13 |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
719b13 |
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
|
719b13 |
Reviewed-by: Peter Xu <peterx@redhat.com>
|
|
|
719b13 |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
719b13 |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
719b13 |
dgilbert: Fixed up thinko'd g_assert_unreachable->g_assert_not_reached
|
|
|
719b13 |
(cherry picked from commit 803ca43e4c7fcf32f9f68c118301ccd0c83ece3f)
|
|
|
719b13 |
Signed-off-by: Leonardo Bras <leobras@redhat.com>
|
|
|
719b13 |
---
|
|
|
719b13 |
io/channel-socket.c | 14 +++++++++-----
|
|
|
719b13 |
1 file changed, 9 insertions(+), 5 deletions(-)
|
|
|
719b13 |
|
|
|
719b13 |
diff --git a/io/channel-socket.c b/io/channel-socket.c
|
|
|
719b13 |
index 38a46ba213..7d37b39de7 100644
|
|
|
719b13 |
--- a/io/channel-socket.c
|
|
|
719b13 |
+++ b/io/channel-socket.c
|
|
|
719b13 |
@@ -579,11 +579,17 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
|
|
|
719b13 |
memcpy(CMSG_DATA(cmsg), fds, fdsize);
|
|
|
719b13 |
}
|
|
|
719b13 |
|
|
|
719b13 |
-#ifdef QEMU_MSG_ZEROCOPY
|
|
|
719b13 |
if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
|
|
|
719b13 |
+#ifdef QEMU_MSG_ZEROCOPY
|
|
|
719b13 |
sflags = MSG_ZEROCOPY;
|
|
|
719b13 |
- }
|
|
|
719b13 |
+#else
|
|
|
719b13 |
+ /*
|
|
|
719b13 |
+ * We expect QIOChannel class entry point to have
|
|
|
719b13 |
+ * blocked this code path already
|
|
|
719b13 |
+ */
|
|
|
719b13 |
+ g_assert_not_reached();
|
|
|
719b13 |
#endif
|
|
|
719b13 |
+ }
|
|
|
719b13 |
|
|
|
719b13 |
retry:
|
|
|
719b13 |
ret = sendmsg(sioc->fd, &msg, sflags);
|
|
|
719b13 |
@@ -593,15 +599,13 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
|
|
|
719b13 |
return QIO_CHANNEL_ERR_BLOCK;
|
|
|
719b13 |
case EINTR:
|
|
|
719b13 |
goto retry;
|
|
|
719b13 |
-#ifdef QEMU_MSG_ZEROCOPY
|
|
|
719b13 |
case ENOBUFS:
|
|
|
719b13 |
- if (sflags & MSG_ZEROCOPY) {
|
|
|
719b13 |
+ if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
|
|
|
719b13 |
error_setg_errno(errp, errno,
|
|
|
719b13 |
"Process can't lock enough memory for using MSG_ZEROCOPY");
|
|
|
719b13 |
return -1;
|
|
|
719b13 |
}
|
|
|
719b13 |
break;
|
|
|
719b13 |
-#endif
|
|
|
719b13 |
}
|
|
|
719b13 |
|
|
|
719b13 |
error_setg_errno(errp, errno,
|
|
|
719b13 |
--
|
|
|
719b13 |
2.35.3
|
|
|
719b13 |
|