From patchwork Fri Feb 15 16:10:08 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: 220772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B931B2C0089 for ; Sat, 16 Feb 2013 03:10:38 +1100 (EST) Received: from localhost ([::1]:46781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6Nrw-0005Fo-Rt for incoming@patchwork.ozlabs.org; Fri, 15 Feb 2013 11:10:36 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6Nrl-0005Fh-V0 for qemu-devel@nongnu.org; Fri, 15 Feb 2013 11:10:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6Nre-0004Qe-NW for qemu-devel@nongnu.org; Fri, 15 Feb 2013 11:10:25 -0500 Received: from cantor2.suse.de ([195.135.220.15]:33381 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6Nre-0004Q5-Hn for qemu-devel@nongnu.org; Fri, 15 Feb 2013 11:10:18 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 30D60A398E; Fri, 15 Feb 2013 17:10:16 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Fri, 15 Feb 2013 17:10:08 +0100 Message-Id: <1360944608-25739-1-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 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: Markus Armbruster , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Luiz Capitulino Subject: [Qemu-devel] [PATCH qom-cpu-next] monitor: Use qemu_get_cpu() in monitor_set_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 No functional change, just a reduction of CPU loops. The mon_cpu field is left untouched for now since changing that requires a number of larger prerequisites, including cpu_synchronize_state() and mon_get_cpu(). Signed-off-by: Andreas Färber Reviewed-by: Luiz Capitulino Reviewed-by: Markus Armbruster --- monitor.c | 13 +++++-------- 1 Datei geändert, 5 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-) diff --git a/monitor.c b/monitor.c index 20bd19b..cae33c4 100644 --- a/monitor.c +++ b/monitor.c @@ -855,17 +855,14 @@ EventInfoList *qmp_query_events(Error **errp) /* set the current CPU defined by the user */ int monitor_set_cpu(int cpu_index) { - CPUArchState *env; CPUState *cpu; - for (env = first_cpu; env != NULL; env = env->next_cpu) { - cpu = ENV_GET_CPU(env); - if (cpu->cpu_index == cpu_index) { - cur_mon->mon_cpu = env; - return 0; - } + cpu = qemu_get_cpu(cpu_index); + if (cpu == NULL) { + return -1; } - return -1; + cur_mon->mon_cpu = cpu->env_ptr; + return 0; } static CPUArchState *mon_get_cpu(void)