From nobody Fri May 3 04:42:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523445523764260.1248728846904; Wed, 11 Apr 2018 04:18:43 -0700 (PDT) Received: from localhost ([::1]:46578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6Dly-00041J-WD for importer@patchew.org; Wed, 11 Apr 2018 07:18:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6Djv-0002nR-KE for qemu-devel@nongnu.org; Wed, 11 Apr 2018 07:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6Djs-0005zq-Gr for qemu-devel@nongnu.org; Wed, 11 Apr 2018 07:16:35 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2613 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f6Djs-0005qQ-6C for qemu-devel@nongnu.org; Wed, 11 Apr 2018 07:16:32 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 4039C5C0E8927; Wed, 11 Apr 2018 19:16:15 +0800 (CST) Received: from localhost (10.177.131.80) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.361.1; Wed, 11 Apr 2018 19:16:08 +0800 From: linzhecheng To: Date: Wed, 11 Apr 2018 19:16:02 +0800 Message-ID: <20180411111602.20156-1-linzhecheng@huawei.com> X-Mailer: git-send-email 2.12.2.windows.2 MIME-Version: 1.0 X-Originating-IP: [10.177.131.80] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH] cpu: skip unpluged cpu when querying cpus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xuyandong2@huawei.com, pbonzini@redhat.com, wangxinxin.wang@huawei.com, rth@twiddle.net, crosthwaite.peter@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: XuYandong After vcpu1 thread exiting, vcpu0 thread (received notification) is still w= aiting for holding qemu_global_mutex in cpu_remove_sync, at this moment, vcpu1 is stil= l in global cpus list. If main thread grab qemu_global_mutex in order to handle qmp command "info = cpus", qmp_query_cpus visit unpluged vcpu1 will lead qemu process to exit. Signed-off-by: XuYandong --- cpus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cpus.c b/cpus.c index 2cb0af9..9b3a6c4 100644 --- a/cpus.c +++ b/cpus.c @@ -2018,6 +2018,11 @@ CpuInfoList *qmp_query_cpus(Error **errp) =20 CPU_FOREACH(cpu) { CpuInfoList *info; + + if (cpu->unplug) { + continue; + } + #if defined(TARGET_I386) X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; --=20 1.8.3.1