From: Eric Blake <eblake@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Markus Armbruster <armbru@redhat.com>,
Wenchao Xia <wenchaoqemu@gmail.com>,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qapi-types: add C99 index names to arrays
Date: Thu, 19 Feb 2015 08:55:56 -0700 [thread overview]
Message-ID: <54E6078C.3060701@redhat.com> (raw)
In-Reply-To: <1424340754-24444-1-git-send-email-mst@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]
On 02/19/2015 03:13 AM, Michael S. Tsirkin wrote:
> It's not easy to figure out how monitor translates
> strings: most QEMU code deals with translated indexes,
> these are translated using _lookup arrays,
> so you need to find the array name, and find the
> appropriate offset.
>
> This patch adds C99 indexes to lookup arrays, which makes it possible to
> find the correct key using simple grep, and see that the matching is
> correct at a glance.
>
> Example:
>
> Before:
>
> const char *MigrationCapability_lookup[] = {
> "xbzrle",
> "rdma-pin-all",
> "auto-converge",
> "zero-blocks",
> NULL,
> };
>
> After:
>
> const char *MigrationCapability_lookup[] = {
> [MIGRATION_CAPABILITY_XBZRLE] = "xbzrle",
> [MIGRATION_CAPABILITY_RDMA_PIN_ALL] = "rdma-pin-all",
> [MIGRATION_CAPABILITY_AUTO_CONVERGE] = "auto-converge",
> [MIGRATION_CAPABILITY_ZERO_BLOCKS] = "zero-blocks",
> [MIGRATION_CAPABILITY_MAX] = NULL,
> };
I like it :)
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> scripts/qapi-types.py | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
prev parent reply other threads:[~2015-02-19 15:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-19 10:13 [Qemu-devel] [PATCH] qapi-types: add C99 index names to arrays Michael S. Tsirkin
2015-02-19 15:55 ` Eric Blake [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54E6078C.3060701@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=wenchaoqemu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).