From nobody Sat Apr 11 18:34:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1775316520; cv=none; d=zohomail.com; s=zohoarc; b=IqJ7JTza4nt4OVEWKJ2ZxI0JxeNUbdPkfBKGTV+pNJyDrht+AQYWUWZKqOZr4dqretouzlOanNke24ZeoDMjqmJRSUTQZUduoQ0fCPeEqOEqlNY54fq5xyR23nIomDh3Y5r93eTBguR8UL17KKoEmLial2N7DSETuaiq0SIsaoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775316520; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VpOPu3N88OLYcGF2nSpup4up/DQqoLUQd3kVQiqld5Q=; b=F1GYJ9kG8/UB1rSkNaPySYcANjTlEzvBGHfDCiV3Teau1nNu+pNlEwYhp2p1ns17zXLyOwX2UyXi8AL3xdfQLsK/0+4mxJ10aQVOONvBkW6jODMLKx9kRCevWjTrwR20Cvf6DNZnlMrOPzp7qBBtn0MXypTzFufKXZbtdKJGPNw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775316520787961.5672514994665; Sat, 4 Apr 2026 08:28:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w92ui-0002xF-UN; Sat, 04 Apr 2026 11:27:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w92uh-0002x4-H6 for qemu-devel@nongnu.org; Sat, 04 Apr 2026 11:27:55 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w92ud-0004dW-FS for qemu-devel@nongnu.org; Sat, 04 Apr 2026 11:27:53 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-2ab077e3f32so11102475ad.3 for ; Sat, 04 Apr 2026 08:27:50 -0700 (PDT) Received: from localhost.localdomain ([123.19.199.205]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c76c6475ae9sm8010120a12.2.2026.04.04.08.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Apr 2026 08:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775316469; x=1775921269; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VpOPu3N88OLYcGF2nSpup4up/DQqoLUQd3kVQiqld5Q=; b=GoPI8NOnSJtbtrfUNw0djthuXTLTiszglM1mnI2s+MpAZEuKs5s2kL0CErPD5/66g9 55RK/HiDzeYYCvoyXpxe8FVmubcM5YdzrvWMW9wkn5nzRvw9gICM42/32X6xjLFJ0aP+ kLSnquH0kBe+7fDYuWlqogKjXnvWxHs/KavP+NFxW0DP/txFOe2Hj56pLyPb7INgLrWe DQSlNWazXvokBt3uIOrUCHmnYCif1Zhpw63pMyjuWK2s8HbvYqCjwaM98fed3HlJfTzm uVohTw0+V2s/fui2Zg05Gzn9/KRMeAJgAcEeNXTW46v/De/yb3stkIRh8GQeK3dD8vui vg1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775316469; x=1775921269; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=VpOPu3N88OLYcGF2nSpup4up/DQqoLUQd3kVQiqld5Q=; b=kGtLEgZdxLjJ+n+vSvZBmS8alWWACbgVF97vvc5HrQBrHuIFCe5ycKqTuY37yzlwlA jUtlasc/cDqdF3JburkqrCXD+UdOVpqeSjWdDFpwrSLVihf/MW1SUW+7WN+L1e4dDEi5 pNA0gyr2iNDjxVb53kcOBl7wk1cbI4TQwiZXapUmztsb9B87A8SGj/S8WKyiKEb0JrEy yzLuUmF1QrHbJsRK+HkVMvyO7XW9bOm2S3tBXET/76p8FfWlqClAw2KLebRWS9zzyXv+ y4KUqPHbxTnxjKDTBZfLnH5X6IKkGmLx/VnyNZQedBSeeK8Cd47BXr/GT7QjYhkeDTuc Gktg== X-Gm-Message-State: AOJu0YwzTvhrMdsrvnBaGpaRB4bKZq6ewtZllwcoY8LU6uM8XJ2jYmaG dDkpMDk3XKbOn7E+3CDaeOhQLPM82l2esrPrNIAzNxJR6CmUzUndRwk1iVJ+FjwZE2QksQ== X-Gm-Gg: AeBDiesTVZomR4ncxpgH37xflLiGnRy+tUrkcP5/Vglg5xzo5AWwhSSKf08h6m9OGIf jO7oUMeC4ZoeUAsjkJEwgEYWFZj4EX9Hw8OH5iokWEkSzV8fCRGJr/UFTWseV3whUTld8oULdsY cPOyrNkv/HmhexNlb/EcEG5j+bxarLqK7b5Vs5iPvhfA+6wU3m4SxxStCMip0Kf5xZCgZ/9IXWs S4FYHiKH6tDPAj1WorFncsLnGf7qDIGPZqxFZo1LtmlNfZC762aZzwldZCbE02RqXPt3v9Lu6uN fPYnwdgOIAjg7dyggLxP3WNHyxS7gGKzLJwd9uDZHo/HayGkpFaYMynDrfSnF3u0W8WSXb5hKZU fNINbiscxWsEc233LbY+yuX145n/h1U/HRDX8JhmnCVoGhNQ/sC4UPR3nByvdJAAZjou/Nd65Ph qixXtB9gheXv22IKWdh+2+VvoSnOAmIyCvrcqrBrIOR0ujI4ElYT+mqGM/yw== X-Received: by 2002:a17:903:183:b0:2b0:5626:f75d with SMTP id d9443c01a7336-2b28176974bmr69306335ad.26.1775316469329; Sat, 04 Apr 2026 08:27:49 -0700 (PDT) From: Trieu Huynh X-Google-Original-From: Trieu Huynh To: qemu-devel@nongnu.org Cc: Trieu Huynh , Peter Xu , Fabiano Rosas , Eric Blake , Markus Armbruster , Paolo Bonzini Subject: [PATCH] migration: add optional capabilities field to migrate and migrate-incoming Date: Sat, 4 Apr 2026 22:27:36 +0700 Message-ID: <20260404152736.30190-1-viking4@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=vikingtc4@gmail.com; helo=mail-pl1-x636.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1775316523269154100 Content-Type: text/plain; charset="utf-8" From: Trieu Huynh When invoking migration, user must call migrate-set-capabilities as a separate QMP command before calling migrate or migrate-incoming. Add an optional 'capabilities' field to both commands. When provided, the capabilities are applied before the migration starts, in the same order as a migrate-set-capabilities call would apply them. Existing callers that do not pass the field are unaffected. This is particularly useful, eg. for snapshot-load workflows where a single migrate-incoming call should express the full migration configuration: { "execute": "migrate-incoming", "arguments": { "uri": "file:/tmp/snapshot", "capabilities": [{"capability": "mapped-ram", "state": true}] }} Internal callers (HMP migrate-incoming, vl.c -incoming) pass has_capabilities=3Dfalse so their behaviour is unchanged. Related-to: https://wiki.qemu.org/ToDo/LiveMigration#Allow_QMP_command_%22m= igrate[_incoming]%22_to_take_capabilities_and_parameters Signed-off-by: Trieu Huynh --- migration/migration-hmp-cmds.c | 4 ++-- migration/migration.c | 19 +++++++++++++++++++ qapi/migration.json | 12 ++++++++++++ system/vl.c | 3 ++- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 0a193b8f54..32c338103d 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -522,7 +522,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qd= ict) } QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel)); =20 - qmp_migrate_incoming(NULL, true, caps, true, false, &err); + qmp_migrate_incoming(NULL, true, caps, false, NULL, true, false, &err); qapi_free_MigrationChannelList(caps); =20 end: @@ -829,7 +829,7 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) } QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel)); =20 - qmp_migrate(NULL, true, caps, true, resume, &err); + qmp_migrate(NULL, true, caps, false, NULL, true, resume, &err); if (hmp_handle_error(mon, err)) { return; } diff --git a/migration/migration.c b/migration/migration.c index 5c9aaa6e58..eb1a734dd9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1752,6 +1752,8 @@ void migrate_del_blocker(Error **reasonp) =20 void qmp_migrate_incoming(const char *uri, bool has_channels, MigrationChannelList *channels, + bool has_capabilities, + MigrationCapabilityStatusList *capabilities, bool has_exit_on_error, bool exit_on_error, Error **errp) { @@ -1772,6 +1774,14 @@ void qmp_migrate_incoming(const char *uri, bool has_= channels, return; } =20 + if (has_capabilities) { + qmp_migrate_set_capabilities(capabilities, errp); + if (*errp) { + yank_unregister_instance(MIGRATION_YANK_INSTANCE); + return; + } + } + mis->exit_on_error =3D has_exit_on_error ? exit_on_error : INMIGRATE_DEFAULT_EXIT_ON_ERRO= R; =20 @@ -2020,6 +2030,8 @@ static gboolean migration_connect_outgoing_cb(QIOChan= nel *channel, =20 void qmp_migrate(const char *uri, bool has_channels, MigrationChannelList *channels, + bool has_capabilities, + MigrationCapabilityStatusList *capabilities, bool has_resume, bool resume, Error **errp) { MigrationState *s =3D migrate_get_current(); @@ -2036,6 +2048,13 @@ void qmp_migrate(const char *uri, bool has_channels, return; } =20 + if (has_capabilities) { + qmp_migrate_set_capabilities(capabilities, errp); + if (*errp) { + return; + } + } + if (!migrate_prepare(s, has_resume && resume, errp)) { /* Error detected, put into errp */ return; diff --git a/qapi/migration.json b/qapi/migration.json index 7134d4ce47..58d934f8fe 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1388,6 +1388,11 @@ # @channels: list of migration stream channels with each stream in the # list connected to a destination interface endpoint. # +# @capabilities: list of migration capabilities to set before +# starting the migration. Equivalent to calling +# `migrate-set-capabilities` before `migrate`, but more +# convenient. +# # @resume: when set, use the new uri/channels specified to resume # paused postcopy migration. This flag should only be used if # the previous postcopy migration was interrupted. The command @@ -1453,6 +1458,7 @@ { 'command': 'migrate', 'data': {'*uri': 'str', '*channels': [ 'MigrationChannel' ], + '*capabilities': ['MigrationCapabilityStatus'], '*resume': 'bool' } } =20 ## @@ -1467,6 +1473,11 @@ # @channels: list of migration stream channels with each stream in the # list connected to a destination interface endpoint. # +# @capabilities: list of migration capabilities to set before +# starting the migration. Equivalent to calling +# `migrate-set-capabilities` before `migrate-incoming`, but more +# convenient. +# # @exit-on-error: Exit on incoming migration failure. Default true. # When set to false, the failure triggers a # :qapi:event:`MIGRATION` event, and error details could be @@ -1525,6 +1536,7 @@ { 'command': 'migrate-incoming', 'data': {'*uri': 'str', '*channels': [ 'MigrationChannel' ], + '*capabilities': ['MigrationCapabilityStatus'], '*exit-on-error': 'bool' } } =20 ## diff --git a/system/vl.c b/system/vl.c index 246623b319..ed569d75e7 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2826,7 +2826,8 @@ void qmp_x_exit_preconfig(Error **errp) g_new0(MigrationChannelList, 1); =20 channels->value =3D incoming_channels[MIGRATION_CHANNEL_TYPE_M= AIN]; - qmp_migrate_incoming(NULL, true, channels, true, true, &local_= err); + qmp_migrate_incoming(NULL, true, channels, false, NULL, true, + true, &local_err); if (local_err) { error_reportf_err(local_err, "-incoming %s: ", incoming); exit(1); --=20 2.43.0