<feed xmlns='http://www.w3.org/2005/Atom'>
<title>qemu/include/io, branch master</title>
<subtitle>QEMU development tree</subtitle>
<id>https://git.zx2c4.com/qemu/atom/include/io?h=master</id>
<link rel='self' href='https://git.zx2c4.com/qemu/atom/include/io?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/'/>
<updated>2024-07-22T11:47:41Z</updated>
<entry>
<title>qio: add support for SO_PEERCRED for socket channel</title>
<updated>2024-07-22T11:47:41Z</updated>
<author>
<name>Anthony Harivel</name>
<email>aharivel@redhat.com</email>
</author>
<published>2024-05-22T15:34:50Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=95fa0c79a04f3ebebb9f3b68cc05b4b8082b5444'/>
<id>urn:sha1:95fa0c79a04f3ebebb9f3b68cc05b4b8082b5444</id>
<content type='text'>
The function qio_channel_get_peercred() returns a pointer to the
credentials of the peer process connected to this socket.

This credentials structure is defined in &lt;sys/socket.h&gt; as follows:

struct ucred {
	pid_t pid;    /* Process ID of the sending process */
	uid_t uid;    /* User ID of the sending process */
	gid_t gid;    /* Group ID of the sending process */
};

The use of this function is possible only for connected AF_UNIX stream
sockets and for AF_UNIX stream and datagram socket pairs.

On platform other than Linux, the function return 0.

Signed-off-by: Anthony Harivel &lt;aharivel@redhat.com&gt;
Link: https://lore.kernel.org/r/20240522153453.1230389-2-aharivel@redhat.com
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
</content>
</entry>
<entry>
<title>io: Introduce qio_channel_file_new_dupfd</title>
<updated>2024-03-12T19:22:23Z</updated>
<author>
<name>Fabiano Rosas</name>
<email>farosas@suse.de</email>
</author>
<published>2024-03-11T23:33:34Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=4760cedc61328e47bf7f1fabceb9937facfa4cdd'/>
<id>urn:sha1:4760cedc61328e47bf7f1fabceb9937facfa4cdd</id>
<content type='text'>
Add a new helper function for creating a QIOChannelFile channel with a
duplicated file descriptor. This saves the calling code from having to
do error checking on the dup() call.

Suggested-by: "Daniel P. Berrangé" &lt;berrange@redhat.com&gt;
Signed-off-by: Fabiano Rosas &lt;farosas@suse.de&gt;
Reviewed-by: "Daniel P. Berrangé" &lt;berrange@redhat.com&gt;
Link: https://lore.kernel.org/r/20240311233335.17299-2-farosas@suse.de
Signed-off-by: Peter Xu &lt;peterx@redhat.com&gt;
</content>
</entry>
<entry>
<title>io: Add generic pwritev/preadv interface</title>
<updated>2024-03-01T07:42:04Z</updated>
<author>
<name>Nikolay Borisov</name>
<email>nborisov@suse.com</email>
</author>
<published>2024-02-29T15:29:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=f1cfe39418a837e8dd52a7e75331f1606949deff'/>
<id>urn:sha1:f1cfe39418a837e8dd52a7e75331f1606949deff</id>
<content type='text'>
Introduce basic pwritev/preadv support in the generic channel layer.
Specific implementation will follow for the file channel as this is
required in order to support migration streams with fixed location of
each ram page.

Signed-off-by: Nikolay Borisov &lt;nborisov@suse.com&gt;
Reviewed-by: "Daniel P. Berrangé" &lt;berrange@redhat.com&gt;
Reviewed-by: Peter Xu &lt;peterx@redhat.com&gt;
Signed-off-by: Fabiano Rosas &lt;farosas@suse.de&gt;
Link: https://lore.kernel.org/r/20240229153017.2221-4-farosas@suse.de
Signed-off-by: Peter Xu &lt;peterx@redhat.com&gt;
</content>
</entry>
<entry>
<title>io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for channel file</title>
<updated>2024-03-01T07:42:04Z</updated>
<author>
<name>Nikolay Borisov</name>
<email>nborisov@suse.com</email>
</author>
<published>2024-02-29T15:29:56Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=401e311ff72e0a62c834bfe466de68a82cfd90cb'/>
<id>urn:sha1:401e311ff72e0a62c834bfe466de68a82cfd90cb</id>
<content type='text'>
Add a generic QIOChannel feature SEEKABLE which would be used by the
qemu_file* apis. For the time being this will be only implemented for
file channels.

Signed-off-by: Nikolay Borisov &lt;nborisov@suse.com&gt;
Reviewed-by: "Daniel P. Berrangé" &lt;berrange@redhat.com&gt;
Reviewed-by: Peter Xu &lt;peterx@redhat.com&gt;
Signed-off-by: Fabiano Rosas &lt;farosas@suse.de&gt;
Link: https://lore.kernel.org/r/20240229153017.2221-3-farosas@suse.de
Signed-off-by: Peter Xu &lt;peterx@redhat.com&gt;
</content>
</entry>
<entry>
<title>Rename "QEMU global mutex" to "BQL" in comments and docs</title>
<updated>2024-01-08T15:45:43Z</updated>
<author>
<name>Stefan Hajnoczi</name>
<email>stefanha@redhat.com</email>
</author>
<published>2024-01-02T15:35:29Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=0b2675c473f68f13bc5ca1dd1c43ce421542e7b8'/>
<id>urn:sha1:0b2675c473f68f13bc5ca1dd1c43ce421542e7b8</id>
<content type='text'>
The term "QEMU global mutex" is identical to the more widely used Big
QEMU Lock ("BQL"). Update the code comments and documentation to use
"BQL" instead of "QEMU global mutex".

Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
Acked-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Reviewed-by: Philippe Mathieu-Daudé &lt;philmd@linaro.org&gt;
Reviewed-by: Paul Durrant &lt;paul@xen.org&gt;
Reviewed-by: Akihiko Odaki &lt;akihiko.odaki@daynix.com&gt;
Reviewed-by: Cédric Le Goater &lt;clg@kaod.org&gt;
Reviewed-by: Harsh Prateek Bora &lt;harshpb@linux.ibm.com&gt;
Message-id: 20240102153529.486531-6-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
</content>
</entry>
<entry>
<title>io: follow coroutine AioContext in qio_channel_yield()</title>
<updated>2023-09-08T01:32:11Z</updated>
<author>
<name>Stefan Hajnoczi</name>
<email>stefanha@redhat.com</email>
</author>
<published>2023-08-30T22:48:02Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=06e0f098d612df79597de58121dadf6f5f375d04'/>
<id>urn:sha1:06e0f098d612df79597de58121dadf6f5f375d04</id>
<content type='text'>
The ongoing QEMU multi-queue block layer effort makes it possible for multiple
threads to process I/O in parallel. The nbd block driver is not compatible with
the multi-queue block layer yet because QIOChannel cannot be used easily from
coroutines running in multiple threads. This series changes the QIOChannel API
to make that possible.

In the current API, calling qio_channel_attach_aio_context() sets the
AioContext where qio_channel_yield() installs an fd handler prior to yielding:

  qio_channel_attach_aio_context(ioc, my_ctx);
  ...
  qio_channel_yield(ioc); // my_ctx is used here
  ...
  qio_channel_detach_aio_context(ioc);

This API design has limitations: reading and writing must be done in the same
AioContext and moving between AioContexts involves a cumbersome sequence of API
calls that is not suitable for doing on a per-request basis.

There is no fundamental reason why a QIOChannel needs to run within the
same AioContext every time qio_channel_yield() is called. QIOChannel
only uses the AioContext while inside qio_channel_yield(). The rest of
the time, QIOChannel is independent of any AioContext.

In the new API, qio_channel_yield() queries the AioContext from the current
coroutine using qemu_coroutine_get_aio_context(). There is no need to
explicitly attach/detach AioContexts anymore and
qio_channel_attach_aio_context() and qio_channel_detach_aio_context() are gone.
One coroutine can read from the QIOChannel while another coroutine writes from
a different AioContext.

This API change allows the nbd block driver to use QIOChannel from any thread.
It's important to keep in mind that the block driver already synchronizes
QIOChannel access and ensures that two coroutines never read simultaneously or
write simultaneously.

This patch updates all users of qio_channel_attach_aio_context() to the
new API. Most conversions are simple, but vhost-user-server requires a
new qemu_coroutine_yield() call to quiesce the vu_client_trip()
coroutine when not attached to any AioContext.

While the API is has become simpler, there is one wart: QIOChannel has a
special case for the iohandler AioContext (used for handlers that must not run
in nested event loops). I didn't find an elegant way preserve that behavior, so
I added a new API called qio_channel_set_follow_coroutine_ctx(ioc, true|false)
for opting in to the new AioContext model. By default QIOChannel uses the
iohandler AioHandler. Code that formerly called
qio_channel_attach_aio_context() now calls
qio_channel_set_follow_coroutine_ctx(ioc, true) once after the QIOChannel is
created.

Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Acked-by: Daniel P. Berrangé &lt;berrange@redhat.com&gt;
Message-ID: &lt;20230830224802.493686-5-stefanha@redhat.com&gt;
[eblake: also fix migration/rdma.c]
Signed-off-by: Eric Blake &lt;eblake@redhat.com&gt;
</content>
</entry>
<entry>
<title>util: spelling fixes</title>
<updated>2023-08-31T17:47:43Z</updated>
<author>
<name>Michael Tokarev</name>
<email>mjt@tls.msk.ru</email>
</author>
<published>2023-08-23T06:53:15Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=d02d06f8f1299eb7a4422c283b9b9cbb4deb0cf9'/>
<id>urn:sha1:d02d06f8f1299eb7a4422c283b9b9cbb4deb0cf9</id>
<content type='text'>
Signed-off-by: Michael Tokarev &lt;mjt@tls.msk.ru&gt;
Reviewed-by: Philippe Mathieu-Daudé &lt;philmd@linaro.org&gt;
Message-ID: &lt;20230823065335.1919380-3-mjt@tls.msk.ru&gt;
Signed-off-by: Philippe Mathieu-Daudé &lt;philmd@linaro.org&gt;
</content>
</entry>
<entry>
<title>io: remove io watch if TLS channel is closed during handshake</title>
<updated>2023-08-01T17:45:27Z</updated>
<author>
<name>Daniel P. Berrangé</name>
<email>berrange@redhat.com</email>
</author>
<published>2023-06-20T08:45:34Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=10be627d2b5ec2d6b3dce045144aa739eef678b4'/>
<id>urn:sha1:10be627d2b5ec2d6b3dce045144aa739eef678b4</id>
<content type='text'>
The TLS handshake make take some time to complete, during which time an
I/O watch might be registered with the main loop. If the owner of the
I/O channel invokes qio_channel_close() while the handshake is waiting
to continue the I/O watch must be removed. Failing to remove it will
later trigger the completion callback which the owner is not expecting
to receive. In the case of the VNC server, this results in a SEGV as
vnc_disconnect_start() tries to shutdown a client connection that is
already gone / NULL.

CVE-2023-3354
Reported-by: jiangyegen &lt;jiangyegen@huawei.com&gt;
Signed-off-by: Daniel P. Berrangé &lt;berrange@redhat.com&gt;
</content>
</entry>
<entry>
<title>nbd/server: Fix drained_poll to wake coroutine in right AioContext</title>
<updated>2023-05-19T17:16:53Z</updated>
<author>
<name>Kevin Wolf</name>
<email>kwolf@redhat.com</email>
</author>
<published>2023-05-17T15:28:33Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=7c1f51bf38de8cea4ed5030467646c37b46edeb7'/>
<id>urn:sha1:7c1f51bf38de8cea4ed5030467646c37b46edeb7</id>
<content type='text'>
nbd_drained_poll() generally runs in the main thread, not whatever
iothread the NBD server coroutine is meant to run in, so it can't
directly reenter the coroutines to wake them up.

The code seems to have the right intention, it specifies the correct
AioContext when it calls qemu_aio_coroutine_enter(). However, this
functions doesn't schedule the coroutine to run in that AioContext, but
it assumes it is already called in the home thread of the AioContext.

To fix this, add a new thread-safe qio_channel_wake_read() that can be
called in the main thread to wake up the coroutine in its AioContext,
and use this in nbd_drained_poll().

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
Message-Id: &lt;20230517152834.277483-3-kwolf@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Signed-off-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
</content>
</entry>
<entry>
<title>io: mark mixed functions that can suspend</title>
<updated>2023-04-20T09:17:35Z</updated>
<author>
<name>Paolo Bonzini</name>
<email>pbonzini@redhat.com</email>
</author>
<published>2022-12-16T11:47:58Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=1dd91b22a620616cad08bee7efc29280121ff0da'/>
<id>urn:sha1:1dd91b22a620616cad08bee7efc29280121ff0da</id>
<content type='text'>
There should be no paths from a coroutine_fn to aio_poll, however in
practice coroutine_mixed_fn will call aio_poll in the !qemu_in_coroutine()
path.  By marking mixed functions, we can track accurately the call paths
that execute entirely in coroutine context, and find more missing
coroutine_fn markers.  This results in more accurate checks that
coroutine code does not end up blocking.

If the marking were extended transitively to all functions that call
these ones, static analysis could be done much more efficiently.
However, this is a start and makes it possible to use vrc's path-based
searches to find potential bugs where coroutine_fns call blocking functions.

Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
</content>
</entry>
</feed>
