Skip to content

Commit a15989d

Browse files
ebblakeMichael Tokarev
authored andcommitted
qio: Inherit follow_coroutine_ctx across TLS
Since qemu 8.2, the combination of NBD + TLS + iothread crashes on an assertion failure: qemu-kvm: ../io/channel.c:534: void qio_channel_restart_read(void *): Assertion `qemu_get_current_aio_context() == qemu_coroutine_get_aio_context(co)' failed. It turns out that when we removed AioContext locking, we did so by having NBD tell its qio channels that it wanted to opt in to qio_channel_set_follow_coroutine_ctx(); but while we opted in on the main channel, we did not opt in on the TLS wrapper channel. qemu-iotests has coverage of NBD+iothread and NBD+TLS, but apparently no coverage of NBD+TLS+iothread, or we would have noticed this regression sooner. (I'll add that in the next patch) But while we could manually opt in to the TLS channel in nbd/server.c (a one-line change), it is more generic if all qio channels that wrap other channels inherit the follow status, in the same way that they inherit feature bits. CC: Stefan Hajnoczi <[email protected]> CC: Daniel P. Berrangé <[email protected]> CC: [email protected] Fixes: https://issues.redhat.com/browse/RHEL-34786 Fixes: 06e0f09 ("io: follow coroutine AioContext in qio_channel_yield()", v8.2.0) Signed-off-by: Eric Blake <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Message-ID: <[email protected]> (cherry picked from commit 199e84d) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 1c8a740 commit a15989d

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

io/channel-tls.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,40 @@ qio_channel_tls_new_server(QIOChannel *master,
6969
const char *aclname,
7070
Error **errp)
7171
{
72-
QIOChannelTLS *ioc;
72+
QIOChannelTLS *tioc;
73+
QIOChannel *ioc;
7374

74-
ioc = QIO_CHANNEL_TLS(object_new(TYPE_QIO_CHANNEL_TLS));
75+
tioc = QIO_CHANNEL_TLS(object_new(TYPE_QIO_CHANNEL_TLS));
76+
ioc = QIO_CHANNEL(tioc);
7577

76-
ioc->master = master;
78+
tioc->master = master;
79+
ioc->follow_coroutine_ctx = master->follow_coroutine_ctx;
7780
if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) {
78-
qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_SHUTDOWN);
81+
qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
7982
}
8083
object_ref(OBJECT(master));
8184

82-
ioc->session = qcrypto_tls_session_new(
85+
tioc->session = qcrypto_tls_session_new(
8386
creds,
8487
NULL,
8588
aclname,
8689
QCRYPTO_TLS_CREDS_ENDPOINT_SERVER,
8790
errp);
88-
if (!ioc->session) {
91+
if (!tioc->session) {
8992
goto error;
9093
}
9194

9295
qcrypto_tls_session_set_callbacks(
93-
ioc->session,
96+
tioc->session,
9497
qio_channel_tls_write_handler,
9598
qio_channel_tls_read_handler,
96-
ioc);
99+
tioc);
97100

98-
trace_qio_channel_tls_new_server(ioc, master, creds, aclname);
99-
return ioc;
101+
trace_qio_channel_tls_new_server(tioc, master, creds, aclname);
102+
return tioc;
100103

101104
error:
102-
object_unref(OBJECT(ioc));
105+
object_unref(OBJECT(tioc));
103106
return NULL;
104107
}
105108

@@ -116,6 +119,7 @@ qio_channel_tls_new_client(QIOChannel *master,
116119
ioc = QIO_CHANNEL(tioc);
117120

118121
tioc->master = master;
122+
ioc->follow_coroutine_ctx = master->follow_coroutine_ctx;
119123
if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) {
120124
qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
121125
}

io/channel-websock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ qio_channel_websock_new_server(QIOChannel *master)
883883
ioc = QIO_CHANNEL(wioc);
884884

885885
wioc->master = master;
886+
ioc->follow_coroutine_ctx = master->follow_coroutine_ctx;
886887
if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) {
887888
qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
888889
}

0 commit comments

Comments
 (0)