qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 08/14] io: Add preadv support to QIOChannelFile


From: Daniel P . Berrangé
Subject: Re: [PATCH v3 08/14] io: Add preadv support to QIOChannelFile
Date: Fri, 10 Feb 2023 16:59:57 +0000
User-agent: Mutt/2.2.9 (2022-11-12)

On Fri, Oct 28, 2022 at 01:39:08PM +0300, Nikolay Borisov wrote:
> preadv is going to be needed when 'fixed-ram'-enabled stream are to be
> restored. Add a minimal implementation of preadv for file channels and
> expose it via the generic io_preadv interface.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  io/channel-file.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/io/channel-file.c b/io/channel-file.c
> index e213a0fd7cd2..d2f4706b7f6d 100644
> --- a/io/channel-file.c
> +++ b/io/channel-file.c
> @@ -145,6 +145,32 @@ static ssize_t qio_channel_file_writev(QIOChannel *ioc,
>      return ret;
>  }
>  
> +static ssize_t qio_channel_file_preadv(QIOChannel *ioc,
> +                                       const struct iovec *iov,
> +                                       size_t niov,
> +                                       off_t offset,
> +                                       Error **errp)
> +{
> +    QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc);
> +    ssize_t ret;
> +
> + retry:
> +    ret = preadv(fioc->fd, iov, niov, offset);
> +    if (ret < 0) {
> +        if (errno == EAGAIN) {
> +            return QIO_CHANNEL_ERR_BLOCK;
> +        }
> +        if (errno == EINTR) {
> +            goto retry;
> +        }
> +
> +        error_setg_errno(errp, errno, "Unable to read from file");
> +        return -1;
> +    }
> +
> +    return ret;
> +}
> +
>  static ssize_t qio_channel_file_pwritev(QIOChannel *ioc,
>                                          const struct iovec *iov,
>                                          size_t niov,
> @@ -252,6 +278,7 @@ static void qio_channel_file_class_init(ObjectClass 
> *klass,
>      ioc_klass->io_readv = qio_channel_file_readv;
>      ioc_klass->io_set_blocking = qio_channel_file_set_blocking;
>      ioc_klass->io_pwritev = qio_channel_file_pwritev;
> +    ioc_klass->io_preadv = qio_channel_file_preadv;
>      ioc_klass->io_seek = qio_channel_file_seek;
>      ioc_klass->io_close = qio_channel_file_close;
>      ioc_klass->io_create_watch = qio_channel_file_create_watch;

I'd suggest this patch should just be merged into the patch which
adds the io_pwritev callback.


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 :|




reply via email to

[Prev in Thread] Current Thread [Next in Thread]