qapi: add 'query-target' command to return target arch/bit size
PATCH 1/1 qapi: add 'query-target' command to return target arch/bit size
From: "Daniel P. Berrange" <[email protected]>
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}}--- arch_init.c | 11 +++++++++++ qapi-schema.json | 25 +++++++++++++++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 41 insertions(+)
arch_init.c +11 -0
@@ -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; +}
qapi-schema.json +25 -0
@@ -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) +# +# @bits: number of bits in physical address (eg 32 or 64) +# +# Since: 1.2.0 +## +{ 'type': 'TargetInfo', + 'data': { 'arch': 'str', 'bits': 'int' } } + +## +# @query-target: +# +# Return information about the target for this QEMU +# +# Returns: TargetInfo +# +# Since: 1.2.0 +## +{ 'command': 'query-target', 'returns': 'TargetInfo' }
qmp-commands.hx +5 -0
@@ -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, + },
Signature · 1 line
1.7.11.2
[Qemu-devel] For 1.2: Re: [PATCH] qapi: add 'query-target' command to return target arch/bit size
Quoted 10 lines · Daniel P. Berrange
From: "Daniel P. Berrange" <[email protected]>
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}}
Quoted 6 lines
Signed-off-by Daniel P. Berrange <[email protected]>--- arch_init.c | 11 +++++++++++ qapi-schema.json | 25 +++++++++++++++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 41 insertions(+)
Adding the for 1.2 marking in the subject, to make it clear that this is a "bug fix" for the fact that Anthony's QMP additions for libvirt were incomplete, and should be pulled in now rather than delayed to 1.3.
qapi-schema.json line 2463
Quoted 6 lines
qapi-schema.json +6
-0+## +# @TargetInfo: +# +# Information describing the QEMU target. +# +# @arch: the name of the target architecture (eg "x86_64", "i686", etc)
s/eg/e.g./ (it is an abbreviation of the two-word phrase exempli gratia)
Or even better, since mixing 'e.g.' and 'etc.' in the same sentence sounds stupid, just go with the much simpler:
@arch: the name of the target architecture (such as "x86_64" or "i686")
Quoted 1 line
+# @bits: number of bits in physical address (eg 32 or 64)
Ditto.
Signature · 2 lines
Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 41 lines · On Mon, 20 Aug 2012 15:31:38 +0100 "Daniel P. Berrange" <[email protected]>…
From: "Daniel P. Berrange" <[email protected]>
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 <[email protected]>--- arch_init.c | 11 +++++++++++ qapi-schema.json | 25 +++++++++++++++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 41 insertions(+)arch_init.c +11
-0@@ -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; +}qapi-schema.json +0
-0
qapi-schema.json line 2463
Quoted 10 lines
qapi-schema.json +7
-0@@ -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.
Quoted 31 lines
qapi-schema.json +18
-0+# +# @bits: number of bits in physical address (eg 32 or 64) +# +# Since: 1.2.0 +## +{ 'type': 'TargetInfo', + 'data': { 'arch': 'str', 'bits': 'int' } } + +## +# @query-target: +# +# Return information about the target for this QEMU +# +# Returns: TargetInfo +# +# Since: 1.2.0 +## +{ 'command': 'query-target', 'returns': 'TargetInfo' }qmp-commands.hx +5
-0@@ -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, + },
Quoted 9 lines · Daniel P. Berrange
From: "Daniel P. Berrange" <[email protected]>
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}}
"bits" is really ambiguous. What it means in QEMU (specifically the value you are returning) is probably not what you expect it to mean.
We're going to most likely fix TARGET_PHYS_ADDR_BITS to 64 real soon.
Why did you include this field? What information are you looking to get from QEMU and what decisions do you plan to make with it?
Regards,
Anthony Liguori
Quoted 75 lines
Signed-off-by Daniel P. Berrange <[email protected]>--- arch_init.c | 11 +++++++++++ qapi-schema.json | 25 +++++++++++++++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 41 insertions(+)arch_init.c +11
-0@@ -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; +}qapi-schema.json +25
-0@@ -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) +# +# @bits: number of bits in physical address (eg 32 or 64) +# +# Since: 1.2.0 +## +{ 'type': 'TargetInfo', + 'data': { 'arch': 'str', 'bits': 'int' } } + +## +# @query-target: +# +# Return information about the target for this QEMU +# +# Returns: TargetInfo +# +# Since: 1.2.0 +## +{ 'command': 'query-target', 'returns': 'TargetInfo' }qmp-commands.hx +5
-0@@ -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, + },Signature · 1 line
1.7.11.2
Quoted 8 lines · Anthony Liguori
Quoted 6 lines · Daniel P. Berrange
From: "Daniel P. Berrange" <[email protected]>
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
Quoted 6 lines
Quoted 3 lines
$ qmp-shell -p /tmp/qemu (QEMU) query-target { u'return': { u'arch': u'x86_64', u'bits': 64}}"bits" is really ambiguous. What it means in QEMU (specifically the value you are returning) is probably not what you expect it to mean.
My intent was to indicate the pointer word size for the architecture. eg 64 for x86_64, ppc64, etc, and 32 and i686, ppc, etc. Probably should have called it 'wordsize' or something like that
Quoted 1 line
We're going to most likely fix
TARGET_PHYS_ADDR_BITSto 64 real soon.
Hmm, when I looked at the header in my checkout it already *is* 64 or 32 as I'd expect for the architecture in question.
$ grep PHYS_ADDR_BITS */config-target.mak alpha-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 arm-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 cris-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=32 i386-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 lm32-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=32 m68k-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=32 microblazeel-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=32 microblaze-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=32 mips64el-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 mips64-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 mipsel-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 mips-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 ppc64-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 ppcemb-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 ppc-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 s390x-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 sh4eb-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=32 sh4-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=32 sparc64-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 sparc-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 x86_64-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 xtensaeb-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=32 xtensa-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=32
Quoted 2 lines
Why did you include this field? What information are you looking to get from QEMU and what decisions do you plan to make with it?
When libvirt reports the host capabilities it includes the architecture name and wordsize, amongst other things:
# virsh capabilities
....snip...
<guest>
<os_type>hvm</os_type>
<arch name='arm'>
<wordsize>32</wordsize>
<emulator>/bin/qemu-system-arm</emulator>
...Currently we just have a table of arch name -> wordsize mapping data in libvirt. I figured if I was adding a 'query-target' command to QEMU, we might as well include this info too. It is not critical though if you'd rather we omitted it though.
Regards,
Daniel
Signature · 4 lines
|: 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 :|
Quoted 48 lines · Luiz Capitulino
Quoted 45 lines · On Mon, 20 Aug 2012 15:31:38 +0100 "Daniel P. Berrange" <[email protected]>…
From: "Daniel P. Berrange" <[email protected]>
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 <[email protected]>--- arch_init.c | 11 +++++++++++ qapi-schema.json | 25 +++++++++++++++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 41 insertions(+)arch_init.c +11
-0@@ -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; +}qapi-schema.json +1
-0@@ -2454,3 +2454,28 @@ # ## { 'command': 'query-fdsets', 'returns': ['FdsetInfo'] } +
Quoted 8 lines
qapi-schema.json line 2463
Quoted 6 lines
qapi-schema.json +6
-0+## +# @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.
Daniel
Signature · 4 lines
|: 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 :|
Quoted 7 lines · Daniel P. Berrange
Quoted 2 lines · Anthony Liguori
"bits" is really ambiguous. What it means in QEMU (specifically the value you are returning) is probably not what you expect it to mean.
My intent was to indicate the pointer word size for the architecture. eg 64 for
x86_64, ppc64, etc, and 32 and i686, ppc, etc. Probably should have called it 'wordsize' or something like that
This is not the same as the physical address size...
Quoted 6 lines
Hmm, when I looked at the header in my checkout it already *is* 64 or 32 as I'd expect for the architecture in question.
$ grep PHYS_ADDR_BITS */config-target.mak alpha-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 arm-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64
...eg for ARM we have a 32 bit pointer size but 40 bit physical addresses (on some cores) and we set TARGET_PHYS_ADDR_BITS to 64 in all cases.
Quoted 1 line
i386-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64
i386 is the other obvious "pointers are 32 bit but we set TARGET_PHYS_ADDR_BITS wider", for about the same reasons.
-- PMM
Quoted 18 lines · Peter Maydell
Quoted 7 lines · Daniel P. Berrange
Quoted 2 lines · Anthony Liguori
"bits" is really ambiguous. What it means in QEMU (specifically the value you are returning) is probably not what you expect it to mean.
My intent was to indicate the pointer word size for the architecture. eg 64 for
x86_64, ppc64, etc, and 32 and i686, ppc, etc. Probably should have called it 'wordsize' or something like thatThis is not the same as the physical address size...
Quoted 6 lines
Hmm, when I looked at the header in my checkout it already *is* 64 or 32 as I'd expect for the architecture in question.
$ grep PHYS_ADDR_BITS */config-target.mak alpha-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64 arm-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64
Quoted 8 lines
...eg for ARM we have a 32 bit pointer size but 40 bit physical addresses (on some cores) and we set
TARGET_PHYS_ADDR_BITSto 64 in all cases.Quoted 1 line
i386-softmmu/config-target.mak:TARGET_PHYS_ADDR_BITS=64
i386 is the other obvious "pointers are 32 bit but we set
TARGET_PHYS_ADDR_BITSwider", for about the same reasons.
Ok, so I'll just respin this patch & remove the 'bits' field entirely so we avoid the confusion.
Daniel
Signature · 4 lines
|: 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 :|
Quoted 58 lines · On Tue, 21 Aug 2012 11:07:50 +0100 "Daniel P. Berrange" <[email protected]>…
Quoted 48 lines · Luiz Capitulino
Quoted 45 lines · On Mon, 20 Aug 2012 15:31:38 +0100 "Daniel P. Berrange" <[email protected]>…
From: "Daniel P. Berrange" <[email protected]>
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 <[email protected]>--- arch_init.c | 11 +++++++++++ qapi-schema.json | 25 +++++++++++++++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 41 insertions(+)arch_init.c +11
-0@@ -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; +}qapi-schema.json +1
-0@@ -2454,3 +2454,28 @@ # ## { 'command': 'query-fdsets', 'returns': ['FdsetInfo'] } +Quoted 8 lines
qapi-schema.json line 2463
Quoted 6 lines
qapi-schema.json +6
-0+## +# @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.
Quoted 1 line
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 (although we could probably kill TARGET_ARCH and use the strings generated by the qapi, but this might end resulting too much work for the hard-freeze).
Quoted 61 lines · Luiz Capitulino
Quoted 58 lines · On Tue, 21 Aug 2012 11:07:50 +0100 "Daniel P. Berrange" <[email protected]>…
Quoted 56 lines · Luiz Capitulino
Quoted 41 lines · On Mon, 20 Aug 2012 15:31:38 +0100 "Daniel P. Berrange" <[email protected]>…
From: "Daniel P. Berrange" <[email protected]>
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 <[email protected]>--- arch_init.c | 11 +++++++++++ qapi-schema.json | 25 +++++++++++++++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 41 insertions(+)arch_init.c +11
-0@@ -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; +}qapi-schema.json +0
-0qapi-schema.json line 2463
Quoted 10 lines
qapi-schema.json +7
-0@@ -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.
Quoted 7 lines
Quoted 1 line
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_ARCHis defined in configure, so you'll have to add something likeCONFIG_TARGET_ENUMthere 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.
Daniel
Signature · 4 lines
|: 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 :|
Quoted 13 lines · Daniel P. Berrange
Quoted 12 lines · Anthony Liguori
Quoted 9 lines · Daniel P. Berrange
From: "Daniel P. Berrange" <[email protected]>
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}}
Quoted 6 lines
Quoted 2 lines
"bits" is really ambiguous. What it means in QEMU (specifically the value you are returning) is probably not what you expect it to mean.
My intent was to indicate the pointer word size for the architecture. eg 64 for
x86_64, ppc64, etc, and 32 and i686, ppc, etc. Probably should have called it 'wordsize' or something like that
So this is physical address size which doesn't necessarily correspond to whether you can run a "64-bit" OS or not. As Peter mentioned, i386 can have a larger physical address size even though it's limited to 32-bit guests.
We really don't need to use a physical address size < 64-bit anymore. It's just a matter of time before someone comes in and fixes TARGET_PHYS_ADDR_BITS to 64 which ought to significantly reduce the build time since we don't need to duplicate objects anymore.
So yeah, removing 'bits' is probably a good idea.
Quoted 9 lines
# virsh capabilities
....snip...
<guest>
<os_type>hvm</os_type>
<arch name='arm'>
<wordsize>32</wordsize>
<emulator>/bin/qemu-system-arm</emulator>
...Quoted 4 lines
Currently we just have a table of arch name -> wordsize mapping data in libvirt. I figured if I was adding a 'query-target' command to QEMU, we might as well include this info too. It is not critical though if you'd rather we omitted it though.
Does anyone actually use wordsize that libvirt reports? What decisions are made with that information?
I'd much rather QEMU provide this kind of information to libvirt but understanding how it's used is important to figure out what to expose.
Regards,
Anthony Liguori
Quoted 8 lines
Regards,
DanielSignature · 4 lines
|: 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 :|
Quoted 67 lines · Daniel P. Berrange
Quoted 66 lines · Luiz Capitulino
Quoted 58 lines · On Tue, 21 Aug 2012 11:07:50 +0100 "Daniel P. Berrange" <[email protected]>…
Quoted 48 lines · Luiz Capitulino
Quoted 45 lines · On Mon, 20 Aug 2012 15:31:38 +0100 "Daniel P. Berrange" <[email protected]>…
From: "Daniel P. Berrange" <[email protected]>
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 <[email protected]>--- arch_init.c | 11 +++++++++++ qapi-schema.json | 25 +++++++++++++++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 41 insertions(+)arch_init.c +11
-0@@ -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; +}qapi-schema.json +1
-0@@ -2454,3 +2454,28 @@ # ## { 'command': 'query-fdsets', 'returns': ['FdsetInfo'] } +Quoted 8 lines
qapi-schema.json line 2463
Quoted 6 lines
qapi-schema.json +6
-0+## +# @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.
Quoted 1 line
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.
Quoted 6 lines
Quoted 2 lines
The only small issue I see though, is that
TARGET_ARCHis defined in configure, so you'll have to add something likeCONFIG_TARGET_ENUMthere tooWell 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
Quoted 7 lines
Daniel
Signature · 4 lines
|: 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 :|