Re: [RFC PATCH v2 6/8] io: Plumb read flags into qio_channel_read_all_eof

2025-02-07 Thread Daniel P . Berrangé
On Fri, Feb 07, 2025 at 11:27:56AM -0300, Fabiano Rosas wrote:
> We want to pass flags into qio_channel_tls_readv() but some functions
> along the way don't take a flags argument. Plumb the flags through.
> 
> No functional change.
> 
> Signed-off-by: Fabiano Rosas 
> ---

> diff --git a/include/io/channel.h b/include/io/channel.h
> index bdf0bca92a..6110f0ffe9 100644
> --- a/include/io/channel.h
> +++ b/include/io/channel.h
> @@ -298,6 +298,7 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
>   * @ioc: the channel object
>   * @iov: the array of memory regions to read data into
>   * @niov: the length of the @iov array
> + * @flags: read flags (QIO_CHANNEL_READ_FLAG_*)
>   * @errp: pointer to a NULL-initialized error object
>   *
>   * Read data from the IO channel, storing it in the
> @@ -321,6 +322,7 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
>  int coroutine_mixed_fn qio_channel_readv_all_eof(QIOChannel *ioc,
>   const struct iovec *iov,
>   size_t niov,
> + int flags,
>   Error **errp);
>  
>  /**
> @@ -442,6 +444,7 @@ ssize_t qio_channel_write(QIOChannel *ioc,
>   * @ioc: the channel object
>   * @buf: the memory region to read data into
>   * @buflen: the number of bytes to @buf
> + * @flags: read flags (QIO_CHANNEL_READ_FLAG_*)
>   * @errp: pointer to a NULL-initialized error object
>   *
>   * Reads @buflen bytes into @buf, possibly blocking or (if the
> @@ -457,6 +460,7 @@ ssize_t qio_channel_write(QIOChannel *ioc,
>  int coroutine_mixed_fn qio_channel_read_all_eof(QIOChannel *ioc,
>  char *buf,
>  size_t buflen,
> +int flags,
>  Error **errp);
>

The 'int flags' parameter is intended to only be added to the
"_full" method variants since it is niche usage, so these two
shouldn't be changed.

>  /**
> @@ -885,6 +889,7 @@ void qio_channel_set_aio_fd_handler(QIOChannel *ioc,
>   * @niov: the length of the @iov array
>   * @fds: an array of file handles to read
>   * @nfds: number of file handles in @fds
> + * @flags: read flags (QIO_CHANNEL_READ_FLAG_*)
>   * @errp: pointer to a NULL-initialized error object
>   *
>   *
> @@ -903,6 +908,7 @@ int coroutine_mixed_fn 
> qio_channel_readv_full_all_eof(QIOChannel *ioc,
>const struct iovec 
> *iov,
>size_t niov,
>int **fds, size_t 
> *nfds,
> +  int flags,
>Error **errp);

This is ok, and migration code should switch to calling this
method instead of qio_channel_readv_all_eof to make use of flags.

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|




[RFC PATCH v2 6/8] io: Plumb read flags into qio_channel_read_all_eof

2025-02-07 Thread Fabiano Rosas
We want to pass flags into qio_channel_tls_readv() but some functions
along the way don't take a flags argument. Plumb the flags through.

No functional change.

Signed-off-by: Fabiano Rosas 
---
 hw/remote/mpqemu-link.c   |  2 +-
 include/io/channel.h  |  6 ++
 io/channel.c  | 13 +
 migration/multifd.c   |  2 +-
 tools/i386/qemu-vmsr-helper.c |  3 ++-
 util/vhost-user-server.c  |  2 +-
 6 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/hw/remote/mpqemu-link.c b/hw/remote/mpqemu-link.c
index e25f97680d..49885a1db6 100644
--- a/hw/remote/mpqemu-link.c
+++ b/hw/remote/mpqemu-link.c
@@ -110,7 +110,7 @@ static ssize_t mpqemu_read(QIOChannel *ioc, void *buf, 
size_t len, int **fds,
 bql_unlock();
 }
 
-ret = qio_channel_readv_full_all_eof(ioc, &iov, 1, fds, nfds, errp);
+ret = qio_channel_readv_full_all_eof(ioc, &iov, 1, fds, nfds, 0, errp);
 
 if (drop_bql && !iothread && !qemu_in_coroutine()) {
 bql_lock();
diff --git a/include/io/channel.h b/include/io/channel.h
index bdf0bca92a..6110f0ffe9 100644
--- a/include/io/channel.h
+++ b/include/io/channel.h
@@ -298,6 +298,7 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
  * @ioc: the channel object
  * @iov: the array of memory regions to read data into
  * @niov: the length of the @iov array
+ * @flags: read flags (QIO_CHANNEL_READ_FLAG_*)
  * @errp: pointer to a NULL-initialized error object
  *
  * Read data from the IO channel, storing it in the
@@ -321,6 +322,7 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
 int coroutine_mixed_fn qio_channel_readv_all_eof(QIOChannel *ioc,
  const struct iovec *iov,
  size_t niov,
+ int flags,
  Error **errp);
 
 /**
@@ -442,6 +444,7 @@ ssize_t qio_channel_write(QIOChannel *ioc,
  * @ioc: the channel object
  * @buf: the memory region to read data into
  * @buflen: the number of bytes to @buf
+ * @flags: read flags (QIO_CHANNEL_READ_FLAG_*)
  * @errp: pointer to a NULL-initialized error object
  *
  * Reads @buflen bytes into @buf, possibly blocking or (if the
@@ -457,6 +460,7 @@ ssize_t qio_channel_write(QIOChannel *ioc,
 int coroutine_mixed_fn qio_channel_read_all_eof(QIOChannel *ioc,
 char *buf,
 size_t buflen,
+int flags,
 Error **errp);
 
 /**
@@ -885,6 +889,7 @@ void qio_channel_set_aio_fd_handler(QIOChannel *ioc,
  * @niov: the length of the @iov array
  * @fds: an array of file handles to read
  * @nfds: number of file handles in @fds
+ * @flags: read flags (QIO_CHANNEL_READ_FLAG_*)
  * @errp: pointer to a NULL-initialized error object
  *
  *
@@ -903,6 +908,7 @@ int coroutine_mixed_fn 
qio_channel_readv_full_all_eof(QIOChannel *ioc,
   const struct iovec *iov,
   size_t niov,
   int **fds, size_t *nfds,
+  int flags,
   Error **errp);
 
 /**
diff --git a/io/channel.c b/io/channel.c
index e3f17c24a0..61e09202f1 100644
--- a/io/channel.c
+++ b/io/channel.c
@@ -113,9 +113,11 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
 int coroutine_mixed_fn qio_channel_readv_all_eof(QIOChannel *ioc,
  const struct iovec *iov,
  size_t niov,
+ int flags,
  Error **errp)
 {
-return qio_channel_readv_full_all_eof(ioc, iov, niov, NULL, NULL, errp);
+return qio_channel_readv_full_all_eof(ioc, iov, niov, NULL, NULL, flags,
+  errp);
 }
 
 int coroutine_mixed_fn qio_channel_readv_all(QIOChannel *ioc,
@@ -130,6 +132,7 @@ int coroutine_mixed_fn 
qio_channel_readv_full_all_eof(QIOChannel *ioc,
   const struct iovec *iov,
   size_t niov,
   int **fds, size_t *nfds,
+  int flags,
   Error **errp)
 {
 int ret = -1;
@@ -155,7 +158,7 @@ int coroutine_mixed_fn 
qio_channel_readv_full_all_eof(QIOChannel *ioc,
 while ((nlocal_iov > 0) || local_fds) {
 ssize_t len;
 len = qio_channel_readv_full(ioc, local_iov, nlocal_iov, local_fds,
- local_nfds, 0, errp);