Skip to content

Commit

Permalink
qapi: Use anonymous bases in QMP flat unions
Browse files Browse the repository at this point in the history
Now that the generator supports it, we might as well use an
anonymous base rather than breaking out a single-use Base
structure, for all three of our current QMP flat unions.

Oddly enough, this change does not affect the resulting
introspection output (because we already inline the members of
a base type into an object, and had no independent use of the
base type reachable from a command).

The case_whitelist now has to list the name of an implicit
type; which is not too bad (consider it a feature if it makes
it harder for developers to make the whitelist grow :)

Signed-off-by: Eric Blake <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
  • Loading branch information
ebblake authored and Markus Armbruster committed Mar 18, 2016
1 parent ac4338f commit 3666a97
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 79 deletions.
20 changes: 6 additions & 14 deletions qapi-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,9 @@
'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 'other' ] }

##
# @CpuInfoBase:
# @CpuInfo:
#
# Common information about a virtual CPU
# Information about a virtual CPU
#
# @CPU: the index of the virtual CPU
#
Expand All @@ -776,18 +776,10 @@
# Notes: @halted is a transient state that changes frequently. By the time the
# data is sent to the client, the guest may no longer be halted.
##
{ 'struct': 'CpuInfoBase',
'data': {'CPU': 'int', 'current': 'bool', 'halted': 'bool',
'qom_path': 'str', 'thread_id': 'int', 'arch': 'CpuInfoArch' } }

##
# @CpuInfo:
#
# Information about a virtual CPU
#
# Since: 0.14.0
##
{ 'union': 'CpuInfo', 'base': 'CpuInfoBase', 'discriminator': 'arch',
{ 'union': 'CpuInfo',
'base': {'CPU': 'int', 'current': 'bool', 'halted': 'bool',
'qom_path': 'str', 'thread_id': 'int', 'arch': 'CpuInfoArch' },
'discriminator': 'arch',
'data': { 'x86': 'CpuInfoX86',
'sparc': 'CpuInfoSPARC',
'ppc': 'CpuInfoPPC',
Expand Down
98 changes: 45 additions & 53 deletions qapi/block-core.json
Original file line number Diff line number Diff line change
Expand Up @@ -1643,57 +1643,6 @@
'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx',
'vmdk', 'vpc', 'vvfat' ] }

##
# @BlockdevOptionsBase
#
# Options that are available for all block devices, independent of the block
# driver.
#
# @driver: block driver name
# @id: #optional id by which the new block device can be referred to.
# This option is only allowed on the top level of blockdev-add.
# A BlockBackend will be created by blockdev-add if and only if
# this option is given.
# @node-name: #optional the name of a block driver state node (Since 2.0).
# This option is required on the top level of blockdev-add if
# the @id option is not given there.
# @discard: #optional discard-related options (default: ignore)
# @cache: #optional cache-related options
# @aio: #optional AIO backend (default: threads)
# @rerror: #optional how to handle read errors on the device
# (default: report)
# @werror: #optional how to handle write errors on the device
# (default: enospc)
# @read-only: #optional whether the block device should be read-only
# (default: false)
# @stats-account-invalid: #optional whether to include invalid
# operations when computing last access statistics
# (default: true) (Since 2.5)
# @stats-account-failed: #optional whether to include failed
# operations when computing latency and last
# access statistics (default: true) (Since 2.5)
# @stats-intervals: #optional list of intervals for collecting I/O
# statistics, in seconds (default: none) (Since 2.5)
# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
# (default: off)
#
# Since: 1.7
##
{ 'struct': 'BlockdevOptionsBase',
'data': { 'driver': 'BlockdevDriver',
'*id': 'str',
'*node-name': 'str',
'*discard': 'BlockdevDiscardOptions',
'*cache': 'BlockdevCacheOptions',
'*aio': 'BlockdevAioOptions',
'*rerror': 'BlockdevOnError',
'*werror': 'BlockdevOnError',
'*read-only': 'bool',
'*stats-account-invalid': 'bool',
'*stats-account-failed': 'bool',
'*stats-intervals': ['int'],
'*detect-zeroes': 'BlockdevDetectZeroesOptions' } }

##
# @BlockdevOptionsFile
#
Expand Down Expand Up @@ -2070,12 +2019,55 @@
##
# @BlockdevOptions
#
# Options for creating a block device.
# Options for creating a block device. Many options are available for all
# block devices, independent of the block driver:
#
# @driver: block driver name
# @id: #optional id by which the new block device can be referred to.
# This option is only allowed on the top level of blockdev-add.
# A BlockBackend will be created by blockdev-add if and only if
# this option is given.
# @node-name: #optional the name of a block driver state node (Since 2.0).
# This option is required on the top level of blockdev-add if
# the @id option is not given there.
# @discard: #optional discard-related options (default: ignore)
# @cache: #optional cache-related options
# @aio: #optional AIO backend (default: threads)
# @rerror: #optional how to handle read errors on the device
# (default: report)
# @werror: #optional how to handle write errors on the device
# (default: enospc)
# @read-only: #optional whether the block device should be read-only
# (default: false)
# @stats-account-invalid: #optional whether to include invalid
# operations when computing last access statistics
# (default: true) (Since 2.5)
# @stats-account-failed: #optional whether to include failed
# operations when computing latency and last
# access statistics (default: true) (Since 2.5)
# @stats-intervals: #optional list of intervals for collecting I/O
# statistics, in seconds (default: none) (Since 2.5)
# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
# (default: off)
#
# Remaining options are determined by the block driver.
#
# Since: 1.7
##
{ 'union': 'BlockdevOptions',
'base': 'BlockdevOptionsBase',
'base': { 'driver': 'BlockdevDriver',
'*id': 'str',
'*node-name': 'str',
'*discard': 'BlockdevDiscardOptions',
'*cache': 'BlockdevCacheOptions',
'*aio': 'BlockdevAioOptions',
'*rerror': 'BlockdevOnError',
'*werror': 'BlockdevOnError',
'*read-only': 'bool',
'*stats-account-invalid': 'bool',
'*stats-account-failed': 'bool',
'*stats-intervals': ['int'],
'*detect-zeroes': 'BlockdevDetectZeroesOptions' },
'discriminator': 'driver',
'data': {
'archipelago':'BlockdevOptionsArchipelago',
Expand Down
12 changes: 1 addition & 11 deletions qapi/introspect.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,6 @@
'data': [ 'builtin', 'enum', 'array', 'object', 'alternate',
'command', 'event' ] }

##
# @SchemaInfoBase
#
# Members common to any @SchemaInfo.
#
# Since: 2.5
##
{ 'struct': 'SchemaInfoBase',
'data': { 'name': 'str', 'meta-type': 'SchemaMetaType' } }

##
# @SchemaInfo
#
Expand All @@ -103,7 +93,7 @@
# Since: 2.5
##
{ 'union': 'SchemaInfo',
'base': 'SchemaInfoBase',
'base': { 'name': 'str', 'meta-type': 'SchemaMetaType' },
'discriminator': 'meta-type',
'data': {
'builtin': 'SchemaInfoBuiltin',
Expand Down
2 changes: 1 addition & 1 deletion scripts/qapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
case_whitelist = [
# From QMP:
'ACPISlotType', # DIMM, visible through query-acpi-ospm-status
'CpuInfoBase', # CPU, visible through query-cpu
'CpuInfoMIPS', # PC, visible through query-cpu
'CpuInfoTricore', # PC, visible through query-cpu
'QapiErrorClass', # all members, visible through errors
'UuidInfo', # UUID, visible through query-uuid
'X86CPURegister32', # all members, visible indirectly through qom-get
'q_obj_CpuInfo-base', # CPU, visible through query-cpu
]

enum_types = []
Expand Down

0 comments on commit 3666a97

Please sign in to comment.