From nobody Sun Feb 8 16:12:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625771562925259.97368974340634; Thu, 8 Jul 2021 12:12:42 -0700 (PDT) Received: from localhost ([::1]:57946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1ZRx-0007nv-UI for importer@patchew.org; Thu, 08 Jul 2021 15:12:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1ZMl-0000E8-RW for qemu-devel@nongnu.org; Thu, 08 Jul 2021 15:07:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1ZMX-0003xJ-IS for qemu-devel@nongnu.org; Thu, 08 Jul 2021 15:07:17 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-Aiq9KeofN_G88bXKFVryXA-1; Thu, 08 Jul 2021 15:07:00 -0400 Received: by mail-qt1-f198.google.com with SMTP id q16-20020ac845100000b0290252006e22f6so4129703qtn.22 for ; Thu, 08 Jul 2021 12:07:00 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-65-184-144-111-238.dsl.bell.ca. [184.144.111.238]) by smtp.gmail.com with ESMTPSA id v15sm1430976qkp.96.2021.07.08.12.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 12:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625771223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qoGIaSSybi+Tx59880HHNpG+HkBjifrEItBdgQov8Zc=; b=b5YBJXc/OcvCSY0VlGXYYfvK/YY+mterC9No2hlm/z2R0ghURX1jna2Mokz5FpYZeEvaaB RWfLPFPpBICF+CDjuvwzTLb3rcj46Vi5phl01FZ0IUH35ZEFUE6qrjcfy9ELtZwn88pfYJ sjYUAvAqBCj5APEwjeMKYTIxF9a16y4= X-MC-Unique: Aiq9KeofN_G88bXKFVryXA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qoGIaSSybi+Tx59880HHNpG+HkBjifrEItBdgQov8Zc=; b=FNMuIzpQLrZxgj9cCI5Y5sztHX5IQYt75AwklAOubimzJykS9JxeN4/aEylUVT3uDm L2OQl8m0HivK0ehQrv7/XK0UZnUqjc/s+ol5W24vwCJNatYX3+PHZQItYyYNEMVbhkZo N0taP1YXhpj5/Mpf+lYoK3hg3XEXsp8AS892yWREDUb7CwVD9pONQrm0+7BLqycI/8Tv nZ4H3WmdUDPnp5ekSbxo4jy5+QVaCVhyBuT+gypDfmAjPgm8FBeqx9nE1oMENhN7mThi qSaq8p+UhMrfwsd+hBLk6MJcdyA/ojXj31HD/aRMN6A0tm1Oo7HAh4jIcHtxPrIYfjaZ +oCQ== X-Gm-Message-State: AOAM530splWDRbd5dyK18q1PL3sPI5DjkXfqum8LKP6tYqXQrgp8c8q5 Xa3Dq6VDvyeN6Bo2i+CXMIcW8bFCYXtUbMJ0MOBbvO9MHDr9w53InkuoUQugkp0a8kBZszo4WnI DKaml7noXU4igmxaKkkoT8jmTtFmg0Heuu/e/cgQ48b4tfZu7/cRyhX1hm/V3koJA X-Received: by 2002:a0c:d68f:: with SMTP id k15mr31602885qvi.14.1625771219261; Thu, 08 Jul 2021 12:06:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9MixROmqxryFMKlkfBrq/qrsoYCiuPw+Vfu3jp6rSeUPNDTDbuyEFYQNyF2+6MXS8FA8yyQ== X-Received: by 2002:a0c:d68f:: with SMTP id k15mr31602854qvi.14.1625771218970; Thu, 08 Jul 2021 12:06:58 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH 1/3] migration: Release return path early for paused postcopy Date: Thu, 8 Jul 2021 15:06:51 -0400 Message-Id: <20210708190653.252961-2-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210708190653.252961-1-peterx@redhat.com> References: <20210708190653.252961-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lukas Straub , Juan Quintela , Li Xiaohui , "Dr . David Alan Gilbert" , peterx@redhat.com, Li Xiaohui , Leonardo Bras Soares Passos Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625771563939100001 Content-Type: text/plain; charset="utf-8" When postcopy pause triggered, we rely on the migration thread to cleanup t= he to_dst_file handle, and the return path thread to cleanup the from_dst_file handle (which is stored in the local variable "rp"). Within the process, from_dst_file cleanup (qemu_fclose) is postponed until = it's setup again due to a postcopy recovery. It used to work before yank was born; after yank is introduced we rely on t= he refcount of IOC to correctly unregister yank function in channel_close(). = If without the early and on-time release of from_dst_file handle the yank func= tion will be leftover during paused postcopy. Without this patch, below steps (quoted from Xiaohui) could trigger qemu src crash: 1.Boot vm on src host 2.Boot vm on dst host 3.Enable postcopy on src&dst host 4.Load stressapptest in vm and set postcopy speed to 50M 5.Start migration from src to dst host, change into postcopy mode when mi= gration is active. 6.When postcopy is active, down the network card(do migration via this ne= twork) on dst host. 7.Wait untill postcopy is paused on src&dst host. 8.Before up network card, recover migration on dst host, will get error l= ike following. 9.Ignore the error of step 8, go on recovering migration on src host: After step 9, qemu on src host will core dump after some seconds: qemu-kvm: ../util/yank.c:107: yank_unregister_instance: Assertion `QLIST_= EMPTY(&entry->yankfns)' failed. 1.sh: line 38: 44662 Aborted (core dumped) Reported-by: Li Xiaohui Signed-off-by: Peter Xu --- migration/migration.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 5ff7ba9d5c..8786104c9a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2818,12 +2818,12 @@ out: * Maybe there is something we can do: it looks like a * network down issue, and we pause for a recovery. */ + qemu_fclose(rp); + ms->rp_state.from_dst_file =3D NULL; + rp =3D NULL; if (postcopy_pause_return_path_thread(ms)) { /* Reload rp, reset the rest */ - if (rp !=3D ms->rp_state.from_dst_file) { - qemu_fclose(rp); - rp =3D ms->rp_state.from_dst_file; - } + rp =3D ms->rp_state.from_dst_file; ms->rp_state.error =3D false; goto retry; } --=20 2.31.1 From nobody Sun Feb 8 16:12:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625772163452987.6667524624244; Thu, 8 Jul 2021 12:22:43 -0700 (PDT) Received: from localhost ([::1]:57798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Zbe-0001Ag-4e for importer@patchew.org; Thu, 08 Jul 2021 15:22:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1ZMl-0000E1-Qx for qemu-devel@nongnu.org; Thu, 08 Jul 2021 15:07:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1ZMX-0003x5-I7 for qemu-devel@nongnu.org; Thu, 08 Jul 2021 15:07:16 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-341-ySh8I9C9MmuxLdoG8WPGow-1; Thu, 08 Jul 2021 15:07:01 -0400 Received: by mail-qv1-f69.google.com with SMTP id eo5-20020ad459450000b02902d60d0f0744so1763522qvb.2 for ; Thu, 08 Jul 2021 12:07:01 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-65-184-144-111-238.dsl.bell.ca. [184.144.111.238]) by smtp.gmail.com with ESMTPSA id v15sm1430976qkp.96.2021.07.08.12.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 12:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625771222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JJwQBaEqPe/S8oFhJKkD4BqzmaMWBTRJJMPC5Q0UEuk=; b=CspCWdgbn9JjLE7VcDRm/udfGCSIZxWIiKm8Ytpsrulwk7ryhXwJ+F/1plW6e47lqB5OUb CX8uFyBadQu8PO4x1LwYeerwQr0x6frTAbMYGu7dQNroJoPaOtdQKJcVGh5rc1nvX4x85J OHcFsJORNUPGn02hcI/3zIh61VNktjo= X-MC-Unique: ySh8I9C9MmuxLdoG8WPGow-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JJwQBaEqPe/S8oFhJKkD4BqzmaMWBTRJJMPC5Q0UEuk=; b=oI1avNYPxylX2DSFomrj6tgyDf+d1Ny3T6xRMWYXHcVlQrbdU8DCoJHwpUPhmIPjQa xTBmvUJFZgOQzcmCsq4Q9njWiOG4QVYlQpZClHb0cJdHX1t8rQByXFDpCcbHygPbT4/e GblaA6SLgEvy4EGTTVryzN7d2D/3jpVMp22lgfvU0jFMZjlwWzaqfH1K1tmhNfITE+ls X+arh8iqzYWoV1EIOA2pZdwj5whFz3kv+hwN8ejJ9x/nu4uGrVW2+4D+V2XHWeD/m7g/ GLExUUFTqQerBI7qp/0j7p/HwDO3RhtZj6Zt0hzx5OLIho+gjH8HUz5SuVMysE0MnNvk Lsog== X-Gm-Message-State: AOAM530ypPlwYXkvtokq4ILt7HiehjLqyNufp2EYxk6a2B92GFEOzYmE otGsVWdL1rF+gZWxeHt7/+hqfgoALA/TPj7t8ATRxmT2ScJm9OghcSxesdSb2fS4iQCRCPqz2Cg hBg3Ykh0h49NrzPSmSokbEjf5+EDkArsm6mFP1/4TlcLuJ8Pq0PXsl+c4HKnXndX7 X-Received: by 2002:a0c:d605:: with SMTP id c5mr31753184qvj.7.1625771220626; Thu, 08 Jul 2021 12:07:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVEvDnVhxPLDF3lUqLj/Qu0dmXfXhy3AexNw8ydrvgyf/ueTGTtpvK9CcNYRbnKhDGg7eKhw== X-Received: by 2002:a0c:d605:: with SMTP id c5mr31753164qvj.7.1625771220429; Thu, 08 Jul 2021 12:07:00 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH 2/3] migration: Don't do migrate cleanup if during postcopy resume Date: Thu, 8 Jul 2021 15:06:52 -0400 Message-Id: <20210708190653.252961-3-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210708190653.252961-1-peterx@redhat.com> References: <20210708190653.252961-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lukas Straub , Juan Quintela , Li Xiaohui , "Dr . David Alan Gilbert" , peterx@redhat.com, Leonardo Bras Soares Passos Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625772165565100001 Content-Type: text/plain; charset="utf-8" Below process could crash qemu with postcopy recovery: 1. (hmp) migrate -d .. 2. (hmp) migrate_start_postcopy 3. [network down, postcopy paused] 4. (hmp) migrate -r $WRONG_PORT when try the recover on an invalid $WRONG_PORT, cleanup_bh will be cle= ared 5. (hmp) migrate -r $RIGHT_PORT [qemu crash on assert(cleanup_bh)] The thing is we shouldn't cleanup if it's postcopy resume; the error is set mostly because the channel is wrong, so we return directly waiting for the = user to retry. migrate_fd_cleanup() should only be called when migration is cancelled or completed. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 8786104c9a..bb1edf862a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3975,7 +3975,18 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) } if (error_in) { migrate_fd_error(s, error_in); - migrate_fd_cleanup(s); + if (resume) { + /* + * Don't do cleanup for resume if channel is invalid, but only= dump + * the error. We wait for another channel connect from the us= er. + * The error_report still gives HMP user a hint on what failed. + * It's normally done in migrate_fd_cleanup(), but call it here + * explicitly. + */ + error_report_err(error_copy(s->error)); + } else { + migrate_fd_cleanup(s); + } return; } =20 --=20 2.31.1 From nobody Sun Feb 8 16:12:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625771926712512.8480240888817; Thu, 8 Jul 2021 12:18:46 -0700 (PDT) Received: from localhost ([::1]:49252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1ZXp-0003vt-JT for importer@patchew.org; Thu, 08 Jul 2021 15:18:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1ZMl-0000E0-Pz for qemu-devel@nongnu.org; Thu, 08 Jul 2021 15:07:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39067) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1ZMX-0003xN-I6 for qemu-devel@nongnu.org; Thu, 08 Jul 2021 15:07:10 -0400 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-437-LX6spscpMBqZOE3V-bKlUA-1; Thu, 08 Jul 2021 15:07:02 -0400 Received: by mail-qk1-f199.google.com with SMTP id a6-20020a37b1060000b02903b488f9d348so4546747qkf.20 for ; Thu, 08 Jul 2021 12:07:02 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-65-184-144-111-238.dsl.bell.ca. [184.144.111.238]) by smtp.gmail.com with ESMTPSA id v15sm1430976qkp.96.2021.07.08.12.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 12:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625771223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0BRbjQuT8HNr96LXHFpVqSFo2IEK25bz2jMcYUh5Y74=; b=X3wNC/Uxk81A55s037aY/gmd33nD89RIKYx18rw/rMwHCF7RG1ugZDrk4eMgdZjnraNFQc Gd67h1S2cPm76zJUXhGAtHYW6B05huCG3lBjI0Z/mh07VrzexDB6mzsQuI5rWMGjGI2IV+ A2UsBF4Qfo86/wTApBUaK9dXMnT1qKs= X-MC-Unique: LX6spscpMBqZOE3V-bKlUA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0BRbjQuT8HNr96LXHFpVqSFo2IEK25bz2jMcYUh5Y74=; b=rtq3QNeS4H5Eqp5CO8WODr1Z6GeCjtcI1t1dK0EXQ82pdATZVdwsIoIsLE0N3oDY7F w2jTHtCQ/LboaijDtkqBECQUK9eJ+q9lUAlVp4/992f1lX3MCMWZ2rbwPYh8fZAXinqV KrLJMnfbR/kcuI+bmj+yK/MKjlPGm7jZv8wdOWNSLPJ+DmbhJ/o6AKvPvVi0FulVmKuq Re+XCgRfP/p06/4ZZ7RrFUJA9bPBagXhb2K9R+hzCT8nJeo4W63kG9ZmHsWaWXysog4b Op6tSJdSjI50T7fPWhJHenrZTBq0TtTnY2sA6oULIkRqLqivjFpiwBSKWKtOEgZFtCWA +LuA== X-Gm-Message-State: AOAM532XxgsJbYowHiGg9S/RrX3iKlUlVcgmY3nwPy0RrbtQ+ZBgK4dQ MXqrgQBQfegz/axlTpediWO4+lwrMiDwKmd9Eb1VYBSO7jAOFOlOfbKL49M016oi+U7zQ6AGGhj PZlC/HfGjLZcKRrI1yqnImVP8SkGLwoT51Frbvxi/wCegD5674Dp5EmPGXCCXO00z X-Received: by 2002:ad4:4150:: with SMTP id z16mr7558652qvp.39.1625771222010; Thu, 08 Jul 2021 12:07:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywgXhywl2J2ZjDzq1orYnVuO0VR2RJKIt1R8olDfdvqhEaMEiLYKZn7CnRh0MaX/P+findAw== X-Received: by 2002:ad4:4150:: with SMTP id z16mr7558628qvp.39.1625771221762; Thu, 08 Jul 2021 12:07:01 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH 3/3] migration: Clear error at entry of migrate_fd_connect() Date: Thu, 8 Jul 2021 15:06:53 -0400 Message-Id: <20210708190653.252961-4-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210708190653.252961-1-peterx@redhat.com> References: <20210708190653.252961-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lukas Straub , Juan Quintela , Li Xiaohui , "Dr . David Alan Gilbert" , peterx@redhat.com, Leonardo Bras Soares Passos Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625771928770100001 Content-Type: text/plain; charset="utf-8" For each "migrate" command, remember to clear the s->error before going on. For one reason, when there's a new error it'll be still remembered; see migrate_set_error() who only sets the error if error=3D=3DNULL. Meanwhile = if a failed migration completes (e.g., postcopy recovered and finished), we shouldn't dump an error when calling migrate_fd_cleanup() at last. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index bb1edf862a..338df01e97 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1855,6 +1855,15 @@ void migrate_set_error(MigrationState *s, const Erro= r *error) } } =20 +static void migrate_error_free(MigrationState *s) +{ + QEMU_LOCK_GUARD(&s->error_mutex); + if (s->error) { + error_free(s->error); + s->error =3D NULL; + } +} + void migrate_fd_error(MigrationState *s, const Error *error) { trace_migrate_fd_error(error_get_pretty(error)); @@ -3966,6 +3975,13 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) int64_t rate_limit; bool resume =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_PAUSED; =20 + /* + * If there's a previous error, free it and prepare for another one. + * Meanwhile if migration completes successfully, there won't have an = error + * dumped when calling migrate_fd_cleanup(). + */ + migrate_error_free(s); + s->expected_downtime =3D s->parameters.downtime_limit; if (resume) { assert(s->cleanup_bh); --=20 2.31.1