From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=45340 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OCvGE-0005jC-Id for qemu-devel@nongnu.org; Fri, 14 May 2010 09:49:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OCvGC-00064W-28 for qemu-devel@nongnu.org; Fri, 14 May 2010 09:49:06 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:47681) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OCvGB-00064G-TW for qemu-devel@nongnu.org; Fri, 14 May 2010 09:49:04 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by e8.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o4E9cXR7011376 for ; Fri, 14 May 2010 05:38:33 -0400 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o4EDn1iE092218 for ; Fri, 14 May 2010 09:49:01 -0400 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o4E6n05L007916 for ; Fri, 14 May 2010 00:49:00 -0600 Message-ID: <4BED54CA.2070908@linux.vnet.ibm.com> Date: Fri, 14 May 2010 08:48:58 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/1] Add -version-simple argument, printing only version number. References: <1273739572-30840-1-git-send-email-Jes.Sorensen@redhat.com> <1273739572-30840-2-git-send-email-Jes.Sorensen@redhat.com> <20100513133322.GI12207@redhat.com> <20100514100654.GC9282@redhat.com> In-Reply-To: <20100514100654.GC9282@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Anthony Liguori , Jes.Sorensen@redhat.com, Markus Armbruster , qemu-devel@nongnu.org, clalance@redhat.com, crobinso@redhat.com On 05/14/2010 05:06 AM, Daniel P. Berrange wrote: > On Fri, May 14, 2010 at 11:42:57AM +0200, Markus Armbruster wrote: > >> "Daniel P. Berrange" writes: >> >> >>> On Thu, May 13, 2010 at 10:32:52AM +0200, Jes.Sorensen@redhat.com wrote: >>> >>>> From: Jes Sorensen >>>> >>>> Add -version-simple argument for QEMU, printing just the version >>>> number, without any supporting text. >>>> >>>> This makes it simpler for other apps, such as libvirt, to parse the >>>> version string from QEMU independant of how the naming string may >>>> change. >>>> >>>> Signed-off-by: Jes Sorensen >>>> --- >>>> qemu-options.hx | 8 ++++++++ >>>> vl.c | 9 +++++++++ >>>> 2 files changed, 17 insertions(+), 0 deletions(-) >>>> >>>> diff --git a/qemu-options.hx b/qemu-options.hx >>>> index 12f6b51..e4f3979 100644 >>>> --- a/qemu-options.hx >>>> +++ b/qemu-options.hx >>>> @@ -27,6 +27,14 @@ STEXI >>>> Display version information and exit >>>> ETEXI >>>> >>>> +DEF("version-simple", 0, QEMU_OPTION_version_simple, >>>> + "-version-simple display version information and exit\n", QEMU_ARCH_ALL) >>>> +STEXI >>>> +@item -version-simple >>>> +@findex -version-simple >>>> +Display basic version number information and exit >>>> +ETEXI >>>> + >>>> DEF("M", HAS_ARG, QEMU_OPTION_M, >>>> "-M machine select emulated machine (-M ? for list)\n", QEMU_ARCH_ALL) >>>> STEXI >>>> diff --git a/vl.c b/vl.c >>>> index 85bcc84..5adca87 100644 >>>> --- a/vl.c >>>> +++ b/vl.c >>>> @@ -2015,6 +2015,11 @@ static void version(void) >>>> printf("QEMU emulator version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"); >>>> } >>>> >>>> +static void version_simple(void) >>>> +{ >>>> + printf(QEMU_VERSION QEMU_PKGVERSION "\n"); >>>> +} >>>> + >>>> static void help(int exitcode) >>>> { >>>> const char *options_help = >>>> @@ -2960,6 +2965,10 @@ int main(int argc, char **argv, char **envp) >>>> version(); >>>> exit(0); >>>> break; >>>> + case QEMU_OPTION_version_simple: >>>> + version_simple(); >>>> + exit(0); >>>> + break; >>>> case QEMU_OPTION_m: { >>>> uint64_t value; >>>> char *ptr; >>>> >>> This omits the KVM version string which is something we also want to see. >>> It would also be nice to avoid having to parse the -help output to determine >>> ARGV supported too. I wonder if it would be a good idea to just produce a >>> well structured equivalent to -help that provides the same data, but in >>> JSON format for sane parsing. That would let peple easily determine the >>> supported ARGV as well as version number(s) >>> >> I'm all for machine-readable self-documentation. And the place for that >> is QMP. Humble beginnings are already there: >> >> { "execute": "query-version", "arguments": { } } >> --> {"return": {"qemu": "0.12.50", "package": ""}} >> >> { "execute": "query-commands", "arguments": { } } >> --> {"return": [{"name": "quit"}, {"name": "eject"}, [...] >> >> Any practical problems with use of QMP instead of parsing command line >> option output? >> > It is unneccessarily complex for such a simple task, requiring you to > configure& connect to the monitor& do the capabilities negotiaton > and then issue the command. > > To just query the version requires this ridiculous interaction: > > $ qemu -chardev stdio,id=monitor -monitor chardev=monitor,mode=control > {"execute":"qmp_capabilities"} > {"QMP": {"version": {"qemu": "0.12.1", "package": " (qemu-kvm-0.12.1.2)"}, "capabilities": []}} > {"execute":"query-version"} > {"return": {"qemu": "0.12.50", "package": ""}} > > > I'm suggesting we just allow some simple syntactic sugar on the command > line for the handful of QMP commands that are just returning static info > about the binary, that are not affected by VM state. > > eg, make this work: > > $ qemu -query-version > {"qemu": "0.12.50", "package": ""} > No need for package. Vendors can use vendor extensions to add whatever info they want. But we should avoid an encoded string, it would be better as: {"major": 0, "minor": 12, "release": 50} And then it could be: {"major": 0, "minor": 12, "release": 50, "__org.linux-kvm.release": 1, "__com.redhat.RHEL6.release": 13} We could also just pretty print it: major: 0 minor: 12 release: 50 __org.linux-kvm.release: 1 __com.redhat.RHEL6.release: 13 Regards, Anthony Liguori > Daniel >