From patchwork Thu Jun 13 00:45:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 250957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AF86C2C0084 for ; Thu, 13 Jun 2013 11:32:33 +1000 (EST) Received: from localhost ([::1]:53062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmvjH-0005l1-Qx for incoming@patchwork.ozlabs.org; Wed, 12 Jun 2013 20:49:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Umvfa-0008Ch-7g for qemu-devel@nongnu.org; Wed, 12 Jun 2013 20:45:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UmvfY-0005V6-4S for qemu-devel@nongnu.org; Wed, 12 Jun 2013 20:45:42 -0400 Received: from cantor2.suse.de ([195.135.220.15]:32929 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmvfX-0005Us-V0 for qemu-devel@nongnu.org; Wed, 12 Jun 2013 20:45:40 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 700A2A5388; Thu, 13 Jun 2013 02:45:39 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2013 02:45:19 +0200 Message-Id: <1371084329-814-8-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1371084329-814-1-git-send-email-afaerber@suse.de> References: <1371084329-814-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Luiz Capitulino Subject: [Qemu-devel] [PULL 07/17] monitor: Simplify do_inject_mce() with qemu_get_cpu() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Avoids an open-coded CPU loop. Reviewed-by: liguang Reviewed-by: Luiz Capitulino Signed-off-by: Andreas Färber --- monitor.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/monitor.c b/monitor.c index 017411f..70ae8f5 100644 --- a/monitor.c +++ b/monitor.c @@ -2013,7 +2013,6 @@ static void do_acl_remove(Monitor *mon, const QDict *qdict) static void do_inject_mce(Monitor *mon, const QDict *qdict) { X86CPU *cpu; - CPUX86State *cenv; CPUState *cs; int cpu_index = qdict_get_int(qdict, "cpu_index"); int bank = qdict_get_int(qdict, "bank"); @@ -2026,14 +2025,11 @@ static void do_inject_mce(Monitor *mon, const QDict *qdict) if (qdict_get_try_bool(qdict, "broadcast", 0)) { flags |= MCE_INJECT_BROADCAST; } - for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) { - cpu = x86_env_get_cpu(cenv); - cs = CPU(cpu); - if (cs->cpu_index == cpu_index) { - cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc, - flags); - break; - } + cs = qemu_get_cpu(cpu_index); + if (cs != NULL) { + cpu = X86_CPU(cs); + cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc, + flags); } } #endif