|
|
4841a6 |
From cbfaf86331c2b2e01a2083303b7554672bf991b7 Mon Sep 17 00:00:00 2001
|
|
|
719b13 |
From: Leonardo Bras <leobras@redhat.com>
|
|
|
719b13 |
Date: Mon, 20 Jun 2022 02:39:42 -0300
|
|
|
4841a6 |
Subject: [PATCH 24/37] 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>
|
|
|
4841a6 |
RH-MergeRequest: 191: MSG_ZEROCOPY + Multifd @ rhel8.7
|
|
|
4841a6 |
RH-Commit: [24/26] b50e2e65307149f247155a7f7a032dc99e57718d
|
|
|
4841a6 |
RH-Bugzilla: 2072049
|
|
|
719b13 |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
4841a6 |
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
4841a6 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@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 |
|