From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
"Dr . David Alan Gilbert" <dave@treblig.org>,
Eric Blake <eblake@redhat.com>
Subject: [PATCH v2 16/18] migration: Add capabilities into MigrationParameters
Date: Wed, 9 Sep 2026 18:45:06 -0300 [thread overview]
Message-ID: <20260909214509.237309-17-farosas@suse.de> (raw)
In-Reply-To: <20260909214509.237309-1-farosas@suse.de>
Add capabilities to MigrationParameters. This structure will hold all
migration options. Capabilities will go away in the next patch.
From this point on, both QMP and HMP versions of
migrate-set-parameters and query-migrate-parameters gain the ability
to work with capabilities.
With MigrationParameters now having members for each capability, the
migration capabilities commands (query-migrate-capabilities,
migrate-set-capabilities) will soon be deprecated. Add a set of
helpers to convert between the old MigrationCapability representation
and the new representation as members of MigrationParameters.
Acked-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/migration.c | 8 +++
migration/options.c | 71 ++++++++++++++++++++++++
migration/options.h | 5 ++
qapi/migration.json | 124 ++++++++++++++++++++++++++++++++++++++++--
4 files changed, 204 insertions(+), 4 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index dab282dd2f..c8e7e86ea0 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -4086,6 +4086,14 @@ static bool migration_object_check(MigrationState *ms, Error **errp)
return false;
}
+ /*
+ * FIXME: Temporarily while -global capabilties are still using
+ * s->capabilities. Will be gone by the end of the series.
+ */
+ for (int i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
+ migrate_capability_set_compat(&ms->parameters, i, ms->capabilities[i]);
+ }
+
return migrate_caps_check(old_caps, ms->capabilities, errp);
}
diff --git a/migration/options.c b/migration/options.c
index 188c4ad20b..aff5d8f550 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -775,6 +775,52 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)
return true;
}
+static bool *migrate_capability_get_addr(MigrationParameters *params,
+ enum MigrationCapability i)
+{
+ bool *cap_addr[] = {
+ ¶ms->xbzrle, ¶ms->rdma_pin_all,
+ ¶ms->auto_converge, ¶ms->events, ¶ms->postcopy_ram,
+ ¶ms->x_colo, ¶ms->release_ram, ¶ms->return_path,
+ ¶ms->pause_before_switchover, ¶ms->multifd,
+ ¶ms->dirty_bitmaps, ¶ms->postcopy_blocktime,
+ ¶ms->late_block_activate, ¶ms->x_ignore_shared,
+ ¶ms->validate_uuid, ¶ms->background_snapshot,
+ ¶ms->zero_copy_send, ¶ms->postcopy_preempt,
+ ¶ms->switchover_ack, ¶ms->dirty_limit, ¶ms->mapped_ram,
+ };
+
+ assert(i >= 0 && i < MIGRATION_CAPABILITY__MAX);
+ return cap_addr[i];
+}
+
+/* Compatibility for code that reads capabilities in a loop */
+bool migrate_capability_get_compat(MigrationParameters *params, int i)
+{
+ return *(migrate_capability_get_addr(params, i));
+}
+
+/* Compatibility for code that writes capabilities in a loop */
+void migrate_capability_set_compat(MigrationParameters *params, int i, bool val)
+{
+ *(migrate_capability_get_addr(params, i)) = val;
+}
+
+/*
+ * Set capabilities for compatibility with the old
+ * migrate-set-capabilities command.
+ */
+void migrate_capabilities_set_compat(MigrationParameters *params,
+ MigrationCapabilityStatusList *caps)
+{
+ MigrationCapabilityStatusList *cap;
+
+ for (cap = caps; cap; cap = cap->next) {
+ migrate_capability_set_compat(params, cap->value->capability,
+ cap->value->state);
+ }
+}
+
MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp)
{
MigrationCapabilityStatusList *head = NULL, **tail = &head;
@@ -816,6 +862,8 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
for (cap = params; cap; cap = cap->next) {
s->capabilities[cap->value->capability] = cap->value->state;
}
+
+ migrate_capabilities_set_compat(&s->parameters, params);
}
/* parameters */
@@ -1139,6 +1187,15 @@ static void migrate_mark_all_params_present(MigrationParameters *p)
&p->has_x_vcpu_dirty_limit_period, &p->has_vcpu_dirty_limit,
&p->has_mode, &p->has_zero_page_detection, &p->has_direct_io,
&p->has_x_rdma_chunk_size, &p->has_cpr_exec_command,
+ &p->has_xbzrle, &p->has_rdma_pin_all,
+ &p->has_auto_converge, &p->has_events,
+ &p->has_postcopy_ram, &p->has_x_colo, &p->has_release_ram,
+ &p->has_return_path, &p->has_pause_before_switchover, &p->has_multifd,
+ &p->has_dirty_bitmaps, &p->has_postcopy_blocktime,
+ &p->has_late_block_activate, &p->has_x_ignore_shared,
+ &p->has_validate_uuid, &p->has_background_snapshot,
+ &p->has_zero_copy_send, &p->has_postcopy_preempt,
+ &p->has_switchover_ack, &p->has_dirty_limit, &p->has_mapped_ram,
};
len = ARRAY_SIZE(has_fields);
@@ -1414,6 +1471,20 @@ void qmp_migrate_set_parameters(MigrationParameters *input, Error **errp)
tls_opt_to_str(input->tls_hostname);
tls_opt_to_str(input->tls_authz);
+ /*
+ * FIXME: Temporarily while migrate_caps_check is not
+ * converted to look at s->parameters. Will be gone the end of
+ * the series.
+ */
+ bool new_caps[MIGRATION_CAPABILITY__MAX] = { 0 };
+ for (int i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
+ new_caps[i] = migrate_capability_get_compat(cur, i);
+ }
+ if (!migrate_caps_check(migrate_get_current()->capabilities, new_caps,
+ errp)) {
+ return;
+ }
+
/* merge input on top of current */
if (!migrate_params_merge(cur, input, &new, errp)) {
return;
diff --git a/migration/options.h b/migration/options.h
index 0d9f88c11e..f7bf56e9ff 100644
--- a/migration/options.h
+++ b/migration/options.h
@@ -95,4 +95,9 @@ bool migrate_params_check(MigrationParameters *params, Error **errp);
void migrate_params_init(MigrationParameters *params);
bool migrate_params_free(MigrationParameters *params, Error **errp);
QDict *migrate_params_to_dict(MigrationParameters *p, Error **errp);
+bool migrate_capability_get_compat(MigrationParameters *params, int i);
+void migrate_capability_set_compat(MigrationParameters *params, int i,
+ bool val);
+void migrate_capabilities_set_compat(MigrationParameters *params,
+ MigrationCapabilityStatusList *caps);
#endif
diff --git a/qapi/migration.json b/qapi/migration.json
index b1eaf7b054..5f4ad965d6 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -830,7 +830,14 @@
'zero-page-detection',
'direct-io',
{ 'name': 'x-rdma-chunk-size', 'features': [ 'unstable' ] },
- 'cpr-exec-command'] }
+ 'cpr-exec-command',
+ 'xbzrle', 'rdma-pin-all', 'auto-converge', 'events',
+ 'postcopy-ram', 'x-colo', 'release-ram', 'return-path',
+ 'pause-before-switchover', 'multifd', 'dirty-bitmaps',
+ 'postcopy-blocktime', 'late-block-activate', 'x-ignore-shared',
+ 'validate-uuid', 'background-snapshot', 'zero-copy-send',
+ 'postcopy-preempt', 'switchover-ack', 'dirty-limit',
+ 'mapped-ram'] }
##
# @migrate-set-parameters:
@@ -1012,10 +1019,98 @@
# Must be set to the same value on both source and destination
# before migration starts. (Since 11.1)
#
+# @xbzrle: Migration supports xbzrle (Xor Based Zero Run Length
+# Encoding). This feature allows us to minimize migration traffic
+# for certain work loads, by sending compressed difference of the
+# pages
+#
+# @rdma-pin-all: Controls whether or not the entire VM memory
+# footprint is mlock()'d on demand or all at once. Refer to
+# docs/rdma.txt for usage. Disabled by default. (since 2.0)
+#
+# @events: generate events for each migration state change (since 2.4)
+#
+# @auto-converge: If enabled, QEMU will automatically throttle down
+# the guest to speed up convergence of RAM migration. (since 1.6)
+#
+# @postcopy-ram: Start executing on the migration target before all of
+# RAM has been migrated, pulling the remaining pages along as
+# needed. The capacity must have the same setting on both source
+# and target or migration will not even start. **Note:** if the
+# migration fails during postcopy the VM will fail. (since 2.6)
+#
+# @x-colo: If enabled, migration will never end, and the state of the
+# VM on the primary side will be migrated continuously to the VM
+# on secondary side, this process is called COarse-Grain LOck
+# Stepping (COLO) for Non-stop Service. (since 2.8)
+#
+# @release-ram: if enabled, QEMU will free the migrated ram pages on
+# the source during postcopy-ram migration. (since 2.9)
+#
+# @return-path: If enabled, migration will use the return path even
+# for precopy. (since 2.10)
+#
+# @pause-before-switchover: Pause outgoing migration before
+# serialising device state and before disabling block IO
+# (since 2.11)
+#
+# @multifd: Use more than one fd for migration (since 4.0)
+#
+# @dirty-bitmaps: If enabled, QEMU will migrate named dirty bitmaps.
+# (since 2.12)
+#
+# @postcopy-blocktime: Calculate downtime for postcopy live migration
+# (since 3.0)
+#
+# @late-block-activate: If enabled, the destination will not activate
+# block devices (and thus take locks) immediately at the end of
+# migration. (since 3.0)
+#
+# @x-ignore-shared: If enabled, QEMU will not migrate shared memory
+# that is accessible on the destination machine. (since 4.0)
+#
+# @validate-uuid: Send the UUID of the source to allow the destination
+# to ensure it is the same. (since 4.2)
+#
+# @background-snapshot: If enabled, the migration stream will be a
+# snapshot of the VM exactly at the point when the migration
+# procedure starts. The VM RAM is saved with running VM.
+# (since 6.0)
+#
+# @zero-copy-send: Controls behavior on sending memory pages on
+# migration. When true, enables a zero-copy mechanism for sending
+# memory pages, if host supports it. Requires that QEMU be
+# permitted to use locked memory for guest RAM pages. (since 7.1)
+#
+# @postcopy-preempt: If enabled, the migration process will allow
+# postcopy requests to preempt precopy stream, so postcopy
+# requests will be handled faster. This is a performance feature
+# and should not affect the correctness of postcopy migration.
+# (since 7.1)
+#
+# @switchover-ack: If enabled, migration will not stop the source VM
+# and complete the migration until the destination has
+# acknowledged that it is OK to switch over. The acknowledgement
+# may depend, for example, on some device's data being loaded in
+# the destination before doing switchover. This can reduce
+# downtime if devices that support this capability are present.
+# Capability @return-path must be enabled to use it. (since 8.1)
+#
+# @dirty-limit: If enabled, migration will throttle vCPUs as needed to
+# keep their dirty page rate within @vcpu-dirty-limit. This can
+# improve responsiveness of large guests during live migration,
+# and can result in more stable read performance. Requires KVM
+# with accelerator property "dirty-ring-size" set. (Since 8.1)
+#
+# @mapped-ram: Migrate using fixed offsets in the migration file for
+# each RAM page. Requires a migration URI that supports seeking,
+# such as a file. (since 9.0)
+#
# Features:
#
-# @unstable: Members @x-checkpoint-delay, @x-rdma-chunk-size, and
-# @x-vcpu-dirty-limit-period are experimental.
+# @unstable: Members @x-checkpoint-delay, @x-rdma-chunk-size,
+# @x-vcpu-dirty-limit-period, @x-colo, @x-ignore-shared and are
+# experimental.
#
# Since: 2.4
##
@@ -1053,7 +1148,28 @@
'*direct-io': 'bool',
'*x-rdma-chunk-size': { 'type': 'uint64',
'features': [ 'unstable' ] },
- '*cpr-exec-command': [ 'str' ]} }
+ '*cpr-exec-command': [ 'str' ],
+ '*xbzrle': 'bool',
+ '*rdma-pin-all': 'bool',
+ '*auto-converge': 'bool',
+ '*events': 'bool',
+ '*postcopy-ram': 'bool',
+ '*x-colo': { 'type': 'bool', 'features': [ 'unstable' ] },
+ '*release-ram': 'bool',
+ '*return-path': 'bool',
+ '*pause-before-switchover': 'bool',
+ '*multifd': 'bool',
+ '*dirty-bitmaps': 'bool',
+ '*postcopy-blocktime': 'bool',
+ '*late-block-activate': 'bool',
+ '*x-ignore-shared': { 'type': 'bool', 'features': [ 'unstable' ] },
+ '*validate-uuid': 'bool',
+ '*background-snapshot': 'bool',
+ '*zero-copy-send': 'bool',
+ '*postcopy-preempt': 'bool',
+ '*switchover-ack': 'bool',
+ '*dirty-limit': 'bool',
+ '*mapped-ram': 'bool' } }
##
# @query-migrate-parameters:
--
2.53.0
next prev parent reply other threads:[~2026-09-09 21:46 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 21:44 [PATCH v2 00/18] migration: MigrationParameters changes Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 01/18] checkpatch: Fix checking of newlines in error messages Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 02/18] migration/options.c: Don't export migrate_tls_opts_free Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 03/18] migration: Rename variables in qmp_migrate_set_parameters Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 04/18] migration: Use QAPI_CLONE_MEMBERS in migrate_params_apply Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 05/18] migration: Merge parameter structs instead of assigning one by one Fabiano Rosas
2026-09-10 12:28 ` Peter Xu
2026-09-09 21:44 ` [PATCH v2 06/18] migration: Open code migrate_params_apply Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 07/18] migration: Stop freeing s->parameters members individually Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 08/18] migration: Use migrate_params_free during finalize Fabiano Rosas
2026-09-09 21:44 ` [PATCH v2 09/18] tests/qtest/migration: Add a test for HMP Fabiano Rosas
2026-09-10 14:02 ` Peter Xu
2026-09-13 20:30 ` Dr. David Alan Gilbert
2026-09-14 14:50 ` Fabiano Rosas
2026-09-14 15:34 ` Dr. David Alan Gilbert
2026-09-09 21:45 ` [PATCH v2 10/18] tests/qtest/migration: Add a test for HMP completion Fabiano Rosas
2026-09-10 17:36 ` Peter Xu
2026-09-13 20:58 ` Dr. David Alan Gilbert
2026-09-14 14:47 ` Fabiano Rosas
2026-09-14 14:50 ` Dr. David Alan Gilbert
2026-09-09 21:45 ` [PATCH v2 11/18] migration: HMP: Fix bandwidth parameters Fabiano Rosas
2026-09-10 6:05 ` Markus Armbruster
2026-09-10 12:37 ` Fabiano Rosas
2026-09-11 6:19 ` Markus Armbruster
2026-09-10 13:20 ` Dr. David Alan Gilbert
2026-09-10 13:26 ` Dr. David Alan Gilbert
2026-09-10 17:38 ` Peter Xu
2026-09-09 21:45 ` [PATCH v2 12/18] migration: Change HMP 'info migrate_parameters' output Fabiano Rosas
2026-09-10 7:32 ` Markus Armbruster
2026-09-10 13:02 ` Fabiano Rosas
2026-09-11 6:46 ` Markus Armbruster
2026-09-09 21:45 ` [PATCH v2 13/18] migration: Use keyval input visitor in HMP set command Fabiano Rosas
2026-09-10 11:07 ` Markus Armbruster
2026-09-10 14:15 ` Fabiano Rosas
2026-09-10 22:10 ` Fabiano Rosas
2026-09-11 8:22 ` Markus Armbruster
2026-09-11 12:54 ` Fabiano Rosas
2026-09-11 8:12 ` Markus Armbruster
2026-09-09 21:45 ` [PATCH v2 14/18] migration: Use output visitor in info command Fabiano Rosas
2026-09-09 21:45 ` [PATCH v2 15/18] migration: Rewrite migrate_set_parameter_completion using QDict Fabiano Rosas
2026-09-10 11:17 ` Markus Armbruster
2026-09-10 13:09 ` Fabiano Rosas
2026-09-11 7:15 ` Markus Armbruster
2026-09-09 21:45 ` Fabiano Rosas [this message]
2026-09-10 11:22 ` [PATCH v2 16/18] migration: Add capabilities into MigrationParameters Markus Armbruster
2026-09-09 21:45 ` [PATCH v2 17/18] migration: Remove s->capabilities Fabiano Rosas
2026-09-09 21:45 ` [PATCH v2 18/18] qapi/migration: Deprecate capabilities commands Fabiano Rosas
2026-09-10 17:35 ` [PATCH v2 00/18] migration: MigrationParameters changes Peter Xu
2026-09-10 19:27 ` 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=20260909214509.237309-17-farosas@suse.de \
--to=farosas@suse.de \
--cc=armbru@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=peterx@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.