From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUgvv-0006Ow-0f for qemu-devel@nongnu.org; Wed, 16 May 2012 12:18:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SUgvl-0007CM-3K for qemu-devel@nongnu.org; Wed, 16 May 2012 12:18:38 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:41588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUgvk-0007CC-T6 for qemu-devel@nongnu.org; Wed, 16 May 2012 12:18:29 -0400 Received: by dadv2 with SMTP id v2so1533573dad.4 for ; Wed, 16 May 2012 09:18:27 -0700 (PDT) Message-ID: <4FB3D34E.2090802@codemonkey.ws> Date: Wed, 16 May 2012 11:18:22 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1337172904-20508-1-git-send-email-berrange@redhat.com> <4FB3CFFD.5090605@redhat.com> In-Reply-To: <4FB3CFFD.5090605@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Add 'query-events' command to QMP to query async events List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Luiz Capitulino , qemu-devel@nongnu.org, Markus Armbruster 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" >> >> 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