All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org, mitake.hitoshi@gmail.com
Subject: Re: [Qemu-devel] [PATCH v2] blkdebug: make the fault injection functionality callable from QMP
Date: Wed, 27 Aug 2014 06:43:49 -0600	[thread overview]
Message-ID: <53FDD285.4090406@redhat.com> (raw)
In-Reply-To: <87r402binc.wl%mitake.hitoshi@lab.ntt.co.jp>

[-- Attachment #1: Type: text/plain, Size: 2612 bytes --]

On 08/26/2014 11:34 PM, Hitoshi Mitake wrote:

>>> {"execute": "blkdebug-set-rules", "arguments": {"device": "ide0-hd0",
>>> "rules":[{"event": "write_aio", "type": "inject-error", "immediately":
>>
>> Why 'write_aoi'? New QMP commands should prefer dashes (write-aio) if
>> there is no compelling reason for underscore.
> 
> The name of event is defined in the event_names array of
> block/blkdebug.c, which uses underscore. I think using the original
> names would be good because the name shouldn't be different from
> config file notation of blkdebug.

But it should be fairly easy to code things to accept both spellings
when parsing the config file, while preferring the dash in QAPI.
Furthermore, by defining the enum in QAPI instead of in blkdebug.c, you
get a generated enum that blkdebug.c can reuse, and where you are then
guaranteed that things stay in sync if new commands are added (by adding
them to the .json file).


>>
>>> +    } else if (!strcmp(type, "inject-error")) {
>>> +        int _errno, sector;
>>
>> The name _errno threw me; is there something better without a leading
>> underscore that would work better?
> 
> I added underscore to the name because errno is already used by
> errno.h. How about "given_errno"?

If you use proper .json typing, the generator will automatically rename
the QMP interface "errno" to the C code "q_errno".  Consistently using
the type-safe munging already done by the generator, instead of redoing
a completely different munging on your own, is the preferred solution here.


>>> +
>>> +        once = qdict_get_try_bool(dict, "once", 0);
>>
>> s/0/bool/ - we use <stdbool.h>, so you should use the named constants
>> when dealing with bool parameters.
> 
> Thanks, I'll fix it in v3.

Actually, if you use a type-safe qapi definition, you may not even need
to do raw qdict operations, but can just directly use the C struct that
gets generated as a result of the qapi.


> 
> I also like the detailed specification. But, there are bunch of event
> names (the event_names array of block/blkdebug.c). In addition, the
> rule of blkdebug can be extended. So I think defining it in two palces
> (qapi-schema.json and block/blkdebug.c) is hard to maintain. Parsing
> qdict in blkdebug.c would be simpler. How do you think?

No, don't do duplication.  Instead, fix blkdebug.c to USE the enum
generated by the .json, and you only have to maintain the list in one
place - the .json file.

-- 
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: 539 bytes --]

  reply	other threads:[~2014-08-27 12:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27  1:59 [Qemu-devel] [PATCH v2] blkdebug: make the fault injection functionality callable from QMP Hitoshi Mitake
2014-08-27  2:54 ` Eric Blake
2014-08-27  5:34   ` Hitoshi Mitake
2014-08-27 12:43     ` Eric Blake [this message]
2014-08-28  6:18       ` Hitoshi Mitake
2014-09-02 15:29         ` Stefan Hajnoczi
2014-09-11  2:50           ` Hitoshi Mitake

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=53FDD285.4090406@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mitake.hitoshi@gmail.com \
    --cc=mitake.hitoshi@lab.ntt.co.jp \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.