On Fri, Oct 28, 2022 at 01:39:06PM +0300, Nikolay Borisov wrote: > 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 <nbori...@suse.com> > --- > include/io/channel.h | 1 + > io/channel-file.c | 9 +++++++++ > 2 files changed, 10 insertions(+) > > diff --git a/include/io/channel.h b/include/io/channel.h > index 6b10bce8bbdf..b645989e467c 100644 > --- a/include/io/channel.h > +++ b/include/io/channel.h > @@ -41,6 +41,7 @@ enum QIOChannelFeature { > QIO_CHANNEL_FEATURE_SHUTDOWN, > QIO_CHANNEL_FEATURE_LISTEN, > QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY, > + QIO_CHANNEL_FEATURE_SEEKABLE, > }; > > > diff --git a/io/channel-file.c b/io/channel-file.c > index a7a90c12dc2b..e213a0fd7cd2 100644 > --- a/io/channel-file.c > +++ b/io/channel-file.c > @@ -35,6 +35,11 @@ qio_channel_file_new_fd(int fd) > > ioc->fd = fd; > > + if (lseek(fd, 0, SEEK_CUR) != (off_t)-1) { > + qio_channel_set_feature(QIO_CHANNEL(ioc), > QIO_CHANNEL_FEATURE_SEEKABLE); > + } > + > + qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_SEEKABLE);
This second qio_channel_set_feature call is a rebase mistake I presume. With that removed, the rest of the patch looks fine Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> > trace_qio_channel_file_new_fd(ioc, fd); > > return ioc; > @@ -59,6 +64,10 @@ qio_channel_file_new_path(const char *path, > return NULL; > } > > + if (lseek(ioc->fd, 0, SEEK_CUR) != (off_t)-1) { > + qio_channel_set_feature(QIO_CHANNEL(ioc), > QIO_CHANNEL_FEATURE_SEEKABLE); > + } > + > trace_qio_channel_file_new_path(ioc, path, flags, mode, ioc->fd); > > return ioc; > -- > 2.34.1 > 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 :|