From nobody Mon Nov 25 11:49:10 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1715211449; cv=none; d=zohomail.com; s=zohoarc; b=W611Mg3Du84/vpaiLAx/xvWb8gbCcpqrAhE0hmh5+U/tbKWF92ABPNmKK22QyatbqLXWEyjoqdGNb271olRZfPomoPgDNXkbRfkAltC9D4tP1yvUt3H8p5Q6atShoNg6Oh5fSTYwA5cM7PYQEOhn3V5klHrQ2jrJVh13Ovg/aFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715211449; 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=T7TwvoAVe5RioVfpxD++Axd+EsFoR7/haRQrRhvgaKM=; b=dzmE8POrmdrkZpXLHMQtSjGuUPdMyfnn6Ts5F8G+VdNJ/EkNF88vTjAtZ9N8tlbLlEBBcifWL9/qS8fM8eiO+6p5lNBk3iFRuxO+9czWKapskU0HjshH2zPPeAG1lB8KeNeJSMNC/HDY0v8Hy4Jl/cqlUKaE6m/1Qfv2g3e6kAM= 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 1715211449211162.71388677478876; Wed, 8 May 2024 16:37:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4qpO-0002g5-Lu; Wed, 08 May 2024 19:36:02 -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 1s4qpL-0002fW-HT for qemu-devel@nongnu.org; Wed, 08 May 2024 19:36:00 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4qpJ-0002Lj-HC for qemu-devel@nongnu.org; Wed, 08 May 2024 19:35:59 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4F8385D38D; Wed, 8 May 2024 23:35:56 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B174F13A27; Wed, 8 May 2024 23:35:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id QIj2HVoMPGZ7FQAAD6G6ig (envelope-from ); Wed, 08 May 2024 23:35:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715211356; h=from:from:reply-to: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=T7TwvoAVe5RioVfpxD++Axd+EsFoR7/haRQrRhvgaKM=; b=oyFYwT6PxlJJ6ks+YUGxgvZ6OR5MIldFzyzRRF4dJGMWWL6I6a+cO5HIVe8DSDXryasNcT uOtZjajZUPplsvKJ8v85dRdNZCVwGV30t4SaGrEnud1GH8SVf6DkntCoRO5TnAZ8JGCcxd kZ+vHwHr+6N/x9lNO8J/efWEVO9X5kk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715211356; h=from:from:reply-to: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=T7TwvoAVe5RioVfpxD++Axd+EsFoR7/haRQrRhvgaKM=; b=+UHqGcS9NYu/81yoz0TchQOMe9L1IIoW0cYy6GVnJlgZSzDp/DiPcM4IALpn8yjGAglyrQ XohTvO4E0n6MVjCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715211356; h=from:from:reply-to: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=T7TwvoAVe5RioVfpxD++Axd+EsFoR7/haRQrRhvgaKM=; b=oyFYwT6PxlJJ6ks+YUGxgvZ6OR5MIldFzyzRRF4dJGMWWL6I6a+cO5HIVe8DSDXryasNcT uOtZjajZUPplsvKJ8v85dRdNZCVwGV30t4SaGrEnud1GH8SVf6DkntCoRO5TnAZ8JGCcxd kZ+vHwHr+6N/x9lNO8J/efWEVO9X5kk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715211356; h=from:from:reply-to: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=T7TwvoAVe5RioVfpxD++Axd+EsFoR7/haRQrRhvgaKM=; b=+UHqGcS9NYu/81yoz0TchQOMe9L1IIoW0cYy6GVnJlgZSzDp/DiPcM4IALpn8yjGAglyrQ XohTvO4E0n6MVjCA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Richard Henderson , Vladimir Sementsov-Ogievskiy , Markus Armbruster Subject: [PULL v2 06/13] qapi: introduce exit-on-error parameter for migrate-incoming Date: Wed, 8 May 2024 20:35:34 -0300 Message-Id: <20240508233541.2403-7-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240508233541.2403-1-farosas@suse.de> References: <20240508233541.2403-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; RCVD_TLS_ALL(0.00)[] 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: 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 @suse.de) X-ZM-MESSAGEID: 1715211449899100003 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Now we do set MIGRATION_FAILED state, but don't give a chance to orchestrator to query migration state and get the error. Let's provide a possibility for QMP-based orchestrators to get an error like with outgoing migration. For hmp_migrate_incoming(), let's enable the new behavior: HMP is not and ABI, it's mostly intended to use by developer and it makes sense not to stop the process. For x-exit-preconfig, let's keep the old behavior: - it's called from init(), so here we want to keep current behavior by default - it does exit on error by itself as well So, if we want to change the behavior of x-exit-preconfig, it should be another patch. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/migration-hmp-cmds.c | 2 +- migration/migration.c | 33 +++++++++++++++++++++++++++------ migration/migration.h | 3 +++ qapi/migration.json | 7 ++++++- system/vl.c | 3 ++- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 7e96ae6ffd..23181bbee1 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -466,7 +466,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, &err); + qmp_migrate_incoming(NULL, true, caps, true, false, &err); qapi_free_MigrationChannelList(caps); =20 end: diff --git a/migration/migration.c b/migration/migration.c index a9599838e6..289afa8d85 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -72,6 +72,8 @@ #define NOTIFIER_ELEM_INIT(array, elem) \ [elem] =3D NOTIFIER_WITH_RETURN_LIST_INITIALIZER((array)[elem]) =20 +#define INMIGRATE_DEFAULT_EXIT_ON_ERROR true + static NotifierWithReturnList migration_state_notifiers[] =3D { NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_NORMAL), NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_CPR_REBOOT), @@ -234,6 +236,8 @@ void migration_object_init(void) qemu_cond_init(¤t_incoming->page_request_cond); current_incoming->page_requested =3D g_tree_new(page_request_addr_cmp); =20 + current_incoming->exit_on_error =3D INMIGRATE_DEFAULT_EXIT_ON_ERROR; + migration_object_check(current_migration, &error_fatal); =20 blk_mig_init(); @@ -800,12 +804,14 @@ fail: =20 migration_incoming_state_destroy(); =20 - WITH_QEMU_LOCK_GUARD(&s->error_mutex) { - error_report_err(s->error); - s->error =3D NULL; - } + if (mis->exit_on_error) { + WITH_QEMU_LOCK_GUARD(&s->error_mutex) { + error_report_err(s->error); + s->error =3D NULL; + } =20 - exit(EXIT_FAILURE); + exit(EXIT_FAILURE); + } } =20 /** @@ -1314,6 +1320,15 @@ static void fill_destination_migration_info(Migratio= nInfo *info) break; } info->status =3D mis->state; + + if (!info->error_desc) { + MigrationState *s =3D migrate_get_current(); + QEMU_LOCK_GUARD(&s->error_mutex); + + if (s->error) { + info->error_desc =3D g_strdup(error_get_pretty(s->error)); + } + } } =20 MigrationInfo *qmp_query_migrate(Error **errp) @@ -1797,10 +1812,13 @@ void migrate_del_blocker(Error **reasonp) } =20 void qmp_migrate_incoming(const char *uri, bool has_channels, - MigrationChannelList *channels, Error **errp) + MigrationChannelList *channels, + bool has_exit_on_error, bool exit_on_error, + Error **errp) { Error *local_err =3D NULL; static bool once =3D true; + MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 if (!once) { error_setg(errp, "The incoming migration has already been started"= ); @@ -1815,6 +1833,9 @@ void qmp_migrate_incoming(const char *uri, bool has_c= hannels, return; } =20 + mis->exit_on_error =3D + has_exit_on_error ? exit_on_error : INMIGRATE_DEFAULT_EXIT_ON_ERRO= R; + qemu_start_incoming_migration(uri, has_channels, channels, &local_err); =20 if (local_err) { diff --git a/migration/migration.h b/migration/migration.h index 6c612c0381..f3406c43c8 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -227,6 +227,9 @@ struct MigrationIncomingState { * is needed as this field is updated serially. */ unsigned int switchover_ack_pending_num; + + /* Do exit on incoming migration failure */ + bool exit_on_error; }; =20 MigrationIncomingState *migration_incoming_get_current(void); diff --git a/qapi/migration.json b/qapi/migration.json index 8c65b90328..9feed413b5 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1837,6 +1837,10 @@ # @channels: list of migration stream channels with each stream in the # list connected to a destination interface endpoint. # +# @exit-on-error: Exit on incoming migration failure. Default true. +# When set to false, the failure triggers a MIGRATION event, and +# error details could be retrieved with query-migrate. (since 9.1) +# # Since: 2.3 # # Notes: @@ -1889,7 +1893,8 @@ ## { 'command': 'migrate-incoming', 'data': {'*uri': 'str', - '*channels': [ 'MigrationChannel' ] } } + '*channels': [ 'MigrationChannel' ], + '*exit-on-error': 'bool' } } =20 ## # @xen-save-devices-state: diff --git a/system/vl.c b/system/vl.c index 7756eac81e..79cd498395 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2723,7 +2723,8 @@ void qmp_x_exit_preconfig(Error **errp) if (incoming) { Error *local_err =3D NULL; if (strcmp(incoming, "defer") !=3D 0) { - qmp_migrate_incoming(incoming, false, NULL, &local_err); + qmp_migrate_incoming(incoming, false, NULL, true, true, + &local_err); if (local_err) { error_reportf_err(local_err, "-incoming %s: ", incoming); exit(1); --=20 2.35.3