From nobody Tue Nov 26 08:24:46 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097465; cv=none; d=zohomail.com; s=zohoarc; b=Y2MmYB/dVIwtbISKfRmjPkILGNzdG1mzraJVcO161PyR0umfRZmFKH6SJfCcG28ckTFg/a7T3NXE3fPBR2H6itPpOcrUP8sxlswlKhFgxROt1rtXgVUbVdjiUFzxLxTR7x+Sa4VQYfTaZ9Dz9XxYQBRU0VMU03Cs1uqh0azcD1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097465; 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=Dg1ggDXCGJYUq+p4wWurYdu97dbcucxaIdvVX4P1Egk=; b=cXCoWmBCr1LTyfup/oOilSs3Sq1hEco1KcsVZ6Bnvv0ev3z7jzDG8c/pcxIH+q9xac67CdO6REmhuHkdvZItRBNSPYI7bdox+bSsRWgJe+yh166/ucKHq+LdL0WbB3btb0TMRga/tP9ctwafE7bSrB1aOqngxH+d7yOdfhq6HR4= 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 1709097465798622.8398712174843; Tue, 27 Feb 2024 21:17:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCJv-0002Kg-23; Wed, 28 Feb 2024 00:17:31 -0500 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 1rfCJ7-0001Kb-EY for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:46 -0500 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 1rfCIv-0007Gs-M9 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:39 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-NvQZgMmEP4qfaw3A-vC7Vw-1; Wed, 28 Feb 2024 00:16:25 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76E643C11CC3; Wed, 28 Feb 2024 05:16:25 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7093F1C060B1; Wed, 28 Feb 2024 05:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097389; 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=Dg1ggDXCGJYUq+p4wWurYdu97dbcucxaIdvVX4P1Egk=; b=gUa1sEkQ6J+3aVYoXPbZOR8zKdJKbgx5oS0SB2kcmPlIBTvF+9ys6Sw1l/fnGWiveyNeS/ iZQrL161kms9nHpQ4t9XIMYm6qNKKKOKhdkFVA5NpHrIJTzr842WKcE+ZhE2daNjvhzAHW za5Z2/t34mm/kAfZPKcTFGPg3oGdeZg= X-MC-Unique: NvQZgMmEP4qfaw3A-vC7Vw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 19/25] migration: notifier error checking Date: Wed, 28 Feb 2024 13:13:09 +0800 Message-ID: <20240228051315.400759-20-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: 1709097467820100017 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Check the status returned by migration notifiers for event type MIG_EVENT_PRECOPY_SETUP, and report errors. None of the notifiers return an error status at this time. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/1708622920-68779-10-git-send-email-steven.s= istare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 8 +++++++- migration/migration.c | 25 ++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 4dc06a92b7..e4933b815b 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -72,6 +72,11 @@ typedef struct MigrationEvent { MigrationEventType type; } MigrationEvent; =20 +/* + * A MigrationNotifyFunc may return an error code and an Error object, + * but only when @e->type is MIG_EVENT_PRECOPY_SETUP. The code is an int + * to allow for different failure modes and recovery actions. + */ typedef int (*MigrationNotifyFunc)(NotifierWithReturn *notify, MigrationEvent *e, Error **errp); =20 @@ -93,7 +98,8 @@ void migration_add_notifier_mode(NotifierWithReturn *noti= fy, MigrationNotifyFunc func, MigMode mode); =20 void migration_remove_notifier(NotifierWithReturn *notify); -void migration_call_notifiers(MigrationState *s, MigrationEventType type); +int migration_call_notifiers(MigrationState *s, MigrationEventType type, + Error **errp); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index 6a115d28b8..37c836b0b0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1376,7 +1376,7 @@ static void migrate_fd_cleanup(MigrationState *s) } type =3D migration_has_failed(s) ? MIG_EVENT_PRECOPY_FAILED : MIG_EVENT_PRECOPY_DONE; - migration_call_notifiers(s, type); + migration_call_notifiers(s, type, NULL); block_cleanup_parameters(); yank_unregister_instance(MIGRATION_YANK_INSTANCE); } @@ -1489,13 +1489,18 @@ void migration_remove_notifier(NotifierWithReturn *= notify) } } =20 -void migration_call_notifiers(MigrationState *s, MigrationEventType type) +int migration_call_notifiers(MigrationState *s, MigrationEventType type, + Error **errp) { MigMode mode =3D s->parameters.mode; MigrationEvent e; + int ret; =20 e.type =3D type; - notifier_with_return_list_notify(&migration_state_notifiers[mode], &e,= 0); + ret =3D notifier_with_return_list_notify(&migration_state_notifiers[mo= de], + &e, errp); + assert(!ret || type =3D=3D MIG_EVENT_PRECOPY_SETUP); + return ret; } =20 bool migration_in_setup(MigrationState *s) @@ -2549,7 +2554,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) * at the transition to postcopy and after the device state; in partic= ular * spice needs to trigger a transition now */ - migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE); + migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE, NULL); =20 migration_downtime_end(ms); =20 @@ -2569,11 +2574,10 @@ static int postcopy_start(MigrationState *ms, Error= **errp) =20 ret =3D qemu_file_get_error(ms->to_dst_file); if (ret) { - error_setg(errp, "postcopy_start: Migration stream errored"); - migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, - MIGRATION_STATUS_FAILED); + error_setg_errno(errp, -ret, "postcopy_start: Migration stream err= or"); + bql_lock(); + goto fail; } - trace_postcopy_preempt_enabled(migrate_postcopy_preempt()); =20 return ret; @@ -2594,6 +2598,7 @@ fail: error_report_err(local_err); } } + migration_call_notifiers(ms, MIG_EVENT_PRECOPY_FAILED, NULL); bql_unlock(); return -1; } @@ -3613,7 +3618,9 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) rate_limit =3D migrate_max_bandwidth(); =20 /* Notify before starting migration thread */ - migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP); + if (migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP, &local_er= r)) { + goto fail; + } } =20 migration_rate_set(rate_limit); --=20 2.43.0