qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Eric Blake <eblake@redhat.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] Add 'query-events' command to QMP to query async events
Date: Wed, 16 May 2012 11:18:22 -0500	[thread overview]
Message-ID: <4FB3D34E.2090802@codemonkey.ws> (raw)
In-Reply-To: <4FB3CFFD.5090605@redhat.com>

On 05/16/2012 11:04 AM, Eric Blake wrote:
> On 05/16/2012 06:55 AM, Daniel P. Berrange wrote:
>> From: "Daniel P. Berrange"<berrange@redhat.com>
>>
>> Sometimes it is neccessary for an application to determine
>> whether a particular QMP event is available, so they can
>> decide whether to use compatibility code instead. This
>> introduces a new 'query-events' command to QMP todo just
>
> s/todo/to do/
>
>> that
>>
>>   { "execute": "query-events" }
>>   {"return": [{"name": "WAKEUP"},
>>               {"name": "SUSPEND"},
>>               {"name": "DEVICE_TRAY_MOVED"},
>>               {"name": "BLOCK_JOB_CANCELLED"},
>>               {"name": "BLOCK_JOB_COMPLETED"},
>>               ...snip...
>>               {"name": "SHUTDOWN"}]}
>>
>> * monitor.c: Split out MonitorEvent ->  string conversion
>>    into monitor_protocol_event_name() API. Add impl of
>>    qmp_query_events monitor command handler
>> * qapi-schema.json, qmp-commands.hx: Define contract of
>>    query-events command
>
> Definitely useful for libvirt.
>
>
>> +static const char *monitor_protocol_event_name(MonitorEvent event)
>> +{
>>       switch (event) {
>>           case QEVENT_SHUTDOWN:
>> -            event_name = "SHUTDOWN";
>> +            return "SHUTDOWN";
>>               break;
>
> These 'break' statements are now unreachable; does this matter in qemu
> coding style?

Seems like we should just take the opportunity to kill off the function entirely 
and replace it with a table:

static const char *monitor_event_names[] = {
  [QEVENT_SHUTDOWN] = "SHUTDOWN",
  ...
};

Regards,

Anthony Liguori

  reply	other threads:[~2012-05-16 16:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 12:55 [Qemu-devel] [PATCH] Add 'query-events' command to QMP to query async events Daniel P. Berrange
2012-05-16 16:04 ` Eric Blake
2012-05-16 16:18   ` Anthony Liguori [this message]
2012-05-16 16:20     ` Daniel P. Berrange
2012-05-16 16:45     ` Luiz Capitulino

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=4FB3D34E.2090802@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).