From patchwork Mon Dec 6 18:23:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 74433 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2E6B7B70AF for ; Tue, 7 Dec 2010 05:33:04 +1100 (EST) Received: from localhost ([127.0.0.1]:56694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPfrx-00072s-GI for incoming@patchwork.ozlabs.org; Mon, 06 Dec 2010 13:33:01 -0500 Received: from [140.186.70.92] (port=35881 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPfjn-000368-3d for qemu-devel@nongnu.org; Mon, 06 Dec 2010 13:24:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPfjl-00049v-W4 for qemu-devel@nongnu.org; Mon, 06 Dec 2010 13:24:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPfjl-00049p-Oa for qemu-devel@nongnu.org; Mon, 06 Dec 2010 13:24:33 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB6IOXZ7005886 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Dec 2010 13:24:33 -0500 Received: from localhost ([10.3.113.17]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB6IOVl2002840; Mon, 6 Dec 2010 13:24:32 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Mon, 6 Dec 2010 16:23:56 -0200 Message-Id: <1291659852-23028-10-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1291659852-23028-1-git-send-email-lcapitulino@redhat.com> References: <1291659852-23028-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 09/25] Monitor: Move qmp_query_cpus() up in monitor.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org So that next commit can change monitor_print_cpus() to call it. Signed-off-by: Luiz Capitulino --- monitor.c | 78 ++++++++++++++++++++++++++++++------------------------------ 1 files changed, 39 insertions(+), 39 deletions(-) diff --git a/monitor.c b/monitor.c index 3091a1a..f067d07 100644 --- a/monitor.c +++ b/monitor.c @@ -854,6 +854,45 @@ static void do_info_registers(Monitor *mon) #endif } +static void qmp_query_cpus(Monitor *mon, QObject **ret_data) +{ + CPUState *env; + QList *cpu_list; + + cpu_list = qlist_new(); + + /* just to set the default cpu if not already done */ + mon_get_cpu(); + + for(env = first_cpu; env != NULL; env = env->next_cpu) { + QDict *cpu; + QObject *obj; + + cpu_synchronize_state(env); + + obj = qobject_from_jsonf("{ 'CPU': %d, 'current': %i, 'halted': %i }", + env->cpu_index, env == mon->mon_cpu, + env->halted); + + cpu = qobject_to_qdict(obj); + +#if defined(TARGET_I386) + qdict_put(cpu, "pc", qint_from_int(env->eip + env->segs[R_CS].base)); +#elif defined(TARGET_PPC) + qdict_put(cpu, "nip", qint_from_int(env->nip)); +#elif defined(TARGET_SPARC) + qdict_put(cpu, "pc", qint_from_int(env->pc)); + qdict_put(cpu, "npc", qint_from_int(env->npc)); +#elif defined(TARGET_MIPS) + qdict_put(cpu, "PC", qint_from_int(env->active_tc.PC)); +#endif + + qlist_append(cpu_list, cpu); + } + + *ret_data = QOBJECT(cpu_list); +} + static void print_cpu_iter(QObject *obj, void *opaque) { QDict *cpu; @@ -901,45 +940,6 @@ static void monitor_print_cpus(Monitor *mon, const QObject *data) qlist_iter(cpu_list, print_cpu_iter, mon); } -static void qmp_query_cpus(Monitor *mon, QObject **ret_data) -{ - CPUState *env; - QList *cpu_list; - - cpu_list = qlist_new(); - - /* just to set the default cpu if not already done */ - mon_get_cpu(); - - for(env = first_cpu; env != NULL; env = env->next_cpu) { - QDict *cpu; - QObject *obj; - - cpu_synchronize_state(env); - - obj = qobject_from_jsonf("{ 'CPU': %d, 'current': %i, 'halted': %i }", - env->cpu_index, env == mon->mon_cpu, - env->halted); - - cpu = qobject_to_qdict(obj); - -#if defined(TARGET_I386) - qdict_put(cpu, "pc", qint_from_int(env->eip + env->segs[R_CS].base)); -#elif defined(TARGET_PPC) - qdict_put(cpu, "nip", qint_from_int(env->nip)); -#elif defined(TARGET_SPARC) - qdict_put(cpu, "pc", qint_from_int(env->pc)); - qdict_put(cpu, "npc", qint_from_int(env->npc)); -#elif defined(TARGET_MIPS) - qdict_put(cpu, "PC", qint_from_int(env->active_tc.PC)); -#endif - - qlist_append(cpu_list, cpu); - } - - *ret_data = QOBJECT(cpu_list); -} - static int do_cpu_set(Monitor *mon, const QDict *qdict, QObject **ret_data) { int index = qdict_get_int(qdict, "index");