qapi: Use 'struct' instead of 'type' in schema

Referring to "type" as both a meta-type (built-in, enum, union,
alternate, or struct) and a specific type (the name that the
schema uses for declaring structs) is confusing.  Do the bulk of
the conversion to "struct" in qapi schema, with a fairly
mechanical:

for f in `find -name '*.json'; do sed -i "s/'type'/'struct'/"; done

followed by manually filtering out the places where we have a
'type' embedded in 'data'.  Then tweak a couple of tests whose
output changes slightly due to longer lines.

I also verified that the generated files for QMP and QGA (such
as qmp-commands.h) are the same before and after, as assurance
that I didn't leave in any accidental member name changes.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Eric Blake
2015-05-05 18:39:01 +02:00
committed by Markus Armbruster
parent 3b2a8b8532
commit 895a2a80e0
39 changed files with 200 additions and 200 deletions
+83 -83
View File
File diff suppressed because it is too large Load Diff
+33 -33
View File
@@ -26,7 +26,7 @@
#
##
{ 'type': 'SnapshotInfo',
{ 'struct': 'SnapshotInfo',
'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'int',
'date-sec': 'int', 'date-nsec': 'int',
'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } }
@@ -45,7 +45,7 @@
#
# Since: 1.7
##
{ 'type': 'ImageInfoSpecificQCow2',
{ 'struct': 'ImageInfoSpecificQCow2',
'data': {
'compat': 'str',
'*lazy-refcounts': 'bool',
@@ -66,7 +66,7 @@
#
# Since: 1.7
##
{ 'type': 'ImageInfoSpecificVmdk',
{ 'struct': 'ImageInfoSpecificVmdk',
'data': {
'create-type': 'str',
'cid': 'int',
@@ -126,7 +126,7 @@
#
##
{ 'type': 'ImageInfo',
{ 'struct': 'ImageInfo',
'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
'*actual-size': 'int', 'virtual-size': 'int',
'*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
@@ -178,7 +178,7 @@
#
##
{ 'type': 'ImageCheck',
{ 'struct': 'ImageCheck',
'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
'*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
'*corruptions-fixed': 'int', '*leaks-fixed': 'int',
@@ -196,7 +196,7 @@
#
# Since: 2.3
##
{ 'type': 'BlockdevCacheInfo',
{ 'struct': 'BlockdevCacheInfo',
'data': { 'writeback': 'bool',
'direct': 'bool',
'no-flush': 'bool' } }
@@ -267,7 +267,7 @@
# Since: 0.14.0
#
##
{ 'type': 'BlockDeviceInfo',
{ 'struct': 'BlockDeviceInfo',
'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
'*backing_file': 'str', 'backing_file_depth': 'int',
'encrypted': 'bool', 'encryption_key_missing': 'bool',
@@ -321,7 +321,7 @@
#
# Since 1.7
##
{ 'type': 'BlockDeviceMapEntry',
{ 'struct': 'BlockDeviceMapEntry',
'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
'data': 'bool', '*offset': 'int' } }
@@ -340,7 +340,7 @@
#
# Since: 1.3
##
{ 'type': 'BlockDirtyInfo',
{ 'struct': 'BlockDirtyInfo',
'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
'frozen': 'bool'} }
@@ -375,7 +375,7 @@
#
# Since: 0.14.0
##
{ 'type': 'BlockInfo',
{ 'struct': 'BlockInfo',
'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
'locked': 'bool', '*inserted': 'BlockDeviceInfo',
'*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
@@ -428,7 +428,7 @@
#
# Since: 0.14.0
##
{ 'type': 'BlockDeviceStats',
{ 'struct': 'BlockDeviceStats',
'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
'wr_operations': 'int', 'flush_operations': 'int',
'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
@@ -454,7 +454,7 @@
#
# Since: 0.14.0
##
{ 'type': 'BlockStats',
{ 'struct': 'BlockStats',
'data': {'*device': 'str', '*node-name': 'str',
'stats': 'BlockDeviceStats',
'*parent': 'BlockStats',
@@ -567,7 +567,7 @@
#
# Since: 1.1
##
{ 'type': 'BlockJobInfo',
{ 'struct': 'BlockJobInfo',
'data': {'type': 'str', 'device': 'str', 'len': 'int',
'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
'io-status': 'BlockDeviceIoStatus', 'ready': 'bool'} }
@@ -677,7 +677,7 @@
# @mode: #optional whether and how QEMU should create a new image, default is
# 'absolute-paths'.
##
{ 'type': 'BlockdevSnapshot',
{ 'struct': 'BlockdevSnapshot',
'data': { '*device': 'str', '*node-name': 'str',
'snapshot-file': 'str', '*snapshot-node-name': 'str',
'*format': 'str', '*mode': 'NewImageMode' } }
@@ -721,7 +721,7 @@
#
# Since: 1.6
##
{ 'type': 'DriveBackup',
{ 'struct': 'DriveBackup',
'data': { 'device': 'str', 'target': 'str', '*format': 'str',
'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
'*speed': 'int', '*bitmap': 'str',
@@ -756,7 +756,7 @@
#
# Since: 2.3
##
{ 'type': 'BlockdevBackup',
{ 'struct': 'BlockdevBackup',
'data': { 'device': 'str', 'target': 'str',
'sync': 'MirrorSyncMode',
'*speed': 'int',
@@ -977,7 +977,7 @@
#
# Since 2.4
##
{ 'type': 'BlockDirtyBitmap',
{ 'struct': 'BlockDirtyBitmap',
'data': { 'node': 'str', 'name': 'str' } }
##
@@ -992,7 +992,7 @@
#
# Since 2.4
##
{ 'type': 'BlockDirtyBitmapAdd',
{ 'struct': 'BlockDirtyBitmapAdd',
'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32' } }
##
@@ -1313,7 +1313,7 @@
#
# Since: 1.7
##
{ 'type': 'BlockdevCacheOptions',
{ 'struct': 'BlockdevCacheOptions',
'data': { '*writeback': 'bool',
'*direct': 'bool',
'*no-flush': 'bool' } }
@@ -1360,7 +1360,7 @@
#
# Since: 1.7
##
{ 'type': 'BlockdevOptionsBase',
{ 'struct': 'BlockdevOptionsBase',
'data': { 'driver': 'BlockdevDriver',
'*id': 'str',
'*node-name': 'str',
@@ -1382,7 +1382,7 @@
#
# Since: 1.7
##
{ 'type': 'BlockdevOptionsFile',
{ 'struct': 'BlockdevOptionsFile',
'data': { 'filename': 'str' } }
##
@@ -1397,7 +1397,7 @@
#
# Since: 2.2
##
{ 'type': 'BlockdevOptionsNull',
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64' } }
##
@@ -1413,7 +1413,7 @@
#
# Since: 1.7
##
{ 'type': 'BlockdevOptionsVVFAT',
{ 'struct': 'BlockdevOptionsVVFAT',
'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
'*rw': 'bool' } }
@@ -1427,7 +1427,7 @@
#
# Since: 1.7
##
{ 'type': 'BlockdevOptionsGenericFormat',
{ 'struct': 'BlockdevOptionsGenericFormat',
'data': { 'file': 'BlockdevRef' } }
##
@@ -1443,7 +1443,7 @@
#
# Since: 1.7
##
{ 'type': 'BlockdevOptionsGenericCOWFormat',
{ 'struct': 'BlockdevOptionsGenericCOWFormat',
'base': 'BlockdevOptionsGenericFormat',
'data': { '*backing': 'BlockdevRef' } }
@@ -1479,7 +1479,7 @@
#
# Since: 2.2
##
{ 'type': 'Qcow2OverlapCheckFlags',
{ 'struct': 'Qcow2OverlapCheckFlags',
'data': { '*template': 'Qcow2OverlapCheckMode',
'*main-header': 'bool',
'*active-l1': 'bool',
@@ -1540,7 +1540,7 @@
#
# Since: 1.7
##
{ 'type': 'BlockdevOptionsQcow2',
{ 'struct': 'BlockdevOptionsQcow2',
'base': 'BlockdevOptionsGenericCOWFormat',
'data': { '*lazy-refcounts': 'bool',
'*pass-discard-request': 'bool',
@@ -1575,7 +1575,7 @@
# use the default value, 'archipelago'.
# Since: 2.2
##
{ 'type': 'BlockdevOptionsArchipelago',
{ 'struct': 'BlockdevOptionsArchipelago',
'data': { 'volume': 'str',
'*mport': 'int',
'*vport': 'int',
@@ -1627,7 +1627,7 @@
#
# Since: 2.0
##
{ 'type': 'BlkdebugInjectErrorOptions',
{ 'struct': 'BlkdebugInjectErrorOptions',
'data': { 'event': 'BlkdebugEvent',
'*state': 'int',
'*errno': 'int',
@@ -1650,7 +1650,7 @@
#
# Since: 2.0
##
{ 'type': 'BlkdebugSetStateOptions',
{ 'struct': 'BlkdebugSetStateOptions',
'data': { 'event': 'BlkdebugEvent',
'*state': 'int',
'new_state': 'int' } }
@@ -1672,7 +1672,7 @@
#
# Since: 2.0
##
{ 'type': 'BlockdevOptionsBlkdebug',
{ 'struct': 'BlockdevOptionsBlkdebug',
'data': { 'image': 'BlockdevRef',
'*config': 'str',
'*align': 'int',
@@ -1690,7 +1690,7 @@
#
# Since: 2.0
##
{ 'type': 'BlockdevOptionsBlkverify',
{ 'struct': 'BlockdevOptionsBlkverify',
'data': { 'test': 'BlockdevRef',
'raw': 'BlockdevRef' } }
@@ -1727,7 +1727,7 @@
#
# Since: 2.0
##
{ 'type': 'BlockdevOptionsQuorum',
{ 'struct': 'BlockdevOptionsQuorum',
'data': { '*blkverify': 'bool',
'children': [ 'BlockdevRef' ],
'vote-threshold': 'int',
+1 -1
View File
@@ -52,7 +52,7 @@
#
# Since: 1.7
##
{ 'type': 'BlockdevSnapshotInternal',
{ 'struct': 'BlockdevSnapshotInternal',
'data': { 'device': 'str', 'name': 'str' } }
##
+2 -2
View File
@@ -50,7 +50,7 @@
#
# Since: 0.14.0
##
{ 'type': 'VersionInfo',
{ 'struct': 'VersionInfo',
'data': {'qemu': {'major': 'int', 'minor': 'int', 'micro': 'int'},
'package': 'str'} }
@@ -74,7 +74,7 @@
#
# Since: 0.14.0
##
{ 'type': 'CommandInfo', 'data': {'name': 'str'} }
{ 'struct': 'CommandInfo', 'data': {'name': 'str'} }
##
# @query-commands:
+1 -1
View File
@@ -32,7 +32,7 @@
#
# Since 2.2
##
{ 'type': 'TraceEventInfo',
{ 'struct': 'TraceEventInfo',
'data': {'name': 'str', 'state': 'TraceEventState'} }
##
+14 -14
View File
@@ -150,7 +150,7 @@
#
# Since 1.1.0
##
{ 'type': 'GuestAgentCommandInfo',
{ 'struct': 'GuestAgentCommandInfo',
'data': { 'name': 'str', 'enabled': 'bool', 'success-response': 'bool' } }
##
@@ -164,7 +164,7 @@
#
# Since 0.15.0
##
{ 'type': 'GuestAgentInfo',
{ 'struct': 'GuestAgentInfo',
'data': { 'version': 'str',
'supported_commands': ['GuestAgentCommandInfo'] } }
##
@@ -242,7 +242,7 @@
#
# Since: 0.15.0
##
{ 'type': 'GuestFileRead',
{ 'struct': 'GuestFileRead',
'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } }
##
@@ -274,7 +274,7 @@
#
# Since: 0.15.0
##
{ 'type': 'GuestFileWrite',
{ 'struct': 'GuestFileWrite',
'data': { 'count': 'int', 'eof': 'bool' } }
##
@@ -309,7 +309,7 @@
#
# Since: 0.15.0
##
{ 'type': 'GuestFileSeek',
{ 'struct': 'GuestFileSeek',
'data': { 'position': 'int', 'eof': 'bool' } }
##
@@ -556,7 +556,7 @@
#
# Since: 1.1
##
{ 'type': 'GuestIpAddress',
{ 'struct': 'GuestIpAddress',
'data': {'ip-address': 'str',
'ip-address-type': 'GuestIpAddressType',
'prefix': 'int'} }
@@ -572,7 +572,7 @@
#
# Since: 1.1
##
{ 'type': 'GuestNetworkInterface',
{ 'struct': 'GuestNetworkInterface',
'data': {'name': 'str',
'*hardware-address': 'str',
'*ip-addresses': ['GuestIpAddress'] } }
@@ -604,7 +604,7 @@
#
# Since: 1.5
##
{ 'type': 'GuestLogicalProcessor',
{ 'struct': 'GuestLogicalProcessor',
'data': {'logical-id': 'int',
'online': 'bool',
'*can-offline': 'bool'} }
@@ -694,7 +694,7 @@
#
# Since: 2.2
##
{ 'type': 'GuestPCIAddress',
{ 'struct': 'GuestPCIAddress',
'data': {'domain': 'int', 'bus': 'int',
'slot': 'int', 'function': 'int'} }
@@ -709,7 +709,7 @@
#
# Since: 2.2
##
{ 'type': 'GuestDiskAddress',
{ 'struct': 'GuestDiskAddress',
'data': {'pci-controller': 'GuestPCIAddress',
'bus-type': 'GuestDiskBusType',
'bus': 'int', 'target': 'int', 'unit': 'int'} }
@@ -725,7 +725,7 @@
#
# Since: 2.2
##
{ 'type': 'GuestFilesystemInfo',
{ 'struct': 'GuestFilesystemInfo',
'data': {'name': 'str', 'mountpoint': 'str', 'type': 'str',
'disk': ['GuestDiskAddress']} }
@@ -782,7 +782,7 @@
#
# Since: 2.3
##
{ 'type': 'GuestMemoryBlock',
{ 'struct': 'GuestMemoryBlock',
'data': {'phys-index': 'uint64',
'online': 'bool',
'*can-offline': 'bool'} }
@@ -835,7 +835,7 @@
#
# Since: 2.3
##
{ 'type': 'GuestMemoryBlockResponse',
{ 'struct': 'GuestMemoryBlockResponse',
'data': { 'phys-index': 'uint64',
'response': 'GuestMemoryBlockResponseType',
'*error-code': 'int' }}
@@ -876,7 +876,7 @@
#
# Since: 2.3
##
{ 'type': 'GuestMemoryBlockInfo',
{ 'struct': 'GuestMemoryBlockInfo',
'data': {'size': 'uint64'} }
##
+1 -1
View File
@@ -1,6 +1,6 @@
# we do not allow array branches in alternates
# TODO: should we support this?
{ 'type': 'One',
{ 'struct': 'One',
'data': { 'name': 'str' } }
{ 'alternate': 'Alt',
'data': { 'one': 'One',
+1 -1
View File
@@ -1,5 +1,5 @@
# we reject alternate with base type
{ 'type': 'Base',
{ 'struct': 'Base',
'data': { 'string': 'str' } }
{ 'alternate': 'Alt',
'base': 'Base',
@@ -1,7 +1,7 @@
# we reject alternates with multiple object branches
{ 'type': 'One',
{ 'struct': 'One',
'data': { 'name': 'str' } }
{ 'type': 'Two',
{ 'struct': 'Two',
'data': { 'value': 'int' } }
{ 'alternate': 'Alt',
'data': { 'one': 'One',
+1 -1
View File
@@ -1,5 +1,5 @@
# Working example of alternate
{ 'type': 'Data',
{ 'struct': 'Data',
'data': { '*number': 'int', '*name': 'str' } }
{ 'enum': 'Enum',
'data': [ 'hello', 'world' ] }
+1 -1
View File
@@ -1,3 +1,3 @@
# we reject a base that is not a struct
{ 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } }
{ 'type': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }
{ 'struct': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }
+1 -1
View File
@@ -1,2 +1,2 @@
# we reject creating a type name with bad name
{ 'type': '*oops', 'data': { 'i': 'int' } }
{ 'struct': '*oops', 'data': { 'i': 'int' } }
+1 -1
View File
@@ -1,2 +1,2 @@
# we reject an expression with a metatype that is not a string
{ 'type': true, 'data': { } }
{ 'struct': true, 'data': { } }
+1 -1
View File
@@ -1 +1 @@
tests/qapi-schema/bad-type-int.json:3:11: Stray "1"
tests/qapi-schema/bad-type-int.json:3:13: Stray "1"
+1 -1
View File
@@ -1,3 +1,3 @@
# we reject an expression with a metatype that is not a string
# FIXME: once the parser understands integer inputs, improve the error message
{ 'type': 1, 'data': { } }
{ 'struct': 1, 'data': { } }
+1 -1
View File
@@ -1,4 +1,4 @@
# valid array members
{ 'enum': 'abc', 'data': [ 'a', 'b', 'c' ] }
{ 'type': 'def', 'data': { 'array': [ 'abc' ] } }
{ 'struct': 'def', 'data': { 'array': [ 'abc' ] } }
{ 'command': 'okay', 'data': { 'member1': [ 'int' ], 'member2': [ 'def' ] } }
+1 -1
View File
@@ -1 +1 @@
tests/qapi-schema/double-data.json:2:39: Duplicate key "data"
tests/qapi-schema/double-data.json:2:41: Duplicate key "data"
+1 -1
View File
@@ -1,2 +1,2 @@
# we reject an expression with duplicate top-level keys
{ 'type': 'bar', 'data': { }, 'data': { 'string': 'str'} }
{ 'struct': 'bar', 'data': { }, 'data': { 'string': 'str'} }
+1 -1
View File
@@ -1,2 +1,2 @@
# we reject an expression with ambiguous metatype
{ 'command': 'foo', 'type': 'bar', 'data': { } }
{ 'command': 'foo', 'struct': 'bar', 'data': { } }
+2 -2
View File
@@ -2,9 +2,9 @@
# TODO: should we allow an anonymous inline base type?
{ 'enum': 'TestEnum',
'data': [ 'value1', 'value2' ] }
{ 'type': 'TestTypeA',
{ 'struct': 'TestTypeA',
'data': { 'string': 'str' } }
{ 'type': 'TestTypeB',
{ 'struct': 'TestTypeB',
'data': { 'integer': 'int' } }
{ 'union': 'TestUnion',
'base': { 'enum1': 'TestEnum', 'kind': 'str' },

Some files were not shown because too many files have changed in this diff Show More