On Tuesday, April 08, 2025 07:25 CEST, Prasad Pandit <ppan...@redhat.com> wrote:

> *  _channel_preadv/_writev functions are generic. They are independent
> of whether the underlying channel is file or socket or memory or
> something else. They are called if and when they are defined and they
> in turn call channel specific preadv/pwritev functions.
> 
>         if (!klass->io_pwritev) {
>             error_setg(errp, "Channel does not support pwritev");
>             return -1;
>         }

They also require QIO_CHANNEL_FEATURE_SEEKABLE.
    if (!qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_SEEKABLE)) {
        error_setg_errno(errp, EINVAL, "Requested channel is not seekable");
        return -1;
    }

> * io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for channel file
>     -> 
> https://gitlab.com/qemu-project/qemu/-/commit/401e311ff72e0a62c834bfe466de68a82cfd90cb
> 
>    This commit sets the *_FEATURE_SEEKABLE flag for the file channel
> when the lseek(2) call succeeds.

The QIOChannelBlock io_seek (qio_channel_block_seek) function
cannot fail for SEEK_CUR, no need to check.

> * ie. 'file' OR 'fd' channel is seekable when lseek(2) call works.
> Similarly Block channel would be seekable when ->io_seek() method is
> defined and it works. And ->io_seek() method is also called if and
> when it is defined
> 
>     qio_channel_io_seek
>         if (!klass->io_seek) {
>             error_setg(errp, "Channel does not support random
> access");
>             return -1;
>         }
>
>   Setting  '*_FEATURE_SEEKABLE' for the block channel does not ensure
> that ->io_seek() is defined and works.

QIOChannelBlock io_seek is always implemented and works
(except for SEEK_END).
 
> It seems redundant that way.

I'm not sure I understand what you mean here.

TLDR: QIOChannelBlock is already always seekable, this patch just adds
the capability explicitly so that it will work with mapped-ram.

Best
Marco


Reply via email to