From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbQYp-0001vm-KZ for qemu-devel@nongnu.org; Wed, 30 Oct 2013 03:51:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbQYg-0007ts-LJ for qemu-devel@nongnu.org; Wed, 30 Oct 2013 03:51:27 -0400 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:36266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbQYf-0007sm-IY for qemu-devel@nongnu.org; Wed, 30 Oct 2013 03:51:18 -0400 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Oct 2013 13:21:14 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 4EB80E0056 for ; Wed, 30 Oct 2013 13:22:50 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r9U7p6XI42205398 for ; Wed, 30 Oct 2013 13:21:07 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r9U7pA1g010957 for ; Wed, 30 Oct 2013 13:21:10 +0530 Message-ID: <5270BA6D.2050606@linux.vnet.ibm.com> Date: Wed, 30 Oct 2013 15:51:09 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1382321765-29052-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1382321765-29052-7-git-send-email-xiawenc@linux.vnet.ibm.com> <526595ED.5090506@redhat.com> <5265EEDC.3080900@linux.vnet.ibm.com> <5265F506.7010603@redhat.com> <52671A3D.6030908@linux.vnet.ibm.com> <52703E9B.8070308@redhat.com> In-Reply-To: <52703E9B.8070308@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 6/6] qapi: add doc for QEvent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, stefanha@redhat.com, pbonzini@redhat.com 于 2013/10/30 7:02, Eric Blake 写道: > On 10/22/2013 06:37 PM, Wenchao Xia wrote: >> Hi, here is my draft for qapi-schema.json, please have a look. >> Note: >> 1 it requires directly support of 'base', so I will sent additonal patch >> support it by key word '_base' in 'data' contents. >> 2 some define not labeled with "since 1.8', are code move. >> 3 reordered. > You may find it easier to break this into multiple patches (in > particular, code motion patches are almost always easier to review when > done separate from the patch that changes contents). > >> ## >> { 'enum': 'QEvent', >> 'data': [ >> # system related >> 'SHUTDOWN', >> 'POWERDOWN', >> 'RESET', >> 'STOP', >> 'RESUME', >> 'SUSPEND', >> 'SUSPEND_DISK', >> 'WAKEUP', >> >> # system virtual device related >> 'RTC_CHANGE', > I like how you grouped events. > >> ## >> # @EventTimestamp >> # >> # Reflect the time when event happens >> # >> # @seconds: the seconds have passed on host system >> # >> # @microsecnds: the microseconds have passed on host system > s/microsecnds/microseconds/ Will fix. >> # >> # Since: 1.8 >> ## >> { 'type': 'EventTimestamp', >> 'data': { 'seconds': 'int', 'microsecnds': 'int' } } > s/microsecnds/microseconds/ > >> ## >> # @EventBase >> # >> # Base type containing properties that are available for all kind of events >> # >> # @event: type of the event >> # >> # @timestamp: the time stamp of the event, which is got from host system > Grammar is awkward, and you are missing a reference point; maybe: > > @timestamp: time stamp when the event was issued by the host system, in > seconds since the Epoch Will doc as above. >> ## >> # @EventShutdown >> # >> # Emitted when the virtual machine shutdown, qemu terminates the >> emulation and > Line wrapping looks awkward here and elsewhere in your patch; be careful > that you fit in a reasonable column width. > > s/terminates/terminated/ OK. >> # exit. If the command-line option "-no-shutdown" has been specified, > s/exit/is about to exit/ OK. >> qemu will >> # not exit, and a STOP event will eventually follow the SHUTDOWN event >> # >> # Since: 1.8 >> ## >> { 'type': 'EventShutdown', >> 'data': { } } >> >> ## >> # @EventPowerdown >> # >> # Emitted when the virtual machine is powered down, qemu tries to set the >> # system power control system, such as ACPI related virtual chips > Hmm, this one is undocumented in qmp-events.txt. Maybe: > > Emitted when the virtual machine is powered down through the system > power control system, such as via ACPI. Will use above. > Do we have a better idea of how EventShutdown and EventPowerdown differ? > >> # >> # Since: 1.8 >> ## >> { 'type': 'EventPowerdown', >> 'data': { } } >> >> ## >> # @EventReset >> # >> # Emitted when the virtual machine is reseted > s/reseted/reset/ OK. >> ## >> # @EventSuspend >> # >> # Emitted when guest enters S3 state > Is S3 an x86-specific term, or does it apply to other architectures? I > know this is what qmp-events.txt says, but maybe it would be better as > "Emitted when guest enters a hardware suspension state (such as S3)". I am not sure if other arch have S3 term, will use as: "Emitted when guest enters a hardware suspension state (such as S3 on x86)" >> # >> # Since: 1.8 >> ## >> { 'type': 'EventSuspend', >> 'data': { } } >> >> ## >> # @EventSuspendDisk >> # >> # Emitted when the guest makes a request to enter S4 state. Note QEMU shuts >> # down (similar to @shutdown) when entering S4 state > Again, is S4 an x86-specific term? The reference to '@shutdown' looks > awkward; should it just call out 'EventShutdown' instead? yes, it should be 'EventShutdown' >> # >> # Since: 1.8 >> ## >> { 'type': 'EventSuspendDisk', >> 'data': { } } >> >> ## >> # @EventWakeup >> # >> # Emitted when the guest has woken up from S3 and is running > Again a question on S3 wording. will reword: 'Emitted when the guest has woken up from suspension state' >> ## >> # @ActionTypeOnWatchdogExpired > That's a mouthful. How about: > > WatchdogExpirationAction OK. >> # >> # An enumeration of the actions taken when the watchdog device's timer is >> # expired >> # >> # @reset: system resets >> # >> # @shutdown: system shutdown, note that it is similar to @powerdown, which >> # tries to set to system status and notify guest >> # >> # @poweroff: system poweroff, the emulator program exits >> # >> # @pause: system pauses, similar to @stop >> # >> # @pause: system enters debug state > s/pause/debug/ > >> ## >> # @EventTrayMoved >> # >> # It's emitted whenever the tray of a removable device is moved by the > s/It's emitted/Emitted/ Will fix. >> ## >> # @BlockdevOnError: > Again, separate code motion from new content. qapi-schema.json does not > have to be in topological order (ie. we already allow for recursive > types, so there's no need to worry whether all intermediate types are > declared prior to the outer type that uses them). Nice to hear no topological limit present, but put the define ahead my make it easier to review? will use seprate patch to do it. >> ## >> { 'type': 'BlockErrorInfo', >> 'data': { 'device': 'str', 'operation': 'IoOperationType', >> 'action': 'BlockdevOnError' } } >> >> ## >> # @EventBlockIoError >> # >> # Emitted when a disk I/O error occurs >> # >> # Since: 1.8 >> ## >> { 'type': 'EventBlockIoError', >> 'data': { >> 'data': { >> '_base': 'BlockErrorInfo' > Huh? I think you mean: > > { 'type': 'EventBlockIoError', > 'data': { > 'data': 'BlockErrorInfo' > } } Yes, I misse it. >> ## >> # @EventBlockImageCorrupted >> # >> # Emitted when a disk image is being marked corrupt >> # >> # @device: Device name >> # >> # @msg: Informative message, for example, reason for the corruption >> # >> # @offset: If the corruption resulted from an image access, this is the >> access >> # offset into the image >> # @size: If the corruption resulted from an image access, this is the >> access >> # size >> # >> # Since: 1.8 >> ## >> { 'type': 'EventBlockImageCorrupted', >> 'data': { >> 'data': { >> 'device': 'str', >> 'msg' : 'str', >> 'offset': 'int', >> 'size' : 'int' > Double-check if 'offset' and 'size' are always present, or if they > should be written '*offset' and '*size'. The original doc says always present, But I think it is resonable to change it as optional, do you agree? >> ## >> # @BlockJobInfoBase >> # >> # Basic info of a block job >> # >> # @type: Job type >> # >> # @device: Device name >> # >> # @len: Maximum progress value >> # >> # @offset: Current progress value. On success this is equal to len. >> # On failure this is less than len >> # >> # @speed: Rate limit, bytes per second >> # >> # Since: 1.8 >> ## >> { 'type': 'BlockJobInfoBase', >> 'data': { 'type': 'BlockJobType', 'device': 'str', 'len': 'int', >> 'offset': 'int', 'speed': 'int' } } > I would fold '*error':'str' into this type, rename BlockJobInfoBase to > BlockJobEventInfo (so it is not confused with the existing BlockJobInfo, > and because it is not a base type), then... >> ## >> # @EventBlockJobCompleted >> # >> # Emitted when a block job has completed >> # >> # @error: #optional, error message. Only present on failure. This field >> # contains a human-readable error message. There are no semantics >> # other than that streaming has failed and clients should not >> try to >> # interpret the error string >> # >> # Since: 1.8 >> ## >> { 'type': 'EventBlockJobCompleted', >> 'data': { >> 'data': { >> '_base' : 'BlockJobInfoBase', >> '*error': 'str' >> } } } > ...fix this to avoid a '_base' by just using: > > { 'type': 'EventBlockJobCompleted', > 'data': { > 'data': 'BlockJobEventInfo' > } } > ... OK. >> ## >> # @EventBlockJobCancelled >> # >> # Emitted when a block job has been cancelled >> # >> # @error: #optional, error message. Only present on failure. This field >> # contains a human-readable error message. There are no semantics >> # other than that streaming has failed and clients should not >> try to >> # interpret the error string >> # >> # Since: 1.8 >> ## >> { 'type': 'EventBlockJobCancelled', >> 'data': { >> 'data': { >> '_base': 'BlockJobInfoBase' >> } } } > ...and do the same here (maybe with a doc that the optional '*error' > will never be populated): > > { 'type': 'EventBlockJobCancelled', > 'data': { > 'data': 'BlockJobEventInfo' > } } OK. >> ## >> # @EventBlockJobError >> # >> # Emitted when a block job encounters an error >> # >> # Since: 1.8 >> ## >> { 'type': 'EventBlockJobError', >> 'data': { >> 'data': { >> '_base': 'BlockErrorInfo' >> } } } > Again, don't use '_base', but just properly inline the > 'data':'BlockErrorInfo'. OK. >> ## >> # @EventNicRxFilterChanged >> # >> # The event is emitted once until the query command is executed, the first > s/query/'query-rx-filter'/ will fix. >> # event will always be emitted >> # >> ## >> # @NetworkConnectionInfo >> # >> # The information for network connection >> # >> # @host: IP address >> # >> # @service: port number >> # >> # @family: address family, "ipv4" or "ipv6" > Seems like a candidate for an enum rather than an open-coded string. OK, will use enum. >> ## >> { 'type': 'EventVncConnected', >> 'data': { >> 'data': { >> 'server': { >> '_base': 'NetworkConnectionInfo', >> '*auth': 'str' }, > Doesn't work like that. I think you want: > > { 'type': 'NetworkConnectionInfoServer', > 'base': 'NetworkConnectionInfo', > 'data': { '*auth': 'str'} } > > followed by: > > { 'type': 'EventVncConnected', > 'data': { > 'data': { > 'server': 'NetworkConnectionInfoServer', > 'client': 'NetworkConnectionInfo' > } } } > >> ## >> # @EventVncInitialized >> # >> # Emitted after authentication takes place (if any) and the VNC session is >> # made active >> # >> # @server: Server information >> # >> # @auth: #optional, authentication method >> # >> # @client: Client information >> # >> # @x509_dname: #optional, TLS dname >> # >> # @sasl_username: #optional, SASL username >> # >> # Since: 1.8 >> ## >> { 'type': 'EventVncInitialized', >> 'data': { >> 'data': { >> 'server': { >> '_base': 'NetworkConnectionInfo', >> '*auth': 'str' }, >> 'client': { >> '_base' : 'NetworkConnectionInfo', >> '*x509_dname' : 'str', >> '*sasl_username': 'str' } > Again, _base doesn't work. You'll need to create a struct containing > the optional members (but can be a child class of > NetworkConnectionInfo), then use direct reference to that struct, as in > 'client':'NetworkConnectionInfoXYZ'. We will have a lot of struct defines, not sure if it is good: NetworkConnectionInfoVNCConnectedServer NetworkConnectionInfoVNCInitializedServer NetworkConnectionInfoVNCInitializedClient NetworkConnectionInfoSPICEConnectedServer ...... Instead of above, I modified qapi script a bit to recognize keyword "_base", which directly inherit data field, just as "base". >> ## >> # @EventSpiceInitialized >> # >> # Emitted after initial handshake and authentication takes place (if any) >> # and the SPICE channel is up'n'running > s/up'n'running/up and running/ OK. >> ## >> { 'type': 'EventSpiceInitialized', >> 'data': { >> 'data': { >> 'server': { >> '_base': 'NetworkConnectionInfo', >> '*auth': 'str' }, >> 'client': { >> '_base' : 'NetworkConnectionInfo', >> 'connection-id': 'int', >> 'channel-type' : 'int', >> 'channel-id' : 'int', >> 'tls' : 'bool' } > More uses of '_base' that instead need to be actual child structs > deriving from the common base. > >> ## >> # @EventGuestPanicked >> # >> # Emitted when guest OS panic is detected >> # >> # @action: Action that has been taken, currently always "pause" > Sounds like it should be an enum rather than a 'str' OK. >> ## >> # @Event >> # >> # Emitted when an event happens >> # >> # Since: 1.8 >> ## >> { 'Union': 'Event', > s/Union/union/ typo mistake. >> 'base': 'EventBase', >> 'discriminator': 'event', >> 'data': { >> 'SHUTDOWN' : 'EventShutdown', >> 'POWERDOWN' : 'EventPowerdown', > ... >> 'BALLOON_CHANGE' : 'EventBalloonChange', >> 'GUEST_PANICKED' : 'EventGuestPanicked' >> } } > Looks like you're headed in the right direction. >