From nobody Sun Apr 12 05:59: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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1771345023; cv=none; d=zohomail.com; s=zohoarc; b=mnwjT9FWdYyo6eC3z/NNDtbQQPnAPUvQxcM5fyGYBQwjZtPKTA4FgVzgLjEoO2RVlrYaeqEWjV7Y8Xa2FLiVQGV/+4BAbzpb+v6wzLWeiNyZacqBgiLHfwMxb7RX3GMKdRwlw6RNgdC1lnsPtZTzIWNsHcB11zIzpZarvAC2aDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771345023; 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=UZ9v1zRre8MJoTcvIKPSMOTVWa31kcAX+dlQiw/brnk=; b=VtO1SOoQxXzn1D2Y1+sMyGsHHEwTKAoqi0cTwqRPZYo8yd76Wyx0A8ZrZleM7gCkWyFASAy+J9a6HaGSPEqyFxNXbgeaDRzJg7iCdc61KSh2FF0qWqH4VOdtT6TRkE1hR9PTrhifweGSoRx3ZEF4lToKUZ4Wvii2AfQqUXe2RKs= 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 1771345023724444.8437123516943; Tue, 17 Feb 2026 08:17:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsNkK-0003br-UO; Tue, 17 Feb 2026 11:16:21 -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 1vsNkI-0003QP-Dl for qemu-devel@nongnu.org; Tue, 17 Feb 2026 11:16:18 -0500 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vsNkG-0003FR-J6 for qemu-devel@nongnu.org; Tue, 17 Feb 2026 11:16:18 -0500 Received: from imap1.dmz-prg2.suse.org (unknown [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-out1.suse.de (Postfix) with ESMTPS id 946F43E718; Tue, 17 Feb 2026 16:15:33 +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 5BD833EA66; Tue, 17 Feb 2026 16:15:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id OKd8CCSUlGmHTgAAD6G6ig (envelope-from ); Tue, 17 Feb 2026 16:15:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771344933; 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=UZ9v1zRre8MJoTcvIKPSMOTVWa31kcAX+dlQiw/brnk=; b=xbOII4FIonnBJFJH/aCRLAKee3dF6WvtKaPxdfP07QRO7ViCy5/hm5BAqnFPLGyWGUlPSU PuWM7JZfVE67mjayVQRQmBxcdyMxS+d5qfgfbC0FyoobHNGvo3LoiN4JwGjeqVnZb6iIAl bwNNbTe8Httqdz0hGn+5cxJsSYQ+9hs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771344933; 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=UZ9v1zRre8MJoTcvIKPSMOTVWa31kcAX+dlQiw/brnk=; b=kksFB/vwhJhLG7DaCbqAEEFeii/K01egg+HgH6vwyohWEsTKUILkdyUYrIuIi/94VxZ3mr pQflTMaLqsm3m+CQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771344933; 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=UZ9v1zRre8MJoTcvIKPSMOTVWa31kcAX+dlQiw/brnk=; b=xbOII4FIonnBJFJH/aCRLAKee3dF6WvtKaPxdfP07QRO7ViCy5/hm5BAqnFPLGyWGUlPSU PuWM7JZfVE67mjayVQRQmBxcdyMxS+d5qfgfbC0FyoobHNGvo3LoiN4JwGjeqVnZb6iIAl bwNNbTe8Httqdz0hGn+5cxJsSYQ+9hs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771344933; 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=UZ9v1zRre8MJoTcvIKPSMOTVWa31kcAX+dlQiw/brnk=; b=kksFB/vwhJhLG7DaCbqAEEFeii/K01egg+HgH6vwyohWEsTKUILkdyUYrIuIi/94VxZ3mr pQflTMaLqsm3m+CQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Lukas Straub Subject: [PULL 27/32] migration/bg-snapshot: Cleanup error paths Date: Tue, 17 Feb 2026 13:14:38 -0300 Message-ID: <20260217161443.12738-28-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260217161443.12738-1-farosas@suse.de> References: <20260217161443.12738-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; 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]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,web.de]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[web.de] X-Spam-Score: -2.80 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @suse.de) X-ZM-MESSAGEID: 1771345026295154100 Content-Type: text/plain; charset="utf-8" From: Peter Xu Cleanup bg_migration_thread() function on error handling. First of all, early_fail is almost only used to say if BQL is taken. Since we already have separate jumping labels, we don't really need it, hence removed. Also, since local_err is around, making sure every failure path will set a proper error string for the failure, then propagate to MigrationState.error. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Tested-by: Lukas Straub Link: https://lore.kernel.org/qemu-devel/20260127185254.3954634-22-peterx@r= edhat.com Signed-off-by: Fabiano Rosas --- migration/migration.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index f81ac21d4e..f9eec4b25a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3628,7 +3628,6 @@ static void *bg_migration_thread(void *opaque) int64_t setup_start; MigThrError thr_error; QEMUFile *fb; - bool early_fail =3D true; Error *local_err =3D NULL; int ret; =20 @@ -3674,10 +3673,7 @@ static void *bg_migration_thread(void *opaque) * devices to unplug. This to preserve migration state transitions. */ if (ret) { - migrate_error_propagate(s, local_err); - migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, - MIGRATION_STATUS_FAILED); - goto fail_setup; + goto fail; } =20 s->setup_time =3D qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; @@ -3687,11 +3683,13 @@ static void *bg_migration_thread(void *opaque) bql_lock(); =20 if (migration_stop_vm(s, RUN_STATE_PAUSED)) { - goto fail; + error_setg(&local_err, "Failed to stop the VM"); + goto fail_with_bql; } =20 if (qemu_savevm_state_non_iterable(fb)) { - goto fail; + error_setg(&local_err, "Failed to save non-iterable devices"); + goto fail_with_bql; } =20 qemu_savevm_state_end_precopy(s, fb); @@ -3704,9 +3702,9 @@ static void *bg_migration_thread(void *opaque) =20 /* Now initialize UFFD context and start tracking RAM writes */ if (ram_write_tracking_start()) { - goto fail; + error_setg(&local_err, "Failed to start write tracking"); + goto fail_with_bql; } - early_fail =3D false; =20 /* * Start VM from BH handler to avoid write-fault lock here. @@ -3738,21 +3736,22 @@ static void *bg_migration_thread(void *opaque) } =20 trace_migration_thread_after_loop(); + goto done; + +fail_with_bql: + bql_unlock(); =20 fail: - if (early_fail) { - migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, - MIGRATION_STATUS_FAILED); - bql_unlock(); - } + /* local_err is guaranteed to be set when reaching here */ + migrate_error_propagate(s, local_err); + migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, + MIGRATION_STATUS_FAILED); =20 -fail_setup: +done: bg_migration_iteration_finish(s); - qemu_fclose(fb); object_unref(OBJECT(s)); rcu_unregister_thread(); - return NULL; } =20 --=20 2.51.0