From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4At0-0005St-4Q for qemu-devel@nongnu.org; Wed, 22 Aug 2012 09:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4Asu-0008I1-VV for qemu-devel@nongnu.org; Wed, 22 Aug 2012 09:22:18 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:35263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4Asu-0008Hv-PK for qemu-devel@nongnu.org; Wed, 22 Aug 2012 09:22:12 -0400 Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 Aug 2012 07:22:11 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 9AEDE1FF003E for ; Wed, 22 Aug 2012 07:21:07 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7MDKWT0097006 for ; Wed, 22 Aug 2012 07:20:34 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7MDKV32005428 for ; Wed, 22 Aug 2012 07:20:31 -0600 From: Anthony Liguori In-Reply-To: <20120821130739.GL7982@redhat.com> References: <1345473098-26299-1-git-send-email-berrange@redhat.com> <20120820160239.72e68fdf@doriath.home> <20120821100750.GG7982@redhat.com> <20120821095355.6f7a59df@doriath.home> <20120821130739.GL7982@redhat.com> Date: Wed, 22 Aug 2012 08:20:26 -0500 Message-ID: <87zk5ngj1h.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH] qapi: add 'query-target' command to return target arch/bit size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , Luiz Capitulino Cc: qemu-devel@nongnu.org "Daniel P. Berrange" writes: > On Tue, Aug 21, 2012 at 09:53:55AM -0300, Luiz Capitulino wrote: >> On Tue, 21 Aug 2012 11:07:50 +0100 >> "Daniel P. Berrange" wrote: >> >> > On Mon, Aug 20, 2012 at 04:02:39PM -0300, Luiz Capitulino wrote: >> > > On Mon, 20 Aug 2012 15:31:38 +0100 >> > > "Daniel P. Berrange" wrote: >> > > >> > > > 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', u'bits': 64}} >> > > > >> > > > Signed-off-by: Daniel P. Berrange >> > > > --- >> > > > arch_init.c | 11 +++++++++++ >> > > > qapi-schema.json | 25 +++++++++++++++++++++++++ >> > > > qmp-commands.hx | 5 +++++ >> > > > 3 files changed, 41 insertions(+) >> > > > >> > > > diff --git a/arch_init.c b/arch_init.c >> > > > index 9b46bfc..095672d 100644 >> > > > --- a/arch_init.c >> > > > +++ b/arch_init.c >> > > > @@ -1080,3 +1080,14 @@ int xen_available(void) >> > > > return 0; >> > > > #endif >> > > > } >> > > > + >> > > > + >> > > > +TargetInfo *qmp_query_target(Error **errp) >> > > > +{ >> > > > + TargetInfo *info = g_malloc0(sizeof(*info)); >> > > > + >> > > > + info->arch = g_strdup(TARGET_ARCH); >> > > > + info->bits = TARGET_PHYS_ADDR_BITS; >> > > > + >> > > > + return info; >> > > > +} >> > > > diff --git a/qapi-schema.json b/qapi-schema.json >> > > > index 3d2b2d1..f0e3fe0 100644 >> > > > --- a/qapi-schema.json >> > > > +++ b/qapi-schema.json >> > > > @@ -2454,3 +2454,28 @@ >> > > > # >> > > > ## >> > > > { 'command': 'query-fdsets', 'returns': ['FdsetInfo'] } >> > > > + >> > > > +## >> > > > +# @TargetInfo: >> > > > +# >> > > > +# Information describing the QEMU target. >> > > > +# >> > > > +# @arch: the name of the target architecture (eg "x86_64", "i686", etc) >> > > >> > > Should be an enum, otherwise looks good. >> > >> > Really ? It feels a little bit odd to make this an enum IMHO. >> >> I don't think it's odd. We should avoid using free-form strings when >> the set of possible values a command returns is limited and known. >> >> The only small issue I see though, is that TARGET_ARCH is defined in >> configure, so you'll have to add something like CONFIG_TARGET_ENUM there too > > Well the (slightly inefficient) way is to just iterate over the enum > strings until you find the matching index. Not a good idea for large > enums, but I figure it'd be acceptable for the small number of arches. We can create a new CONFIG_ #define that gets set directly to the enumerator value. No need for string comparison. Regards, Anthony Liguori > > Daniel > -- > |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| > |: http://libvirt.org -o- http://virt-manager.org :| > |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| > |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|