From patchwork Wed Apr 11 11:16:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: linzhecheng X-Patchwork-Id: 897145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40LhMx6XRkz9s27 for ; Wed, 11 Apr 2018 21:17:33 +1000 (AEST) Received: from localhost ([::1]:46552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6Dkp-0002pX-4h for incoming@patchwork.ozlabs.org; Wed, 11 Apr 2018 07:17:31 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: XuYandong After vcpu1 thread exiting, vcpu0 thread (received notification) is still waiting for holding qemu_global_mutex in cpu_remove_sync, at this moment, vcpu1 is still 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) CPU_FOREACH(cpu) { CpuInfoList *info; + + if (cpu->unplug) { + continue; + } + #if defined(TARGET_I386) X86CPU *x86_cpu = X86_CPU(cpu); CPUX86State *env = &x86_cpu->env;