[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/11] io: Add preadv support to QIOChannelFile
From: |
Nikolay Borisov |
Subject: |
[PATCH 06/11] io: Add preadv support to QIOChannelFile |
Date: |
Tue, 4 Oct 2022 15:37:28 +0300 |
preadv is going to be needed when 'fixed-ram'-enabled stream are to be
restored. Simply add a wrapper around preadv that's specific to
QIOChannelFile.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
include/io/channel-file.h | 5 +++++
io/channel-file.c | 26 ++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/include/io/channel-file.h b/include/io/channel-file.h
index 0a5d54f5e58e..2187f5affd23 100644
--- a/include/io/channel-file.h
+++ b/include/io/channel-file.h
@@ -89,6 +89,11 @@ qio_channel_file_new_path(const char *path,
mode_t mode,
Error **errp);
+ssize_t qio_channel_file_preadv(QIOChannel *ioc,
+ const struct iovec *iov,
+ size_t niov,
+ off_t offset,
+ Error **errp);
ssize_t qio_channel_file_pwritev(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
diff --git a/io/channel-file.c b/io/channel-file.c
index d84a6737f2f7..edca64ad63a7 100644
--- a/io/channel-file.c
+++ b/io/channel-file.c
@@ -141,6 +141,32 @@ static ssize_t qio_channel_file_writev(QIOChannel *ioc,
return ret;
}
+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;
+}
+
ssize_t qio_channel_file_pwritev(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
--
2.34.1
- [RFC PATCH 00/11] Add support for fixed ram offsets during migration, Nikolay Borisov, 2022/10/04
- [PATCH 01/11] migration: support file: uri for source migration, Nikolay Borisov, 2022/10/04
- [PATCH 10/11] migration: Add support for 'fixed-ram' migration restore, Nikolay Borisov, 2022/10/04
- [PATCH 11/11] analyze-migration.py: add initial support for fixed ram streams, Nikolay Borisov, 2022/10/04
- [PATCH 04/11] io: add pwritev support to QIOChannelFile, Nikolay Borisov, 2022/10/04
- [PATCH 03/11] migration: Make migration json writer part of MigrationState struct, Nikolay Borisov, 2022/10/04
- [PATCH 08/11] migration/ram: Introduce 'fixed-ram' migration stream capability, Nikolay Borisov, 2022/10/04
- [PATCH 07/11] migration: add qemu_get_buffer_at, Nikolay Borisov, 2022/10/04
- [PATCH 06/11] io: Add preadv support to QIOChannelFile,
Nikolay Borisov <=
- [PATCH 09/11] migration: Refactor precopy ram loading code, Nikolay Borisov, 2022/10/04
- [PATCH 02/11] migration: Add support for 'file:' uri for incoming migration, Nikolay Borisov, 2022/10/04
- [PATCH 05/11] io: Add support for seekable channels, Nikolay Borisov, 2022/10/04