migration: Add support for mapped-ram with snapshots
v2 cover migration: Add support for mapped-ram with snapshots
Add support for mapped-ram capability in combination with savevm/loadvm snapshots.
v2:
- Remove unnecessary CONFIG_PREADV ifdef macros
- Remove trivial doc fix since already queued
- Fix swapped parameters in handle_zero_mapped_ram calls
- Check for RUN_STATE_RESTORE_VM before zeoring instead of checking for run_state not in [RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE]
- Check for from >= to instead of from == to in handle_zero_mapped_ram
- Remove mapped_ram from snapshots incompatible options
- Rebase on top of
Based-on: <[email protected]>
([RESEND] migration/savevm: Add a compatibility check for capabilities)
v1:
https://lore.kernel.org/qemu-devel/[email protected]/
Thanks for the reviews on v1
Marco Cavenati (2):
migration: add FEATURE_SEEKABLE to QIOChannelBlock
migration: mapped-ram: handle zero pages
migration/channel-block.c | 44 +++++++++++++++++++++++++++++ migration/options.c | 1 - migration/ram.c | 59 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 102 insertions(+), 2 deletions(-)
Signature · 1 line
2.48.1
PATCH v2 1/2 migration: add FEATURE_SEEKABLE to QIOChannelBlock
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.
--- migration/channel-block.c | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
migration/channel-block.c +44 -0
@@ -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,47 @@ qio_channel_block_writev(QIOChannel *ioc,return qiov.size; } +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; +} static int qio_channel_block_set_blocking(QIOChannel *ioc,
@@ -177,6 +219,8 @@ 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; + ioc_klass->io_preadv = qio_channel_block_preadv; + ioc_klass->io_pwritev = qio_channel_block_pwritev; 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;
Signature · 1 line
2.48.1
PATCH v2 2/2 migration: mapped-ram: handle zero pages
In reply to Marco CavenatiMake mapped-ram compatible with loadvm snapshot restoring by explicitly zeroing memory pages in this case.
Skip zeroing for -incoming and -loadvm migrations to preserve performance.
--- migration/options.c | 1 - migration/ram.c | 59 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-)
migration/options.c +0 -1
@@ -449,7 +449,6 @@ INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snapshot,static const INITIALIZE_MIGRATE_CAPS_SET(check_caps_savevm, MIGRATION_CAPABILITY_MULTIFD, - MIGRATION_CAPABILITY_MAPPED_RAM, );static bool migrate_incoming_started (void )
migration/ram.c +58 -1
82 lines not on this page · raw message
Signature · 1 line
2.48.1
Peter Xu
AppliedQuoted 15 lines · Marco Cavenati
Add support for mapped-ram capability in combination with savevm/loadvm snapshots.
v2:
- Remove unnecessaryCONFIG_PREADVifdef macros
- Remove trivial doc fix since already queued
- Fix swapped parameters inhandle_zero_mapped_ramcalls
- Check forRUN_STATE_RESTORE_VMbefore zeoring instead of checking forrun_statenot in [RUN_STATE_PRELAUNCH,RUN_STATE_INMIGRATE]
- Check for from >= to instead of from == to inhandle_zero_mapped_ram
- Removemapped_ramfrom snapshots incompatible options
- Rebase on top of
Based-on: <[email protected]>
([RESEND] migration/savevm: Add a compatibility check for capabilities)
Quoted 4 lines
v1:
https://lore.kernel.org/qemu-devel/[email protected]/Thanks for the reviews on v1
queued, thanks.
Signature · 1 line
Peter Xu