From: Fabiano Rosas <farosas@suse.de>
To: Marco Cavenati <Marco.Cavenati@eurecom.fr>, Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org,
"Marco Cavenati" <Marco.Cavenati@eurecom.fr>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Prasad Pandit" <ppandit@redhat.com>
Subject: Re: [PATCH] migration: add FEATURE_SEEKABLE to QIOChannelBlock
Date: Thu, 10 Apr 2025 16:52:41 -0300 [thread overview]
Message-ID: <87jz7rhjzq.fsf@suse.de> (raw)
In-Reply-To: <20250327141451.163744-3-Marco.Cavenati@eurecom.fr>
Marco Cavenati <Marco.Cavenati@eurecom.fr> writes:
> Enable the use of the mapped-ram migration feature with savevm/loadvm
> snapshots by adding the QIO_CHANNEL_FEATURE_SEEKABLE feature to
> QIOChannelBlock. Implement io_preadv and io_pwritev methods to provide
> positioned I/O capabilities that don't modify the channel's position
> pointer.
We'll need to add the infrastructure to reject multifd and direct-io
before this. The rest of the capabilities should not affect mapped-ram,
so it's fine (for now) if we don't honor them.
What about zero page handling? Mapped-ram doesn't send zero pages
because the file will always have zeroes in it and the migration
destination is guaranteed to not have been running previously. I believe
loading a snapshot in a VM that's already been running would leave stale
data in the guest's memory.
>
> Signed-off-by: Marco Cavenati <Marco.Cavenati@eurecom.fr>
> ---
> Hello,
> Please note that this depends on my previous fix [0] (which has already
> been reviewed) in order to work.
>
> The code in this patch is inspired by commit
> 0478b030fa2530cbbfc4d6432e8e39a16d06865b that adds the same feature to
> QIOChannelFile.
>
> Thank you,
> Regards
> Marco
>
> [0] [PATCH] migration: fix SEEK_CUR offset calculation in
> qio_channel_block_seek https://lore.kernel.org/all/20250326162230.3323199-1-Marco.Cavenati@eurecom.fr/t/#u
> ---
> migration/channel-block.c | 48 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 48 insertions(+)
>
> diff --git a/migration/channel-block.c b/migration/channel-block.c
> index fff8d87094..741cf6f31b 100644
> --- a/migration/channel-block.c
> +++ b/migration/channel-block.c
> @@ -30,6 +30,7 @@ qio_channel_block_new(BlockDriverState *bs)
> QIOChannelBlock *ioc;
>
> ioc = QIO_CHANNEL_BLOCK(object_new(TYPE_QIO_CHANNEL_BLOCK));
> + qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_SEEKABLE);
>
> bdrv_ref(bs);
> ioc->bs = bs;
> @@ -96,6 +97,49 @@ qio_channel_block_writev(QIOChannel *ioc,
> return qiov.size;
> }
>
> +#ifdef CONFIG_PREADV
> +static ssize_t
> +qio_channel_block_preadv(QIOChannel *ioc,
> + const struct iovec *iov,
> + size_t niov,
> + off_t offset,
> + Error **errp)
> +{
> + QIOChannelBlock *bioc = QIO_CHANNEL_BLOCK(ioc);
> + QEMUIOVector qiov;
> + int ret;
> +
> + qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
> + ret = bdrv_readv_vmstate(bioc->bs, &qiov, offset);
> + if (ret < 0) {
> + error_setg_errno(errp, -ret, "bdrv_readv_vmstate failed");
> + return -1;
> + }
> +
> + return qiov.size;
> +}
> +
> +static ssize_t
> +qio_channel_block_pwritev(QIOChannel *ioc,
> + const struct iovec *iov,
> + size_t niov,
> + off_t offset,
> + Error **errp)
> +{
> + QIOChannelBlock *bioc = QIO_CHANNEL_BLOCK(ioc);
> + QEMUIOVector qiov;
> + int ret;
> +
> + qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
> + ret = bdrv_writev_vmstate(bioc->bs, &qiov, offset);
> + if (ret < 0) {
> + error_setg_errno(errp, -ret, "bdrv_writev_vmstate failed");
> + return -1;
> + }
> +
> + return qiov.size;
> +}
> +#endif /* CONFIG_PREADV */
>
> static int
> qio_channel_block_set_blocking(QIOChannel *ioc,
> @@ -177,6 +221,10 @@ qio_channel_block_class_init(ObjectClass *klass,
> ioc_klass->io_writev = qio_channel_block_writev;
> ioc_klass->io_readv = qio_channel_block_readv;
> ioc_klass->io_set_blocking = qio_channel_block_set_blocking;
> +#ifdef CONFIG_PREADV
> + ioc_klass->io_preadv = qio_channel_block_preadv;
> + ioc_klass->io_pwritev = qio_channel_block_pwritev;
> +#endif
> ioc_klass->io_seek = qio_channel_block_seek;
> ioc_klass->io_close = qio_channel_block_close;
> ioc_klass->io_set_aio_fd_handler = qio_channel_block_set_aio_fd_handler;
next prev parent reply other threads:[~2025-04-10 19:53 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 14:14 [PATCH] migration: add FEATURE_SEEKABLE to QIOChannelBlock Marco Cavenati
2025-04-04 8:19 ` Prasad Pandit
2025-04-04 9:04 ` Marco Cavenati
2025-04-04 10:14 ` Prasad Pandit
2025-04-04 12:05 ` Marco Cavenati
2025-04-07 6:47 ` Prasad Pandit
2025-04-07 9:00 ` Marco Cavenati
2025-04-08 5:25 ` Prasad Pandit
2025-04-08 15:03 ` Marco Cavenati
2025-04-15 10:21 ` Daniel P. Berrangé
2025-04-15 10:44 ` Prasad Pandit
2025-04-15 11:03 ` Daniel P. Berrangé
2025-04-15 11:57 ` Prasad Pandit
2025-04-15 12:03 ` Daniel P. Berrangé
2025-04-10 19:52 ` Fabiano Rosas [this message]
2025-04-11 8:48 ` Marco Cavenati
2025-04-11 12:24 ` Fabiano Rosas
2025-04-15 10:15 ` Marco Cavenati
2025-04-15 13:50 ` Fabiano Rosas
2025-04-17 9:10 ` Marco Cavenati
2025-04-17 15:12 ` Fabiano Rosas
2025-04-24 13:44 ` Marco Cavenati
2025-05-08 20:23 ` Peter Xu
2025-05-09 12:51 ` Marco Cavenati
2025-05-09 16:21 ` Peter Xu
2025-05-09 21:14 ` Marco Cavenati
2025-05-09 22:04 ` Peter Xu
2025-09-16 16:06 ` Marco Cavenati
2025-09-19 21:24 ` Fabiano Rosas
2025-09-22 15:51 ` Marco Cavenati
2025-09-30 20:12 ` Fabiano Rosas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jz7rhjzq.fsf@suse.de \
--to=farosas@suse.de \
--cc=Marco.Cavenati@eurecom.fr \
--cc=berrange@redhat.com \
--cc=peterx@redhat.com \
--cc=ppandit@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.