From patchwork Wed Aug 22 15:09:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 179331 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 6D7C62C0088 for ; Thu, 23 Aug 2012 01:15:23 +1000 (EST) Received: from localhost ([::1]:44236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4CeP-0000U2-7m for incoming@patchwork.ozlabs.org; Wed, 22 Aug 2012 11:15:21 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4CeA-0000Q4-PD for qemu-devel@nongnu.org; Wed, 22 Aug 2012 11:15:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4Cdx-0007ka-Hd for qemu-devel@nongnu.org; Wed, 22 Aug 2012 11:15:06 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:38473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4Cdx-0007kK-Di for qemu-devel@nongnu.org; Wed, 22 Aug 2012 11:14:53 -0400 Received: from /spool/local by e6.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 Aug 2012 11:14:50 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e6.ny.us.ibm.com (192.168.1.106) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 22 Aug 2012 11:14:29 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 53AC738C818A for ; Wed, 22 Aug 2012 11:12:18 -0400 (EDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7MFCGgJ191276 for ; Wed, 22 Aug 2012 11:12:17 -0400 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7MFAKuF016260 for ; Wed, 22 Aug 2012 09:10:20 -0600 Received: from titi.austin.rr.com (sig-9-65-103-225.mts.ibm.com [9.65.103.225]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q7MF9v5Z013075; Wed, 22 Aug 2012 09:09:58 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 22 Aug 2012 10:09:38 -0500 Message-Id: <1345648178-19823-1-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.5.4 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12082215-1976-0000-0000-0000107553D7 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.146 Cc: Anthony Liguori , Eric Blake , Luiz Capitulino Subject: [Qemu-devel] [PATCH] qapi: add 'query-target' command to return target arch/bit size (v2) 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 From: "Daniel P. Berrange" Add a 'query-target' QAPI command to allow management applications to determine what target architecture a QEMU binary is emulating without having to parse the binary name or -help output $ qmp-shell -p /tmp/qemu (QEMU) query-target { u'return': { u'arch': u'x86_64' }} Signed-off-by: Daniel P. Berrange Signed-off-by: Anthony Liguori Reviewed-by: Luiz Capitulino --- v1 -> v2 (aliguori) - remove 'bits' field - switch command to return an enum --- arch_init.c | 11 +++++++++++ configure | 7 ++++++- qapi-schema.json | 39 +++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 5 +++++ 4 files changed, 61 insertions(+), 1 deletions(-) diff --git a/arch_init.c b/arch_init.c index 9b46bfc..5a1173e 100644 --- a/arch_init.c +++ b/arch_init.c @@ -44,6 +44,7 @@ #include "exec-memory.h" #include "hw/pcspk.h" #include "qemu/page_cache.h" +#include "qmp-commands.h" #ifdef DEBUG_ARCH_INIT #define DPRINTF(fmt, ...) \ @@ -1080,3 +1081,13 @@ int xen_available(void) return 0; #endif } + + +TargetInfo *qmp_query_target(Error **errp) +{ + TargetInfo *info = g_malloc0(sizeof(*info)); + + info->arch = TARGET_TYPE; + + return info; +} diff --git a/configure b/configure index 60d266f..d97fd81 100755 --- a/configure +++ b/configure @@ -3834,14 +3834,19 @@ case "$target_arch2" in ;; esac +upper() { + echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]' +} + echo "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak echo "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak echo "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak echo "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak -target_arch_name="`echo $TARGET_ARCH | LC_ALL=C tr '[a-z]' '[A-Z]'`" +target_arch_name="`upper $TARGET_ARCH`" echo "TARGET_$target_arch_name=y" >> $config_target_mak echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak +echo "TARGET_TYPE=TARGET_TYPE_`upper $target_arch2`" >> $config_target_mak echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak if [ "$TARGET_ABI_DIR" = "" ]; then TARGET_ABI_DIR=$TARGET_ARCH diff --git a/qapi-schema.json b/qapi-schema.json index 3d2b2d1..72b3c4d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2454,3 +2454,42 @@ # ## { 'command': 'query-fdsets', 'returns': ['FdsetInfo'] } + +## +# @TargetType +# +# Target CPU emulation type +# +# These parameters correspond to the softmmu binary CPU name that is currently +# running. +# +# Since: 1.2.0 +## +{ 'enum': 'TargetType', + 'data': [ 'alpha', 'arm', 'cris', 'i386', 'lm32', 'm68k', 'microblazeel', + 'microblaze', 'mips64el', 'mips64', 'mipsel', 'mips', 'or32', + 'ppc64', 'ppcemb', 'ppc', 's390x', 'sh4eb', 'sh4', 'sparc64', + 'sparc', 'unicore32', 'x86_64', 'xtensaeb', 'xtensa' ] } + +## +# @TargetInfo: +# +# Information describing the QEMU target. +# +# @arch: the target architecture (eg "x86_64", "i386", etc) +# +# Since: 1.2.0 +## +{ 'type': 'TargetInfo', + 'data': { 'arch': 'TargetType' } } + +## +# @query-target: +# +# Return information about the target for this QEMU +# +# Returns: TargetInfo +# +# Since: 1.2.0 +## +{ 'command': 'query-target', 'returns': 'TargetInfo' } diff --git a/qmp-commands.hx b/qmp-commands.hx index 2ce4ce6..00d798f 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2509,3 +2509,8 @@ EQMP .mhandler.cmd_new = qmp_marshal_input_query_cpu_definitions, }, + { + .name = "query-target", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_target, + },