From nobody Fri Nov 14 18:17:40 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761579793; cv=none; d=zohomail.com; s=zohoarc; b=kORpWZNhDYMf283bYnZLhYf7uFwbn8HV4uzSCsWBfMeNyKL+CaCZ1Rfv63i2VgU3oWQSYu+oe3mCO5/2O5KkEY+kVKUzDGhzxpZiegex2owZMB6ae1Kj3zP3jM9o4MHDzpMNUhpJTD1aZGwcbaRLRWkxwsCcSNLtU+TsfH/OH/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761579793; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oJ/kAIunWoTHn08ow+43H8rlzqa6envgWmeSG+w9GoQ=; b=ifznjVuaIkMtchC5+dzlQnFeJxhdUzvzI2dYgulVODMLd1Ns9zjqjxGEZpM02BWpZI0/HrqcWMxWuCSQqcBt7HxRG/w+0CAX1qkfCwr4QWdxhFBjgM98w1wR67fFl2ERThNBW2eM/+FbbnYnjMrinXp3KjGcnYvynz6nED3xhYU= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761579793679991.0651096190453; Mon, 27 Oct 2025 08:43:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDPM9-0001xz-2S; Mon, 27 Oct 2025 11:42:01 -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 1vDPM4-0001wV-06 for qemu-devel@nongnu.org; Mon, 27 Oct 2025 11:41:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vDPLs-0008M0-Pa for qemu-devel@nongnu.org; Mon, 27 Oct 2025 11:41:55 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-PWQAyOsFPBGbp3K-zKjilQ-1; Mon, 27 Oct 2025 11:41:34 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0BEC51800378; Mon, 27 Oct 2025 15:41:33 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.183]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0971A30001A2; Mon, 27 Oct 2025 15:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761579696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oJ/kAIunWoTHn08ow+43H8rlzqa6envgWmeSG+w9GoQ=; b=A8rWrThVdee7QILVlapX6r/Cuw4YG74J8uRheEAVViOI7qsVg/I3mGwlZ1mraK24cjL6LX VeAGzU7CMYhYSuUAARqawI/5hBGA1A+y8lNA5/tP/jhbfgqkpJZ0VpLI68z1Aot2HGu96M 5YOA3YIUuHN8QQNbuY57sPyOvq+pKf8= X-MC-Unique: PWQAyOsFPBGbp3K-zKjilQ-1 X-Mimecast-MFC-AGG-ID: PWQAyOsFPBGbp3K-zKjilQ_1761579693 From: Juraj Marcin To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Xu , "Dr. David Alan Gilbert" , Jiri Denemark , Fabiano Rosas Subject: [PATCH v2 1/4] migration: Do not try to start VM if disk activation fails Date: Mon, 27 Oct 2025 16:41:08 +0100 Message-ID: <20251027154115.4138677-2-jmarcin@redhat.com> In-Reply-To: <20251027154115.4138677-1-jmarcin@redhat.com> References: <20251027154115.4138677-1-jmarcin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=jmarcin@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: 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 @redhat.com) X-ZM-MESSAGEID: 1761579795508154100 Content-Type: text/plain; charset="utf-8" From: Peter Xu If a rare split brain happens (e.g. dest QEMU started running somehow, taking shared drive locks), src QEMU may not be able to activate the drives anymore. In this case, src QEMU shouldn't start the VM or it might crash the block layer later with something like: Meanwhile, src QEMU cannot try to continue either even if dest QEMU can release the drive locks (e.g. by QMP "stop"). Because as long as dest QEMU started running, it means dest QEMU's RAM is the only version that is consistent with current status of the shared storage. Signed-off-by: Peter Xu --- migration/migration.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index a63b46bbef..e9acd0f63b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3551,6 +3551,8 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) =20 static void migration_iteration_finish(MigrationState *s) { + Error *local_err =3D NULL; + bql_lock(); =20 /* @@ -3574,11 +3576,28 @@ static void migration_iteration_finish(MigrationSta= te *s) case MIGRATION_STATUS_FAILED: case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_CANCELLING: - /* - * Re-activate the block drives if they're inactivated. Note, COLO - * shouldn't use block_active at all, so it should be no-op there. - */ - migration_block_activate(NULL); + if (!migration_block_activate(&local_err)) { + /* + * Re-activate the block drives if they're inactivated. + * + * If it fails (e.g. in case of a split brain, where dest QEMU + * might have taken some of the drive locks and running!), do + * not start VM, instead wait for mgmt to decide the next step. + * + * If dest already started, it means dest QEMU should contain + * all the data it needs and it properly owns all the drive + * locks. Then even if src QEMU got a FAILED in migration, it + * normally should mean we should treat the migration as + * COMPLETED. + * + * NOTE: it's not safe anymore to start VM on src now even if + * dest would release the drive locks. It's because as long as + * dest started running then only dest QEMU's RAM is consistent + * with the shared storage. + */ + error_free(local_err); + break; + } if (runstate_is_live(s->vm_old_state)) { if (!runstate_check(RUN_STATE_SHUTDOWN)) { vm_start(); --=20 2.51.0 From nobody Fri Nov 14 18:17:40 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761579795; cv=none; d=zohomail.com; s=zohoarc; b=fWM2vqhcKtFIyE+eY9kOnxpHw4KOVhU0Y6rY4dYxQfP3buNqiCLuvr8JkQf3rlNNYWz+Hd7fzMALxgqiDCLvnf62uBbmMsRY6E6uhqyeTsD21oQLk2CIdhBDFI+BpPrSQDKnHoa4uKtEDl/pHKp233ZYkpPh6xygFuJQ3XuStYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761579795; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t180PYNalySODgaWYpV7NHiAYPKhiHRd9Vru2Y5LYN0=; b=T7nG+XTdoPMZs1AFhNKNHlIsKyO0780QbShaZ3sPbFL83RyREXZKaz8fd8n8EH4L0kQ/q1MgZR6QlQNYFtTlrMFEdZvEtsIFtQqmBbPkqCh49STDOsK2YmmNXRPeeCilOGnzro4lZ7BhqoGLNplWvFEa4ycyYVqjNlA9cI7JQfk= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761579795619640.007700594659; Mon, 27 Oct 2025 08:43:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDPM9-0001yl-P5; Mon, 27 Oct 2025 11:42:01 -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 1vDPM5-0001wu-Nh for qemu-devel@nongnu.org; Mon, 27 Oct 2025 11:41:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vDPLu-0008NC-SJ for qemu-devel@nongnu.org; Mon, 27 Oct 2025 11:41:56 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-YTB0RVUrPLiUyx-3MlzZmw-1; Mon, 27 Oct 2025 11:41:40 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 56DB618001D6; Mon, 27 Oct 2025 15:41:39 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.183]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 66AFF30001A2; Mon, 27 Oct 2025 15:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761579703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t180PYNalySODgaWYpV7NHiAYPKhiHRd9Vru2Y5LYN0=; b=duYo6PkkvGmiLjF843zZI1strkjhb8mHNNio1J82ge8zReX2eLogz9rlbl2u2ocrz8hB54 1Lf7aRdm/XOiD/ev5pEHOJAIKJM6hGG7Ix7Z6aI6gB5ndH1v/jfMstv7W9u0d9q9c/LgMC agsYAJoIPlQHQxqBsFJhWgCqjOmMPCg= X-MC-Unique: YTB0RVUrPLiUyx-3MlzZmw-1 X-Mimecast-MFC-AGG-ID: YTB0RVUrPLiUyx-3MlzZmw_1761579699 From: Juraj Marcin To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Xu , "Dr. David Alan Gilbert" , Jiri Denemark , Fabiano Rosas Subject: [PATCH v2 2/4] migration: Move postcopy_ram_listen_thread() to postcopy-ram.c Date: Mon, 27 Oct 2025 16:41:09 +0100 Message-ID: <20251027154115.4138677-3-jmarcin@redhat.com> In-Reply-To: <20251027154115.4138677-1-jmarcin@redhat.com> References: <20251027154115.4138677-1-jmarcin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=jmarcin@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: 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 @redhat.com) X-ZM-MESSAGEID: 1761579797710154100 Content-Type: text/plain; charset="utf-8" From: Juraj Marcin This patch addresses a TODO about moving postcopy_ram_listen_thread() to postcopy file. Furthermore, this patch adds a pair of functions, postcopy_incoming_setup() and postcopy_incoming_cleanup(), which sets up and cleans the postcopy_ram_incoming state and the listen thread. Signed-off-by: Juraj Marcin --- migration/migration.c | 2 +- migration/postcopy-ram.c | 144 +++++++++++++++++++++++++++++++++++++++ migration/postcopy-ram.h | 3 + migration/savevm.c | 131 +---------------------------------- 4 files changed, 150 insertions(+), 130 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e9acd0f63b..8827884a15 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -892,7 +892,7 @@ process_incoming_migration_co(void *opaque) * but managed to complete within the precopy period, we can u= se * the normal exit. */ - postcopy_ram_incoming_cleanup(mis); + postcopy_incoming_cleanup(mis); } else if (ret >=3D 0) { /* * Postcopy was started, cleanup should happen at the end of t= he diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 5471efb4f0..dbbb2dfb78 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -2077,3 +2077,147 @@ bool postcopy_is_paused(MigrationStatus status) return status =3D=3D MIGRATION_STATUS_POSTCOPY_PAUSED || status =3D=3D MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP; } + +/* + * Triggered by a postcopy_listen command; this thread takes over reading + * the input stream, leaving the main thread free to carry on loading the = rest + * of the device state (from RAM). + */ +static void *postcopy_listen_thread(void *opaque) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + QEMUFile *f =3D mis->from_src_file; + int load_res; + MigrationState *migr =3D migrate_get_current(); + Error *local_err =3D NULL; + + object_ref(OBJECT(migr)); + + migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, + MIGRATION_STATUS_POSTCOPY_ACTIVE); + qemu_event_set(&mis->thread_sync_event); + trace_postcopy_ram_listen_thread_start(); + + rcu_register_thread(); + /* + * Because we're a thread and not a coroutine we can't yield + * in qemu_file, and thus we must be blocking now. + */ + qemu_file_set_blocking(f, true, &error_fatal); + + /* TODO: sanity check that only postcopiable data will be loaded here = */ + load_res =3D qemu_loadvm_state_main(f, mis, &local_err); + + /* + * This is tricky, but, mis->from_src_file can change after it + * returns, when postcopy recovery happened. In the future, we may + * want a wrapper for the QEMUFile handle. + */ + f =3D mis->from_src_file; + + /* And non-blocking again so we don't block in any cleanup */ + qemu_file_set_blocking(f, false, &error_fatal); + + trace_postcopy_ram_listen_thread_exit(); + if (load_res < 0) { + qemu_file_set_error(f, load_res); + dirty_bitmap_mig_cancel_incoming(); + if (postcopy_state_get() =3D=3D POSTCOPY_INCOMING_RUNNING && + !migrate_postcopy_ram() && migrate_dirty_bitmaps()) + { + error_report("%s: loadvm failed during postcopy: %d. All state= s " + "are migrated except dirty bitmaps. Some dirty " + "bitmaps may be lost, and present migrated dirty " + "bitmaps are correctly migrated and valid.", + __func__, load_res); + load_res =3D 0; /* prevent further exit() */ + } else { + error_prepend(&local_err, + "loadvm failed during postcopy: %d: ", load_res); + migrate_set_error(migr, local_err); + error_report_err(local_err); + migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIV= E, + MIGRATION_STATUS_FAILED); + } + } + if (load_res >=3D 0) { + /* + * This looks good, but it's possible that the device loading in t= he + * main thread hasn't finished yet, and so we might not be in 'RUN' + * state yet; wait for the end of the main thread. + */ + qemu_event_wait(&mis->main_thread_load_event); + } + postcopy_incoming_cleanup(mis); + + if (load_res < 0) { + /* + * If something went wrong then we have a bad state so exit; + * depending how far we got it might be possible at this point + * to leave the guest running and fire MCEs for pages that never + * arrived as a desperate recovery step. + */ + rcu_unregister_thread(); + exit(EXIT_FAILURE); + } + + migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, + MIGRATION_STATUS_COMPLETED); + /* + * If everything has worked fine, then the main thread has waited + * for us to start, and we're the last use of the mis. + * (If something broke then qemu will have to exit anyway since it's + * got a bad migration state). + */ + bql_lock(); + migration_incoming_state_destroy(); + bql_unlock(); + + rcu_unregister_thread(); + mis->have_listen_thread =3D false; + postcopy_state_set(POSTCOPY_INCOMING_END); + + object_unref(OBJECT(migr)); + + return NULL; +} + +int postcopy_incoming_setup(MigrationIncomingState *mis, Error **errp) +{ + /* + * Sensitise RAM - can now generate requests for blocks that don't exi= st + * However, at this point the CPU shouldn't be running, and the IO + * shouldn't be doing anything yet so don't actually expect requests + */ + if (migrate_postcopy_ram()) { + if (postcopy_ram_incoming_setup(mis)) { + postcopy_ram_incoming_cleanup(mis); + error_setg(errp, "Failed to setup incoming postcopy RAM blocks= "); + return -1; + } + } + + trace_loadvm_postcopy_handle_listen("after uffd"); + + if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_LISTEN, errp)) { + return -1; + } + + mis->have_listen_thread =3D true; + postcopy_thread_create(mis, &mis->listen_thread, + MIGRATION_THREAD_DST_LISTEN, + postcopy_listen_thread, QEMU_THREAD_DETACHED); + + return 0; +} + +int postcopy_incoming_cleanup(MigrationIncomingState *mis) +{ + int rc =3D 0; + + if (migrate_postcopy_ram()) { + rc =3D postcopy_ram_incoming_cleanup(mis); + } + + return rc; +} diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index ca19433b24..a080dd65a7 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -199,4 +199,7 @@ bool postcopy_is_paused(MigrationStatus status); void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid, RAMBlock *rb); =20 +int postcopy_incoming_setup(MigrationIncomingState *mis, Error **errp); +int postcopy_incoming_cleanup(MigrationIncomingState *mis); + #endif diff --git a/migration/savevm.c b/migration/savevm.c index 7b35ec4dd0..96a2699ca7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2087,112 +2087,6 @@ static int loadvm_postcopy_ram_handle_discard(Migra= tionIncomingState *mis, return 0; } =20 -/* - * Triggered by a postcopy_listen command; this thread takes over reading - * the input stream, leaving the main thread free to carry on loading the = rest - * of the device state (from RAM). - * (TODO:This could do with being in a postcopy file - but there again it's - * just another input loop, not that postcopy specific) - */ -static void *postcopy_ram_listen_thread(void *opaque) -{ - MigrationIncomingState *mis =3D migration_incoming_get_current(); - QEMUFile *f =3D mis->from_src_file; - int load_res; - MigrationState *migr =3D migrate_get_current(); - Error *local_err =3D NULL; - - object_ref(OBJECT(migr)); - - migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, - MIGRATION_STATUS_POSTCOPY_ACTIVE); - qemu_event_set(&mis->thread_sync_event); - trace_postcopy_ram_listen_thread_start(); - - rcu_register_thread(); - /* - * Because we're a thread and not a coroutine we can't yield - * in qemu_file, and thus we must be blocking now. - */ - qemu_file_set_blocking(f, true, &error_fatal); - - /* TODO: sanity check that only postcopiable data will be loaded here = */ - load_res =3D qemu_loadvm_state_main(f, mis, &local_err); - - /* - * This is tricky, but, mis->from_src_file can change after it - * returns, when postcopy recovery happened. In the future, we may - * want a wrapper for the QEMUFile handle. - */ - f =3D mis->from_src_file; - - /* And non-blocking again so we don't block in any cleanup */ - qemu_file_set_blocking(f, false, &error_fatal); - - trace_postcopy_ram_listen_thread_exit(); - if (load_res < 0) { - qemu_file_set_error(f, load_res); - dirty_bitmap_mig_cancel_incoming(); - if (postcopy_state_get() =3D=3D POSTCOPY_INCOMING_RUNNING && - !migrate_postcopy_ram() && migrate_dirty_bitmaps()) - { - error_report("%s: loadvm failed during postcopy: %d. All state= s " - "are migrated except dirty bitmaps. Some dirty " - "bitmaps may be lost, and present migrated dirty " - "bitmaps are correctly migrated and valid.", - __func__, load_res); - load_res =3D 0; /* prevent further exit() */ - } else { - error_prepend(&local_err, - "loadvm failed during postcopy: %d: ", load_res); - migrate_set_error(migr, local_err); - error_report_err(local_err); - migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIV= E, - MIGRATION_STATUS_FAILED); - } - } - if (load_res >=3D 0) { - /* - * This looks good, but it's possible that the device loading in t= he - * main thread hasn't finished yet, and so we might not be in 'RUN' - * state yet; wait for the end of the main thread. - */ - qemu_event_wait(&mis->main_thread_load_event); - } - postcopy_ram_incoming_cleanup(mis); - - if (load_res < 0) { - /* - * If something went wrong then we have a bad state so exit; - * depending how far we got it might be possible at this point - * to leave the guest running and fire MCEs for pages that never - * arrived as a desperate recovery step. - */ - rcu_unregister_thread(); - exit(EXIT_FAILURE); - } - - migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, - MIGRATION_STATUS_COMPLETED); - /* - * If everything has worked fine, then the main thread has waited - * for us to start, and we're the last use of the mis. - * (If something broke then qemu will have to exit anyway since it's - * got a bad migration state). - */ - bql_lock(); - migration_incoming_state_destroy(); - bql_unlock(); - - rcu_unregister_thread(); - mis->have_listen_thread =3D false; - postcopy_state_set(POSTCOPY_INCOMING_END); - - object_unref(OBJECT(migr)); - - return NULL; -} - /* After this message we must be able to immediately receive postcopy data= */ static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis, Error **errp) @@ -2218,32 +2112,11 @@ static int loadvm_postcopy_handle_listen(MigrationI= ncomingState *mis, =20 trace_loadvm_postcopy_handle_listen("after discard"); =20 - /* - * Sensitise RAM - can now generate requests for blocks that don't exi= st - * However, at this point the CPU shouldn't be running, and the IO - * shouldn't be doing anything yet so don't actually expect requests - */ - if (migrate_postcopy_ram()) { - if (postcopy_ram_incoming_setup(mis)) { - postcopy_ram_incoming_cleanup(mis); - error_setg(errp, "Failed to setup incoming postcopy RAM blocks= "); - return -1; - } - } + int rc =3D postcopy_incoming_setup(mis, errp); =20 - trace_loadvm_postcopy_handle_listen("after uffd"); - - if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_LISTEN, errp)) { - return -1; - } - - mis->have_listen_thread =3D true; - postcopy_thread_create(mis, &mis->listen_thread, - MIGRATION_THREAD_DST_LISTEN, - postcopy_ram_listen_thread, QEMU_THREAD_DETACHE= D); trace_loadvm_postcopy_handle_listen("return"); =20 - return 0; + return rc; } =20 static void loadvm_postcopy_handle_run_bh(void *opaque) --=20 2.51.0 From nobody Fri Nov 14 18:17:40 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761579782; cv=none; d=zohomail.com; s=zohoarc; b=Lv5RRcSaEB6/Ta8cSz8gaK6gZdl0WGLm6O8EWoqOCKSJBMushPEMbS1x3ATnNC3o0iGmdG/RxX12+B/x8A4YCEt1ltaqCLoMwvZyWB0YVrHlGpBzQx0oFn7UVmSYg4y0vIo9MQA6sK/whjXSCz1/kRSUJ1SvVhLqBe+I5RpgsDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761579782; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DAG3FOBfaeKpGC+BB6OHes56nMqD5tLAMrJ14B9K7VA=; b=g3Zw++CahJCzowE6+0IMGWDi4UbJoooyApg2bkfxRbfBUjVeImYpUtAWu4qtB1PnMLr+sF6N7N0wuu31kXD5Fkq4V2kpyfvh/l/ngdGF/ANgInE76e5yY2FzgjP864giIrQABandoR2doZdGJARtRgvkAZYgd+LZyug3hbIq0yU= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761579782595871.2671825534899; Mon, 27 Oct 2025 08:43:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDPMF-00020F-A3; Mon, 27 Oct 2025 11:42:07 -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 1vDPMA-000205-Ej for qemu-devel@nongnu.org; Mon, 27 Oct 2025 11:42:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vDPM3-0008Nt-3O for qemu-devel@nongnu.org; Mon, 27 Oct 2025 11:42:02 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-450-KYXSxoe8Ob6owaQAXXlimw-1; Mon, 27 Oct 2025 11:41:46 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D7787180034C; Mon, 27 Oct 2025 15:41:45 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.183]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C1AF130001A2; Mon, 27 Oct 2025 15:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761579710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DAG3FOBfaeKpGC+BB6OHes56nMqD5tLAMrJ14B9K7VA=; b=Ptw9suiXzE6GZq/qHMyjTId2xsdCHPCzovgQ8Rp5QwoegDbaOvDbE1ZAKsr2WZ4pC0FEJ7 dINl5KPE97afkOSZPW5L8/aQjwakpBim4FolUcpJDuPF2/3mGs3Ys43BwY0iTmN7AzG8/2 XE9XnB36vbgI0X7v29amBDzK+2p5S8A= X-MC-Unique: KYXSxoe8Ob6owaQAXXlimw-1 X-Mimecast-MFC-AGG-ID: KYXSxoe8Ob6owaQAXXlimw_1761579706 From: Juraj Marcin To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Xu , "Dr. David Alan Gilbert" , Jiri Denemark , Fabiano Rosas Subject: [PATCH v2 3/4] migration: Refactor all incoming cleanup into migration_incoming_cleanup() Date: Mon, 27 Oct 2025 16:41:10 +0100 Message-ID: <20251027154115.4138677-4-jmarcin@redhat.com> In-Reply-To: <20251027154115.4138677-1-jmarcin@redhat.com> References: <20251027154115.4138677-1-jmarcin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=jmarcin@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: 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 @redhat.com) X-ZM-MESSAGEID: 1761579785527154100 Content-Type: text/plain; charset="utf-8" From: Juraj Marcin Currently, there are two functions that are responsible for cleanup of the incoming migration state. With successful precopy, it's the process incoming migration coroutine and with successful postcopy it's the postcopy listen thread. However, if postcopy fails during in the device load, both functions will try to do the cleanup. Moreover, when exit-on-error parameter was added, it was applied only to precopy. This patch introduces exit-on-error to postcopy and refactors incoming migration cleanup into a common function while defining a clear boundary of who is responsible for the cleanup. The process incoming migration coroutine is responsible for running the cleanup function, unless the listen thread has been started (the postcopy state is at least in LISTENING phase), in which case the postcopy listen thread runs the incoming migration cleanup in a BH, which also joins the listen thread. Signed-off-by: Juraj Marcin --- migration/migration-hmp-cmds.c | 2 +- migration/migration.c | 77 +++++++++++++++++----------------- migration/migration.h | 4 +- migration/postcopy-ram.c | 53 ++++++++++------------- migration/savevm.c | 4 +- qapi/migration.json | 9 +++- system/vl.c | 3 +- 7 files changed, 75 insertions(+), 77 deletions(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 847d18faaa..c572c1fb28 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -521,7 +521,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, true, false, true, false, &err); qapi_free_MigrationChannelList(caps); =20 end: diff --git a/migration/migration.c b/migration/migration.c index 8827884a15..2cc6327c39 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -328,6 +328,7 @@ void migration_object_init(void) current_incoming->page_requested =3D g_tree_new(page_request_addr_cmp); =20 current_incoming->exit_on_error =3D INMIGRATE_DEFAULT_EXIT_ON_ERROR; + current_incoming->postcopy_exit_on_error =3D INMIGRATE_DEFAULT_EXIT_ON= _ERROR; =20 migration_object_check(current_migration, &error_fatal); =20 @@ -436,12 +437,18 @@ void migration_incoming_transport_cleanup(MigrationIn= comingState *mis) } } =20 -void migration_incoming_state_destroy(void) +void migration_incoming_cleanup(void) { - struct MigrationIncomingState *mis =3D migration_incoming_get_current(= ); + MigrationState *ms =3D migrate_get_current(); + MigrationIncomingState *mis =3D migration_incoming_get_current(); + PostcopyState ps =3D postcopy_state_get(); =20 multifd_recv_cleanup(); =20 + if (ps !=3D POSTCOPY_INCOMING_NONE) { + postcopy_incoming_cleanup(mis); + } + /* * RAM state cleanup needs to happen after multifd cleanup, because * multifd threads can use some of its states (receivedmap). @@ -493,6 +500,22 @@ void migration_incoming_state_destroy(void) =20 cpr_set_incoming_mode(MIG_MODE_NONE); yank_unregister_instance(MIGRATION_YANK_INSTANCE); + + if (mis->state =3D=3D MIGRATION_STATUS_FAILED && + ((ps < POSTCOPY_INCOMING_LISTENING && mis->exit_on_error) || + (ps >=3D POSTCOPY_INCOMING_LISTENING && mis->postcopy_exit_on_err= or))) { + WITH_QEMU_LOCK_GUARD(&ms->error_mutex) { + error_report_err(ms->error); + ms->error =3D NULL; + } + + exit(EXIT_FAILURE); + } +} + +void migration_incoming_cleanup_bh(void *opaque) +{ + migration_incoming_cleanup(); } =20 static void migrate_generate_event(MigrationStatus new_state) @@ -858,7 +881,7 @@ static void process_incoming_migration_bh(void *opaque) */ migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COMPLETED); - migration_incoming_state_destroy(); + migration_incoming_cleanup(); } =20 static void coroutine_fn @@ -885,23 +908,13 @@ process_incoming_migration_co(void *opaque) =20 ps =3D postcopy_state_get(); trace_process_incoming_migration_co_end(ret, ps); - if (ps !=3D POSTCOPY_INCOMING_NONE) { - if (ps =3D=3D POSTCOPY_INCOMING_ADVISE) { - /* - * Where a migration had postcopy enabled (and thus went to ad= vise) - * but managed to complete within the precopy period, we can u= se - * the normal exit. - */ - postcopy_incoming_cleanup(mis); - } else if (ret >=3D 0) { - /* - * Postcopy was started, cleanup should happen at the end of t= he - * postcopy thread. - */ - trace_process_incoming_migration_co_postcopy_end_main(); - goto out; - } - /* Else if something went wrong then just fall out of the normal e= xit */ + if (ps >=3D POSTCOPY_INCOMING_LISTENING) { + /* + * Postcopy was started, cleanup should happen at the end of the + * postcopy listen thread. + */ + trace_process_incoming_migration_co_postcopy_end_main(); + goto out; } =20 if (ret < 0) { @@ -924,25 +937,7 @@ fail: migrate_set_error(s, local_err); error_free(local_err); =20 - migration_incoming_state_destroy(); - - if (mis->exit_on_error) { - WITH_QEMU_LOCK_GUARD(&s->error_mutex) { - error_report_err(s->error); - s->error =3D NULL; - } - - exit(EXIT_FAILURE); - } else { - /* - * Report the error here in case that QEMU abruptly exits - * when postcopy is enabled. - */ - WITH_QEMU_LOCK_GUARD(&s->error_mutex) { - error_report_err(s->error); - s->error =3D NULL; - } - } + migration_incoming_cleanup(); out: /* Pairs with the refcount taken in qmp_migrate_incoming() */ migrate_incoming_unref_outgoing_state(); @@ -1968,6 +1963,8 @@ void migrate_del_blocker(Error **reasonp) void qmp_migrate_incoming(const char *uri, bool has_channels, MigrationChannelList *channels, bool has_exit_on_error, bool exit_on_error, + bool has_postcopy_exit_on_error, + bool postcopy_exit_on_error, Error **errp) { Error *local_err =3D NULL; @@ -1989,6 +1986,8 @@ void qmp_migrate_incoming(const char *uri, bool has_c= hannels, =20 mis->exit_on_error =3D has_exit_on_error ? exit_on_error : INMIGRATE_DEFAULT_EXIT_ON_ERRO= R; + mis->postcopy_exit_on_error =3D has_postcopy_exit_on_error ? + postcopy_exit_on_error : INMIGRATE_DEFAULT_EXIT_ON_ERROR; =20 qemu_start_incoming_migration(uri, has_channels, channels, &local_err); =20 diff --git a/migration/migration.h b/migration/migration.h index 01329bf824..9d9e95ae90 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -249,10 +249,12 @@ struct MigrationIncomingState { =20 /* Do exit on incoming migration failure */ bool exit_on_error; + bool postcopy_exit_on_error; }; =20 MigrationIncomingState *migration_incoming_get_current(void); -void migration_incoming_state_destroy(void); +void migration_incoming_cleanup(void); +void migration_incoming_cleanup_bh(void *opaque); void migration_incoming_transport_cleanup(MigrationIncomingState *mis); /* * Functions to work with blocktime context diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index dbbb2dfb78..0375366ed0 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -2130,53 +2130,37 @@ static void *postcopy_listen_thread(void *opaque) "bitmaps may be lost, and present migrated dirty " "bitmaps are correctly migrated and valid.", __func__, load_res); - load_res =3D 0; /* prevent further exit() */ } else { + /* + * Something went fatally wrong and we have a bad state, QEMU = will + * exit depending on if postcopy-exit-on-error is true, but the + * migration cannot be recovered. + */ error_prepend(&local_err, "loadvm failed during postcopy: %d: ", load_res); migrate_set_error(migr, local_err); error_report_err(local_err); migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIV= E, MIGRATION_STATUS_FAILED); + goto out; } } - if (load_res >=3D 0) { - /* - * This looks good, but it's possible that the device loading in t= he - * main thread hasn't finished yet, and so we might not be in 'RUN' - * state yet; wait for the end of the main thread. - */ - qemu_event_wait(&mis->main_thread_load_event); - } - postcopy_incoming_cleanup(mis); - - if (load_res < 0) { - /* - * If something went wrong then we have a bad state so exit; - * depending how far we got it might be possible at this point - * to leave the guest running and fire MCEs for pages that never - * arrived as a desperate recovery step. - */ - rcu_unregister_thread(); - exit(EXIT_FAILURE); - } + /* + * This looks good, but it's possible that the device loading in the + * main thread hasn't finished yet, and so we might not be in 'RUN' + * state yet; wait for the end of the main thread. + */ + qemu_event_wait(&mis->main_thread_load_event); =20 migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, MIGRATION_STATUS_COMPLETED); - /* - * If everything has worked fine, then the main thread has waited - * for us to start, and we're the last use of the mis. - * (If something broke then qemu will have to exit anyway since it's - * got a bad migration state). - */ - bql_lock(); - migration_incoming_state_destroy(); - bql_unlock(); =20 +out: rcu_unregister_thread(); - mis->have_listen_thread =3D false; postcopy_state_set(POSTCOPY_INCOMING_END); =20 + migration_bh_schedule(migration_incoming_cleanup_bh, NULL); + object_unref(OBJECT(migr)); =20 return NULL; @@ -2206,7 +2190,7 @@ int postcopy_incoming_setup(MigrationIncomingState *m= is, Error **errp) mis->have_listen_thread =3D true; postcopy_thread_create(mis, &mis->listen_thread, MIGRATION_THREAD_DST_LISTEN, - postcopy_listen_thread, QEMU_THREAD_DETACHED); + postcopy_listen_thread, QEMU_THREAD_JOINABLE); =20 return 0; } @@ -2215,6 +2199,11 @@ int postcopy_incoming_cleanup(MigrationIncomingState= *mis) { int rc =3D 0; =20 + if (mis->have_listen_thread) { + qemu_thread_join(&mis->listen_thread); + mis->have_listen_thread =3D false; + } + if (migrate_postcopy_ram()) { rc =3D postcopy_ram_incoming_cleanup(mis); } diff --git a/migration/savevm.c b/migration/savevm.c index 96a2699ca7..27fe815731 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3368,7 +3368,7 @@ void qmp_xen_load_devices_state(const char *filename,= Error **errp) if (ret < 0) { error_prepend(errp, "loading Xen device state failed: "); } - migration_incoming_state_destroy(); + migration_incoming_cleanup(); } =20 bool load_snapshot(const char *name, const char *vmstate, @@ -3438,7 +3438,7 @@ bool load_snapshot(const char *name, const char *vmst= ate, goto err_drain; } ret =3D qemu_loadvm_state(f, errp); - migration_incoming_state_destroy(); + migration_incoming_cleanup(); =20 bdrv_drain_all_end(); =20 diff --git a/qapi/migration.json b/qapi/migration.json index be0f3fcc12..da5b3a4d8c 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1817,6 +1817,12 @@ # event, and error details could be retrieved with `query-migrate`. # (since 9.1) # +# @postcopy-exit-on-error: same es exit-on-error, but used during postcopy +# migration. Default true. When set to true, QEMU only exits if a fa= tal +# unrecoverable error happens during postcopy, in which case QEMU would +# exit even before the introduction of this option. +# (since 10.2) +# # Since: 2.3 # # .. admonition:: Notes @@ -1870,7 +1876,8 @@ { 'command': 'migrate-incoming', 'data': {'*uri': 'str', '*channels': [ 'MigrationChannel' ], - '*exit-on-error': 'bool' } } + '*exit-on-error': 'bool', + '*postcopy-exit-on-error': 'bool' } } =20 ## # @xen-save-devices-state: diff --git a/system/vl.c b/system/vl.c index 17bbc092c8..1308d92901 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2824,7 +2824,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, true, true, true, t= rue, + &local_err); if (local_err) { error_reportf_err(local_err, "-incoming %s: ", incoming); exit(1); --=20 2.51.0 From nobody Fri Nov 14 18:17:40 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761579787; cv=none; d=zohomail.com; s=zohoarc; b=dnBHDSWxxkzgpEnu8God7pbIsP2m/wJUOrj5mBormPJd2SAX0l7G20lI2cNqdyuUZub9WyVzoNrlISLHkCUYAkhuKkk8Gkev1cDfMcbTYri+YNE3NcuCHWyTZCL14fj6XANs8eROL+0yuLJznZSy2ySgtJ8tCy60Bf++3flYXQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761579787; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=B4wCPrB0FE5zMpzTf7Vw06fgxpDTYJ+oLyKltTOfttA=; b=JwlhPtkaFPCt1Me/g5NbNVvIcbckfFPEg4rwheoGvrPHpXgtAwXvEtObpvQg0o1N8Xnyr2DBPFPVaP31m0atfh+HVfkM3FhV5AfOq5qJN545YUBS4MtqAUlUEw4g1w/XS596dP7V5vk9lvXPVXuESPYaVVmJotf/YTd0e0ecbCc= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761579787918672.9027357231561; Mon, 27 Oct 2025 08:43:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDPML-00021b-Ma; Mon, 27 Oct 2025 11:42:14 -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 1vDPMJ-00021Q-FM for qemu-devel@nongnu.org; Mon, 27 Oct 2025 11:42:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vDPM7-0008PA-Qm for qemu-devel@nongnu.org; Mon, 27 Oct 2025 11:42:11 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-671-jaSl1Ea2P9mgXCJA87tZXQ-1; Mon, 27 Oct 2025 11:41:52 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EA7DC19560B0; Mon, 27 Oct 2025 15:41:50 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.183]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 05D7230001A2; Mon, 27 Oct 2025 15:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761579717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B4wCPrB0FE5zMpzTf7Vw06fgxpDTYJ+oLyKltTOfttA=; b=f6Z0wii8sU/QQsqsrao1AugDVWvz3i/yvD17jBh+8wxTruKGNJOTBzm5/Gn42jeODCRZCP 3dBJmPDCBWoN2xFscUsVxV/Osk9GgUwqpVPCOhgQrBIjKuBDq1e6mb1BTA9tSfQXWdeCMz HcX27i7WLOvY1iIQsmwks7e1ixGwtw4= X-MC-Unique: jaSl1Ea2P9mgXCJA87tZXQ-1 X-Mimecast-MFC-AGG-ID: jaSl1Ea2P9mgXCJA87tZXQ_1761579711 From: Juraj Marcin To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Xu , "Dr. David Alan Gilbert" , Jiri Denemark , Fabiano Rosas Subject: [PATCH v2 4/4] migration: Introduce POSTCOPY_DEVICE state Date: Mon, 27 Oct 2025 16:41:11 +0100 Message-ID: <20251027154115.4138677-5-jmarcin@redhat.com> In-Reply-To: <20251027154115.4138677-1-jmarcin@redhat.com> References: <20251027154115.4138677-1-jmarcin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=jmarcin@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: 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 @redhat.com) X-ZM-MESSAGEID: 1761579789579154100 Content-Type: text/plain; charset="utf-8" From: Juraj Marcin Currently, when postcopy starts, the source VM starts switchover and sends a package containing the state of all non-postcopiable devices. When the destination loads this package, the switchover is complete and the destination VM starts. However, if the device state load fails or the destination side crashes, the source side is already in POSTCOPY_ACTIVE state and cannot be recovered, even when it has the most up-to-date machine state as the destination has not yet started. This patch introduces a new POSTCOPY_DEVICE state which is active while the destination machine is loading the device state, is not yet running, and the source side can be resumed in case of a migration failure. To transition from POSTCOPY_DEVICE to POSTCOPY_ACTIVE, the source side uses a PONG message that is a response to a PING message processed just before the POSTCOPY_RUN command that starts the destination VM. Thus, this feature is effective even if the destination side does not yet support this new state. Signed-off-by: Juraj Marcin Reviewed-by: Peter Xu --- migration/migration.c | 42 ++++++++++++++++++++++++--- migration/migration.h | 3 ++ migration/postcopy-ram.c | 8 +++-- migration/savevm.c | 2 ++ migration/savevm.h | 2 ++ migration/trace-events | 1 + qapi/migration.json | 8 +++-- tests/qtest/migration/precopy-tests.c | 3 +- 8 files changed, 60 insertions(+), 9 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 2cc6327c39..38f1a888a1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1217,6 +1217,7 @@ bool migration_is_running(void) =20 switch (s->state) { case MIGRATION_STATUS_ACTIVE: + case MIGRATION_STATUS_POSTCOPY_DEVICE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_POSTCOPY_PAUSED: case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: @@ -1238,6 +1239,7 @@ static bool migration_is_active(void) MigrationState *s =3D current_migration; =20 return (s->state =3D=3D MIGRATION_STATUS_ACTIVE || + s->state =3D=3D MIGRATION_STATUS_POSTCOPY_DEVICE || s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); } =20 @@ -1360,6 +1362,7 @@ static void fill_source_migration_info(MigrationInfo = *info) break; case MIGRATION_STATUS_ACTIVE: case MIGRATION_STATUS_CANCELLING: + case MIGRATION_STATUS_POSTCOPY_DEVICE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_PRE_SWITCHOVER: case MIGRATION_STATUS_DEVICE: @@ -1413,6 +1416,7 @@ static void fill_destination_migration_info(Migration= Info *info) case MIGRATION_STATUS_CANCELLING: case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_ACTIVE: + case MIGRATION_STATUS_POSTCOPY_DEVICE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_POSTCOPY_PAUSED: case MIGRATION_STATUS_POSTCOPY_RECOVER: @@ -1752,6 +1756,7 @@ bool migration_in_postcopy(void) MigrationState *s =3D migrate_get_current(); =20 switch (s->state) { + case MIGRATION_STATUS_POSTCOPY_DEVICE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_POSTCOPY_PAUSED: case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: @@ -1853,6 +1858,8 @@ int migrate_init(MigrationState *s, Error **errp) memset(&mig_stats, 0, sizeof(mig_stats)); migration_reset_vfio_bytes_transferred(); =20 + s->postcopy_package_loaded =3D false; + return 0; } =20 @@ -2608,6 +2615,11 @@ static void *source_return_path_thread(void *opaque) tmp32 =3D ldl_be_p(buf); trace_source_return_path_thread_pong(tmp32); qemu_sem_post(&ms->rp_state.rp_pong_acks); + if (tmp32 =3D=3D QEMU_VM_PING_PACKAGED_LOADED) { + trace_source_return_path_thread_postcopy_package_loaded(); + ms->postcopy_package_loaded =3D true; + qemu_event_set(&ms->postcopy_package_loaded_event); + } break; =20 case MIG_RP_MSG_REQ_PAGES: @@ -2853,6 +2865,13 @@ static int postcopy_start(MigrationState *ms, Error = **errp) if (migrate_postcopy_ram()) { qemu_savevm_send_ping(fb, 3); } + /* + * This ping will tell us that all non-postcopiable device state has b= een + * successfully loaded and the destination is about to start. When res= ponse + * is received, it will trigger transition from POSTCOPY_DEVICE to + * POSTCOPY_ACTIVE state. + */ + qemu_savevm_send_ping(fb, QEMU_VM_PING_PACKAGED_LOADED); =20 qemu_savevm_send_postcopy_run(fb); =20 @@ -2910,7 +2929,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) =20 /* Now, switchover looks all fine, switching to postcopy-active */ migrate_set_state(&ms->state, MIGRATION_STATUS_DEVICE, - MIGRATION_STATUS_POSTCOPY_ACTIVE); + MIGRATION_STATUS_POSTCOPY_DEVICE); =20 bql_unlock(); =20 @@ -3351,8 +3370,8 @@ static MigThrError migration_detect_error(MigrationSt= ate *s) return postcopy_pause(s); } else { /* - * For precopy (or postcopy with error outside IO), we fail - * with no time. + * For precopy (or postcopy with error outside IO, or before dest + * starts), we fail with no time. */ migrate_set_state(&s->state, state, MIGRATION_STATUS_FAILED); trace_migration_thread_file_err(); @@ -3487,7 +3506,8 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) { uint64_t must_precopy, can_postcopy, pending_size; Error *local_err =3D NULL; - bool in_postcopy =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE; + bool in_postcopy =3D (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_DEVICE= || + s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); bool can_switchover =3D migration_can_switchover(s); bool complete_ready; =20 @@ -3503,6 +3523,18 @@ static MigIterateState migration_iteration_run(Migra= tionState *s) * POSTCOPY_ACTIVE it means switchover already happened. */ complete_ready =3D !pending_size; + if (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_DEVICE && + (s->postcopy_package_loaded || complete_ready)) { + /* + * If package has been loaded, the event is set and we will + * immediatelly transition to POSTCOPY_ACTIVE. If we are ready= for + * completion, we need to wait for destination to load the pos= tcopy + * package before actually completing. + */ + qemu_event_wait(&s->postcopy_package_loaded_event); + migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_DEVICE, + MIGRATION_STATUS_POSTCOPY_ACTIVE); + } } else { /* * Exact pending reporting is only needed for precopy. Taking RAM @@ -4157,6 +4189,7 @@ static void migration_instance_finalize(Object *obj) qemu_sem_destroy(&ms->rp_state.rp_pong_acks); qemu_sem_destroy(&ms->postcopy_qemufile_src_sem); error_free(ms->error); + qemu_event_destroy(&ms->postcopy_package_loaded_event); } =20 static void migration_instance_init(Object *obj) @@ -4178,6 +4211,7 @@ static void migration_instance_init(Object *obj) qemu_sem_init(&ms->wait_unplug_sem, 0); qemu_sem_init(&ms->postcopy_qemufile_src_sem, 0); qemu_mutex_init(&ms->qemu_file_lock); + qemu_event_init(&ms->postcopy_package_loaded_event, 0); } =20 /* diff --git a/migration/migration.h b/migration/migration.h index 9d9e95ae90..050ded9e69 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -511,6 +511,9 @@ struct MigrationState { /* Is this a rdma migration */ bool rdma_migration; =20 + bool postcopy_package_loaded; + QemuEvent postcopy_package_loaded_event; + GSource *hup_source; }; =20 diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 0375366ed0..985b66d1a6 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -2094,7 +2094,7 @@ static void *postcopy_listen_thread(void *opaque) object_ref(OBJECT(migr)); =20 migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, - MIGRATION_STATUS_POSTCOPY_ACTIVE); + MIGRATION_STATUS_POSTCOPY_DEVICE); qemu_event_set(&mis->thread_sync_event); trace_postcopy_ram_listen_thread_start(); =20 @@ -2140,7 +2140,7 @@ static void *postcopy_listen_thread(void *opaque) "loadvm failed during postcopy: %d: ", load_res); migrate_set_error(migr, local_err); error_report_err(local_err); - migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIV= E, + migrate_set_state(&mis->state, mis->state, MIGRATION_STATUS_FAILED); goto out; } @@ -2152,6 +2152,10 @@ static void *postcopy_listen_thread(void *opaque) */ qemu_event_wait(&mis->main_thread_load_event); =20 + /* + * Device load in the main thread has finished, we should be in + * POSTCOPY_ACTIVE now. + */ migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, MIGRATION_STATUS_COMPLETED); =20 diff --git a/migration/savevm.c b/migration/savevm.c index 27fe815731..209c41c5b6 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2169,6 +2169,8 @@ static int loadvm_postcopy_handle_run(MigrationIncomi= ngState *mis, Error **errp) return -1; } =20 + migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_DEVICE, + MIGRATION_STATUS_POSTCOPY_ACTIVE); postcopy_state_set(POSTCOPY_INCOMING_RUNNING); migration_bh_schedule(loadvm_postcopy_handle_run_bh, mis); =20 diff --git a/migration/savevm.h b/migration/savevm.h index c337e3e3d1..125a2507b7 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -29,6 +29,8 @@ #define QEMU_VM_COMMAND 0x08 #define QEMU_VM_SECTION_FOOTER 0x7e =20 +#define QEMU_VM_PING_PACKAGED_LOADED 0x42 + bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_non_migratable_list(strList **reasons); int qemu_savevm_state_prepare(Error **errp); diff --git a/migration/trace-events b/migration/trace-events index e8edd1fbba..48518a4b2c 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -191,6 +191,7 @@ source_return_path_thread_pong(uint32_t val) "0x%x" source_return_path_thread_shut(uint32_t val) "0x%x" source_return_path_thread_resume_ack(uint32_t v) "%"PRIu32 source_return_path_thread_switchover_acked(void) "" +source_return_path_thread_postcopy_package_loaded(void) "" migration_thread_low_pending(uint64_t pending) "%" PRIu64 migrate_transferred(uint64_t transferred, uint64_t time_spent, uint64_t ba= ndwidth, uint64_t avail_bw, uint64_t size) "transferred %" PRIu64 " time_sp= ent %" PRIu64 " bandwidth %" PRIu64 " switchover_bw %" PRIu64 " max_size %"= PRId64 process_incoming_migration_co_end(int ret, int ps) "ret=3D%d postcopy-stat= e=3D%d" diff --git a/qapi/migration.json b/qapi/migration.json index da5b3a4d8c..c22285fd1c 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -142,6 +142,10 @@ # @postcopy-active: like active, but now in postcopy mode. # (since 2.5) # +# @postcopy-device: like postcopy-active, but the destination is still +# loading device state and is not running yet. If migration fails +# during this state, the source side will resume. (since 10.2) +# # @postcopy-paused: during postcopy but paused. (since 3.0) # # @postcopy-recover-setup: setup phase for a postcopy recovery @@ -173,8 +177,8 @@ ## { 'enum': 'MigrationStatus', 'data': [ 'none', 'setup', 'cancelling', 'cancelled', - 'active', 'postcopy-active', 'postcopy-paused', - 'postcopy-recover-setup', + 'active', 'postcopy-device', 'postcopy-active', + 'postcopy-paused', 'postcopy-recover-setup', 'postcopy-recover', 'completed', 'failed', 'colo', 'pre-switchover', 'device', 'wait-unplug' ] } ## diff --git a/tests/qtest/migration/precopy-tests.c b/tests/qtest/migration/= precopy-tests.c index bb38292550..57ca623de5 100644 --- a/tests/qtest/migration/precopy-tests.c +++ b/tests/qtest/migration/precopy-tests.c @@ -1316,13 +1316,14 @@ void migration_test_add_precopy(MigrationTestEnv *e= nv) } =20 /* ensure new status don't go unnoticed */ - assert(MIGRATION_STATUS__MAX =3D=3D 15); + assert(MIGRATION_STATUS__MAX =3D=3D 16); =20 for (int i =3D MIGRATION_STATUS_NONE; i < MIGRATION_STATUS__MAX; i++) { switch (i) { case MIGRATION_STATUS_DEVICE: /* happens too fast */ case MIGRATION_STATUS_WAIT_UNPLUG: /* no support in tests */ case MIGRATION_STATUS_COLO: /* no support in tests */ + case MIGRATION_STATUS_POSTCOPY_DEVICE: /* postcopy can't be cancel= led */ case MIGRATION_STATUS_POSTCOPY_ACTIVE: /* postcopy can't be cancel= led */ case MIGRATION_STATUS_POSTCOPY_PAUSED: case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: --=20 2.51.0