[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 06/34] io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for
From: |
Fabiano Rosas |
Subject: |
[PATCH v4 06/34] io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for channel file |
Date: |
Tue, 20 Feb 2024 19:41:10 -0300 |
From: Nikolay Borisov <nborisov@suse.com>
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 <nborisov@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
include/io/channel.h | 1 +
io/channel-file.c | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/include/io/channel.h b/include/io/channel.h
index 5f9dbaab65..fcb19fd672 100644
--- a/include/io/channel.h
+++ b/include/io/channel.h
@@ -44,6 +44,7 @@ enum QIOChannelFeature {
QIO_CHANNEL_FEATURE_LISTEN,
QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY,
QIO_CHANNEL_FEATURE_READ_MSG_PEEK,
+ QIO_CHANNEL_FEATURE_SEEKABLE,
};
diff --git a/io/channel-file.c b/io/channel-file.c
index 4a12c61886..f91bf6db1c 100644
--- a/io/channel-file.c
+++ b/io/channel-file.c
@@ -36,6 +36,10 @@ 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);
+ }
+
trace_qio_channel_file_new_fd(ioc, fd);
return ioc;
@@ -60,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.35.3
- [PATCH v4 01/34] docs/devel/migration.rst: Document the file transport, (continued)
- [PATCH v4 01/34] docs/devel/migration.rst: Document the file transport, Fabiano Rosas, 2024/02/20
- [PATCH v4 02/34] tests/qtest/migration: Rename fd_proto test, Fabiano Rosas, 2024/02/20
- [PATCH v4 03/34] tests/qtest/migration: Add a fd + file test, Fabiano Rosas, 2024/02/20
- [PATCH v4 04/34] migration/multifd: Remove p->quit from recv side, Fabiano Rosas, 2024/02/20
- [PATCH v4 05/34] migration/multifd: Release recv sem_sync earlier, Fabiano Rosas, 2024/02/20
- [PATCH v4 06/34] io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for channel file,
Fabiano Rosas <=
- [PATCH v4 07/34] io: Add generic pwritev/preadv interface, Fabiano Rosas, 2024/02/20
- [PATCH v4 08/34] io: implement io_pwritev/preadv for QIOChannelFile, Fabiano Rosas, 2024/02/20
- [PATCH v4 09/34] io: fsync before closing a file channel, Fabiano Rosas, 2024/02/20
- [PATCH v4 10/34] migration/qemu-file: add utility methods for working with seekable channels, Fabiano Rosas, 2024/02/20
- [PATCH v4 11/34] migration/ram: Introduce 'fixed-ram' migration capability, Fabiano Rosas, 2024/02/20
- Re: [PATCH v4 11/34] migration/ram: Introduce 'fixed-ram' migration capability, Peter Xu, 2024/02/25