From nobody Mon Feb 9 03:12:52 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1626190091; cv=none; d=zohomail.com; s=zohoarc; b=TOYVwUyNsBkNyVcni6yoZjatf8dG7hmW53Jf2Jo9Va3bWjX06Zfg3kA6wmMJwtjpySHdK7H2etfCXmIlV9KASP9pYInonmRiz6A9shZyRHGbIE+njHyh2g0/rg4orFTT4Gyk6z5AYpaPcB3alQhpwq7SeEFuqKo0G+kWMsxPo9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626190091; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0snJlGCX5abLMsB6dvL+8UI1xERqaWyAo489B2AWz0I=; b=mVoe4qRBOFvgCosRrH3WHDMQHZBgS/UR1hMhyF8EkO7A5Gg1l5FEYBCTHPE8ghlL++vk8FyAZ3XmLx5+3Xp9KkfE8R8q1PbBxULpuRXH5Y/kUOG1GT5LKX13KOKaqyUzyP4h8PyBvaA7qtP6WdC+d2CKZDiCwr1qWOoZYZcrX34= 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 1626190091168194.41270825180152; Tue, 13 Jul 2021 08:28:11 -0700 (PDT) Received: from localhost ([::1]:36386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3KKQ-0002ZH-4e for importer@patchew.org; Tue, 13 Jul 2021 11:28:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3KGW-000316-Sv for qemu-devel@nongnu.org; Tue, 13 Jul 2021 11:24:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45250) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3KGV-0001uN-7L for qemu-devel@nongnu.org; Tue, 13 Jul 2021 11:24:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-J4ydi55hPUiRdT5Ulap2CQ-1; Tue, 13 Jul 2021 11:24:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1A12804140; Tue, 13 Jul 2021 15:24:03 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-114-214.ams2.redhat.com [10.36.114.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EBDE5D9CA; Tue, 13 Jul 2021 15:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626189846; 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=0snJlGCX5abLMsB6dvL+8UI1xERqaWyAo489B2AWz0I=; b=d5W9CAwvUu9+E29xGlvGkM/vBQFUk66x6mv7ATBntrIqFWzokGUS4mEygWqOtY0tPmNqfQ 17kHhj2UIhIAcMcAJKvyLURHg9AJQqRUHPK8uXgAW79G53IgN3Rpp870/44SZL8TaYczNA 1/Slmb+39S8g3kPAxtYEy5FeTdylUa4= X-MC-Unique: J4ydi55hPUiRdT5Ulap2CQ-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, lizhijian@cn.fujitsu.com, lvivier@redhat.com, peterx@redhat.com Subject: [PULL 3/6] migration: Release return path early for paused postcopy Date: Tue, 13 Jul 2021 16:23:21 +0100 Message-Id: <20210713152324.217255-4-dgilbert@redhat.com> In-Reply-To: <20210713152324.217255-1-dgilbert@redhat.com> References: <20210713152324.217255-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@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=170.10.133.124; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626190091688100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu 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 Message-Id: <20210708190653.252961-2-peterx@redhat.com> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert --- migration/migration.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index d717cd089a..38ebc6c1ab 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