From nobody Fri May 17 12:14:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1612882104; cv=none; d=zohomail.com; s=zohoarc; b=FKEAz5XcvOuynThzSRQ/IayN3NZO0DrGSryDt5YCcmVXNc77dHVUqo0y8nZI3x2+mEdGA8PPQKkVRksiw4dSvN+qCGQ2gcVUjMgOGDVPdVkzEJw21kkUhroIncsLZk5o5b6AtB8GYbibY7bMMz0yVSBqWzC7/FNkH5N/l2+cZv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612882104; 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=ru3bRhABI6OtYIVBvPFmFVMH/ELX2iFa6NhT2U1i/9Y=; b=FykXtDdgv9jfnc1rJ/M7D+PzROelFIUTMcM9bSFQQXFnZFlsTjg6bte9LpG8dYnmiGcLgLt+Q8dFEpzT6Ixgl+kZ08BJVrKGMjMToYREMnrgU/t7seJILzPYDz4+423kGANDVt70bHurFZ8YgiuEyU+UuWg72R+c9BSTLI+I/UE= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612882104158578.5047727746753; Tue, 9 Feb 2021 06:48:24 -0800 (PST) Received: from localhost ([::1]:51574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9UJT-0000NR-5P for importer@patchew.org; Tue, 09 Feb 2021 09:48:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9QTv-0006rF-Q1 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 05:42:55 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9QTs-0000L4-26 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 05:42:55 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DZfZW4B7rz7hmh; Tue, 9 Feb 2021 18:41:23 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Tue, 9 Feb 2021 18:42:39 +0800 From: Hao Wang To: , , Subject: [PATCH v2 1/2] migration/tls: fix inverted semantics in multifd_channel_connect Date: Tue, 9 Feb 2021 18:42:36 +0800 Message-ID: <20210209104237.2250941-2-wanghao232@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210209104237.2250941-1-wanghao232@huawei.com> References: <20210209104237.2250941-1-wanghao232@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected 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=45.249.212.35; envelope-from=wanghao232@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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-Mailman-Approved-At: Tue, 09 Feb 2021 09:41:09 -0500 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: yubihong@huawei.com, alex.chen@huawei.com, zhang.zhanghailiang@huawei.com, qemu-devel@nongnu.org, xiexiangyou@huawei.com, zhengchuan@huawei.com, wanghao232@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Function multifd_channel_connect() return "true" to indicate failure, which is rather confusing. Fix that. Signed-off-by: Hao Wang Reviewed-by: Chuan Zheng Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/multifd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 1a1e589064..2a1ea85ade 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -798,9 +798,9 @@ static bool multifd_channel_connect(MultiFDSendParams *= p, * function after the TLS handshake, * so we mustn't call multifd_send_thread until then */ - return false; - } else { return true; + } else { + return false; } } else { /* update for tls qio channel */ @@ -808,10 +808,10 @@ static bool multifd_channel_connect(MultiFDSendParams= *p, qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, QEMU_THREAD_JOINABLE); } - return false; + return true; } =20 - return true; + return false; } =20 static void multifd_new_send_channel_cleanup(MultiFDSendParams *p, @@ -844,7 +844,7 @@ static void multifd_new_send_channel_async(QIOTask *tas= k, gpointer opaque) p->c =3D QIO_CHANNEL(sioc); qio_channel_set_delay(p->c, false); p->running =3D true; - if (multifd_channel_connect(p, sioc, local_err)) { + if (!multifd_channel_connect(p, sioc, local_err)) { goto cleanup; } return; --=20 2.23.0 From nobody Fri May 17 12:14:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1612881971; cv=none; d=zohomail.com; s=zohoarc; b=dHaXdH+dw7KXsaV23KVf3At4Pf4+ZI+f5b9Yz5MPN3LhVThF/D/ON2Mb7wpwubxeEBsqomFb1g8zYn1zTQzUrve3qbS5D8IhlrdC6tB02EcEDVEHNTkKY/NRx0kjCTi+xJtJz8JhIvWv9cLc1wahF4ZD/yJfXMlnnDYwaFwiR04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612881971; 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=ptIVfabY0FoapiYrRvCDNIffW3mfHybJyMEJr2PoNH8=; b=JWpgnIewedgFnyqKW9dcxHLGIXN7K0b12ravbh6fT0w8HB7w/lC9KOoKmvQfDacIBEQNa2V2XqSP/pJzj89yKKMx+dbfOalH3Ha4AYupeAVYNBluBQ31+3Orl3Lcgs/QzaGZom+bys4hriAwDntaFBZSVFT1/cErWNO6c0HnAuE= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612881970822145.73970470060033; Tue, 9 Feb 2021 06:46:10 -0800 (PST) Received: from localhost ([::1]:47436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9UHJ-00072b-Ke for importer@patchew.org; Tue, 09 Feb 2021 09:46:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9QTv-0006qz-GT for qemu-devel@nongnu.org; Tue, 09 Feb 2021 05:42:55 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9QTs-0000L2-4G for qemu-devel@nongnu.org; Tue, 09 Feb 2021 05:42:55 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DZfZW3tXlz7hkK; Tue, 9 Feb 2021 18:41:23 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Tue, 9 Feb 2021 18:42:40 +0800 From: Hao Wang To: , , Subject: [PATCH v2 2/2] migration/tls: add error handling in multifd_tls_handshake_thread Date: Tue, 9 Feb 2021 18:42:37 +0800 Message-ID: <20210209104237.2250941-3-wanghao232@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210209104237.2250941-1-wanghao232@huawei.com> References: <20210209104237.2250941-1-wanghao232@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected 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=45.249.212.35; envelope-from=wanghao232@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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-Mailman-Approved-At: Tue, 09 Feb 2021 09:41:09 -0500 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: yubihong@huawei.com, alex.chen@huawei.com, zhang.zhanghailiang@huawei.com, qemu-devel@nongnu.org, xiexiangyou@huawei.com, zhengchuan@huawei.com, wanghao232@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If any error happens during multifd send thread creating (e.g. channel broke because new domain is destroyed by the dst), multifd_tls_handshake_thread may exit silently, leaving main migration thread hanging (ram_save_setup -> multifd_send_sync_main -> qemu_sem_wait(&p->sem_sync)). Fix that by adding error handling in multifd_tls_handshake_thread. Signed-off-by: Hao Wang Reviewed-by: Chuan Zheng Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/multifd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/migration/multifd.c b/migration/multifd.c index 2a1ea85ade..03527c564c 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -739,7 +739,16 @@ static void multifd_tls_outgoing_handshake(QIOTask *ta= sk, } else { trace_multifd_tls_outgoing_handshake_complete(ioc); } - multifd_channel_connect(p, ioc, err); + + if (!multifd_channel_connect(p, ioc, err)) { + /* + * Error happen, mark multifd_send_thread status as 'quit' althoug= h it + * is not created, and then tell who pay attention to me. + */ + p->quit =3D true; + qemu_sem_post(&multifd_send_state->channels_ready); + qemu_sem_post(&p->sem_sync); + } } =20 static void *multifd_tls_handshake_thread(void *opaque) --=20 2.23.0