[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 05/14] io: implement io_pwritev for QIOChannelFile
From: |
Nikolay Borisov |
Subject: |
[PATCH v3 05/14] io: implement io_pwritev for QIOChannelFile |
Date: |
Fri, 28 Oct 2022 13:39:05 +0300 |
The upcoming 'fixed-ram' feature would require qemu to write data at
specific offsets of the file. Add a minimal implementation of pwritev
and expose it via the io_pwritev interface.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
io/channel-file.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/io/channel-file.c b/io/channel-file.c
index b67687c2aa64..a7a90c12dc2b 100644
--- a/io/channel-file.c
+++ b/io/channel-file.c
@@ -136,6 +136,30 @@ static ssize_t qio_channel_file_writev(QIOChannel *ioc,
return ret;
}
+static ssize_t qio_channel_file_pwritev(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 = pwritev(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 write to file");
+ return -1;
+ }
+ return ret;
+}
+
static int qio_channel_file_set_blocking(QIOChannel *ioc,
bool enabled,
Error **errp)
@@ -218,6 +242,7 @@ static void qio_channel_file_class_init(ObjectClass *klass,
ioc_klass->io_writev = qio_channel_file_writev;
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_seek = qio_channel_file_seek;
ioc_klass->io_close = qio_channel_file_close;
ioc_klass->io_create_watch = qio_channel_file_create_watch;
--
2.34.1
- [PATCH v3 00/14] File-based migration support and fixed-ram features, Nikolay Borisov, 2022/10/28
- [PATCH v3 02/14] migration: Add support for 'file:' uri for incoming migration, Nikolay Borisov, 2022/10/28
- [PATCH v3 01/14] migration: support file: uri for source migration, Nikolay Borisov, 2022/10/28
- [PATCH v3 09/14] migration: add qemu_get_buffer_at, Nikolay Borisov, 2022/10/28
- [PATCH v3 04/14] io: Add generic pwritev/preadv interface, Nikolay Borisov, 2022/10/28
- [PATCH v3 03/14] migration: Initial support of fixed-ram feature for analyze-migration.py, Nikolay Borisov, 2022/10/28
- [PATCH v3 07/14] migration/qemu-file: add utility methods for working with seekable channels, Nikolay Borisov, 2022/10/28
- [PATCH v3 06/14] io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for channel file, Nikolay Borisov, 2022/10/28
- [PATCH v3 05/14] io: implement io_pwritev for QIOChannelFile,
Nikolay Borisov <=
- [PATCH v3 08/14] io: Add preadv support to QIOChannelFile, Nikolay Borisov, 2022/10/28
- [PATCH v3 14/14] tests/qtest: migration-test: Add tests for file-based migration, Nikolay Borisov, 2022/10/28
- [PATCH v3 11/14] migration: Refactor precopy ram loading code, Nikolay Borisov, 2022/10/28
- [PATCH v3 12/14] migration: Add support for 'fixed-ram' migration restore, Nikolay Borisov, 2022/10/28
- [PATCH v3 10/14] migration/ram: Introduce 'fixed-ram' migration stream capability, Nikolay Borisov, 2022/10/28
- [PATCH v3 13/14] tests: Add migrate_incoming_qmp helper, Nikolay Borisov, 2022/10/28