qapi: make 'if' condition strings simple identifiers

Change the 'if' condition strings to be C-agnostic. It will accept
'[A-Z][A-Z0-9_]*' identifiers. This allows to express configuration
conditions in other languages (Rust or Python for ex) or other more
suitable forms.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: John Snow <jsnow@redhat.com>
Message-Id: <20210804083105.97531-11-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased with semantic conflict in redefined-event.json]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Marc-André Lureau 2021-08-04 12:31:05 +04:00 committed by Markus Armbruster
parent 2b7d214536
commit 8a9f1e1d9c
25 changed files with 206 additions and 208 deletions

View File

@ -914,7 +914,7 @@
'data': { 'data': {
'file': 'BlockStatsSpecificFile', 'file': 'BlockStatsSpecificFile',
'host_device': { 'type': 'BlockStatsSpecificFile', 'host_device': { 'type': 'BlockStatsSpecificFile',
'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, 'if': 'HAVE_HOST_BLOCK_DEVICE' },
'nvme': 'BlockStatsSpecificNvme' } } 'nvme': 'BlockStatsSpecificNvme' } }
## ##
@ -2796,7 +2796,7 @@
## ##
{ 'enum': 'BlockdevAioOptions', { 'enum': 'BlockdevAioOptions',
'data': [ 'threads', 'native', 'data': [ 'threads', 'native',
{ 'name': 'io_uring', 'if': 'defined(CONFIG_LINUX_IO_URING)' } ] } { 'name': 'io_uring', 'if': 'CONFIG_LINUX_IO_URING' } ] }
## ##
# @BlockdevCacheOptions: # @BlockdevCacheOptions:
@ -2832,12 +2832,12 @@
'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps',
'gluster', 'gluster',
{'name': 'host_cdrom', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, {'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
{'name': 'host_device', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, {'name': 'host_device', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
'http', 'https', 'iscsi', 'http', 'https', 'iscsi',
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
{ 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, { 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] } 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
## ##
@ -2879,10 +2879,10 @@
'*locking': 'OnOffAuto', '*locking': 'OnOffAuto',
'*aio': 'BlockdevAioOptions', '*aio': 'BlockdevAioOptions',
'*drop-cache': {'type': 'bool', '*drop-cache': {'type': 'bool',
'if': 'defined(CONFIG_LINUX)'}, 'if': 'CONFIG_LINUX'},
'*x-check-cache-dropped': 'bool' }, '*x-check-cache-dropped': 'bool' },
'features': [ { 'name': 'dynamic-auto-read-only', 'features': [ { 'name': 'dynamic-auto-read-only',
'if': 'defined(CONFIG_POSIX)' } ] } 'if': 'CONFIG_POSIX' } ] }
## ##
# @BlockdevOptionsNull: # @BlockdevOptionsNull:
@ -3774,7 +3774,7 @@
# Since: 2.9 # Since: 2.9
## ##
{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ], { 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ],
'if': 'defined(CONFIG_REPLICATION)' } 'if': 'CONFIG_REPLICATION' }
## ##
# @BlockdevOptionsReplication: # @BlockdevOptionsReplication:
@ -3793,7 +3793,7 @@
'base': 'BlockdevOptionsGenericFormat', 'base': 'BlockdevOptionsGenericFormat',
'data': { 'mode': 'ReplicationMode', 'data': { 'mode': 'ReplicationMode',
'*top-id': 'str' }, '*top-id': 'str' },
'if': 'defined(CONFIG_REPLICATION)' } 'if': 'CONFIG_REPLICATION' }
## ##
# @NFSTransport: # @NFSTransport:
@ -4108,9 +4108,9 @@
'ftps': 'BlockdevOptionsCurlFtps', 'ftps': 'BlockdevOptionsCurlFtps',
'gluster': 'BlockdevOptionsGluster', 'gluster': 'BlockdevOptionsGluster',
'host_cdrom': { 'type': 'BlockdevOptionsFile', 'host_cdrom': { 'type': 'BlockdevOptionsFile',
'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, 'if': 'HAVE_HOST_BLOCK_DEVICE' },
'host_device': { 'type': 'BlockdevOptionsFile', 'host_device': { 'type': 'BlockdevOptionsFile',
'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, 'if': 'HAVE_HOST_BLOCK_DEVICE' },
'http': 'BlockdevOptionsCurlHttp', 'http': 'BlockdevOptionsCurlHttp',
'https': 'BlockdevOptionsCurlHttps', 'https': 'BlockdevOptionsCurlHttps',
'iscsi': 'BlockdevOptionsIscsi', 'iscsi': 'BlockdevOptionsIscsi',
@ -4129,7 +4129,7 @@
'raw': 'BlockdevOptionsRaw', 'raw': 'BlockdevOptionsRaw',
'rbd': 'BlockdevOptionsRbd', 'rbd': 'BlockdevOptionsRbd',
'replication': { 'type': 'BlockdevOptionsReplication', 'replication': { 'type': 'BlockdevOptionsReplication',
'if': 'defined(CONFIG_REPLICATION)' }, 'if': 'CONFIG_REPLICATION' },
'ssh': 'BlockdevOptionsSsh', 'ssh': 'BlockdevOptionsSsh',
'throttle': 'BlockdevOptionsThrottle', 'throttle': 'BlockdevOptionsThrottle',
'vdi': 'BlockdevOptionsGenericFormat', 'vdi': 'BlockdevOptionsGenericFormat',
@ -4307,8 +4307,8 @@
# @size: Size of the virtual disk in bytes # @size: Size of the virtual disk in bytes
# @preallocation: Preallocation mode for the new image (default: off; # @preallocation: Preallocation mode for the new image (default: off;
# allowed values: off, # allowed values: off,
# falloc (if defined CONFIG_POSIX_FALLOCATE), # falloc (if CONFIG_POSIX_FALLOCATE),
# full (if defined CONFIG_POSIX)) # full (if CONFIG_POSIX))
# @nocow: Turn off copy-on-write (valid only on btrfs; default: off) # @nocow: Turn off copy-on-write (valid only on btrfs; default: off)
# @extent-size-hint: Extent size hint to add to the image file; 0 for not # @extent-size-hint: Extent size hint to add to the image file; 0 for not
# adding an extent size hint (default: 1 MB, since 5.1) # adding an extent size hint (default: 1 MB, since 5.1)
@ -4331,8 +4331,8 @@
# @size: Size of the virtual disk in bytes # @size: Size of the virtual disk in bytes
# @preallocation: Preallocation mode for the new image (default: off; # @preallocation: Preallocation mode for the new image (default: off;
# allowed values: off, # allowed values: off,
# falloc (if defined CONFIG_GLUSTERFS_FALLOCATE), # falloc (if CONFIG_GLUSTERFS_FALLOCATE),
# full (if defined CONFIG_GLUSTERFS_ZEROFILL)) # full (if CONFIG_GLUSTERFS_ZEROFILL))
# #
# Since: 2.12 # Since: 2.12
## ##
@ -4432,7 +4432,7 @@
# Since: 5.1 # Since: 5.1
## ##
{ 'enum': 'Qcow2CompressionType', { 'enum': 'Qcow2CompressionType',
'data': [ 'zlib', { 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] } 'data': [ 'zlib', { 'name': 'zstd', 'if': 'CONFIG_ZSTD' } ] }
## ##
# @BlockdevCreateOptionsQcow2: # @BlockdevCreateOptionsQcow2:

View File

@ -168,7 +168,7 @@
'data': { 'mountpoint': 'str', 'data': { 'mountpoint': 'str',
'*growable': 'bool', '*growable': 'bool',
'*allow-other': 'FuseExportAllowOther' }, '*allow-other': 'FuseExportAllowOther' },
'if': 'defined(CONFIG_FUSE)' } 'if': 'CONFIG_FUSE' }
## ##
# @NbdServerAddOptions: # @NbdServerAddOptions:
@ -278,7 +278,7 @@
## ##
{ 'enum': 'BlockExportType', { 'enum': 'BlockExportType',
'data': [ 'nbd', 'vhost-user-blk', 'data': [ 'nbd', 'vhost-user-blk',
{ 'name': 'fuse', 'if': 'defined(CONFIG_FUSE)' } ] } { 'name': 'fuse', 'if': 'CONFIG_FUSE' } ] }
## ##
# @BlockExportOptions: # @BlockExportOptions:
@ -321,7 +321,7 @@
'nbd': 'BlockExportOptionsNbd', 'nbd': 'BlockExportOptionsNbd',
'vhost-user-blk': 'BlockExportOptionsVhostUserBlk', 'vhost-user-blk': 'BlockExportOptionsVhostUserBlk',
'fuse': { 'type': 'BlockExportOptionsFuse', 'fuse': { 'type': 'BlockExportOptionsFuse',
'if': 'defined(CONFIG_FUSE)' } 'if': 'CONFIG_FUSE' }
} } } }
## ##

View File

@ -342,7 +342,7 @@
{ 'struct': 'ChardevSpiceChannel', { 'struct': 'ChardevSpiceChannel',
'data': { 'type': 'str' }, 'data': { 'type': 'str' },
'base': 'ChardevCommon', 'base': 'ChardevCommon',
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @ChardevSpicePort: # @ChardevSpicePort:
@ -356,7 +356,7 @@
{ 'struct': 'ChardevSpicePort', { 'struct': 'ChardevSpicePort',
'data': { 'fqdn': 'str' }, 'data': { 'fqdn': 'str' },
'base': 'ChardevCommon', 'base': 'ChardevCommon',
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @ChardevVC: # @ChardevVC:
@ -405,7 +405,7 @@
'data': { '*mouse': 'bool', 'data': { '*mouse': 'bool',
'*clipboard': 'bool' }, '*clipboard': 'bool' },
'base': 'ChardevCommon', 'base': 'ChardevCommon',
'if': 'defined(CONFIG_SPICE_PROTOCOL)' } 'if': 'CONFIG_SPICE_PROTOCOL' }
## ##
# @ChardevBackend: # @ChardevBackend:
@ -431,11 +431,11 @@
'stdio': 'ChardevStdio', 'stdio': 'ChardevStdio',
'console': 'ChardevCommon', 'console': 'ChardevCommon',
'spicevmc': { 'type': 'ChardevSpiceChannel', 'spicevmc': { 'type': 'ChardevSpiceChannel',
'if': 'defined(CONFIG_SPICE)' }, 'if': 'CONFIG_SPICE' },
'spiceport': { 'type': 'ChardevSpicePort', 'spiceport': { 'type': 'ChardevSpicePort',
'if': 'defined(CONFIG_SPICE)' }, 'if': 'CONFIG_SPICE' },
'qemu-vdagent': { 'type': 'ChardevQemuVDAgent', 'qemu-vdagent': { 'type': 'ChardevQemuVDAgent',
'if': 'defined(CONFIG_SPICE_PROTOCOL)' }, 'if': 'CONFIG_SPICE_PROTOCOL' },
'vc': 'ChardevVC', 'vc': 'ChardevVC',
'ringbuf': 'ChardevRingbuf', 'ringbuf': 'ChardevRingbuf',
# next one is just for compatibility # next one is just for compatibility

View File

@ -89,7 +89,7 @@
## ##
{ 'struct': 'CpuModelBaselineInfo', { 'struct': 'CpuModelBaselineInfo',
'data': { 'model': 'CpuModelInfo' }, 'data': { 'model': 'CpuModelInfo' },
'if': 'defined(TARGET_S390X)' } 'if': 'TARGET_S390X' }
## ##
# @CpuModelCompareInfo: # @CpuModelCompareInfo:
@ -112,7 +112,7 @@
{ 'struct': 'CpuModelCompareInfo', { 'struct': 'CpuModelCompareInfo',
'data': { 'result': 'CpuModelCompareResult', 'data': { 'result': 'CpuModelCompareResult',
'responsible-properties': ['str'] }, 'responsible-properties': ['str'] },
'if': 'defined(TARGET_S390X)' } 'if': 'TARGET_S390X' }
## ##
# @query-cpu-model-comparison: # @query-cpu-model-comparison:
@ -156,7 +156,7 @@
{ 'command': 'query-cpu-model-comparison', { 'command': 'query-cpu-model-comparison',
'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' }, 'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' },
'returns': 'CpuModelCompareInfo', 'returns': 'CpuModelCompareInfo',
'if': 'defined(TARGET_S390X)' } 'if': 'TARGET_S390X' }
## ##
# @query-cpu-model-baseline: # @query-cpu-model-baseline:
@ -200,7 +200,7 @@
'data': { 'modela': 'CpuModelInfo', 'data': { 'modela': 'CpuModelInfo',
'modelb': 'CpuModelInfo' }, 'modelb': 'CpuModelInfo' },
'returns': 'CpuModelBaselineInfo', 'returns': 'CpuModelBaselineInfo',
'if': 'defined(TARGET_S390X)' } 'if': 'TARGET_S390X' }
## ##
# @CpuModelExpansionInfo: # @CpuModelExpansionInfo:
@ -213,9 +213,9 @@
## ##
{ 'struct': 'CpuModelExpansionInfo', { 'struct': 'CpuModelExpansionInfo',
'data': { 'model': 'CpuModelInfo' }, 'data': { 'model': 'CpuModelInfo' },
'if': { 'any': [ 'defined(TARGET_S390X)', 'if': { 'any': [ 'TARGET_S390X',
'defined(TARGET_I386)', 'TARGET_I386',
'defined(TARGET_ARM)'] } } 'TARGET_ARM' ] } }
## ##
# @query-cpu-model-expansion: # @query-cpu-model-expansion:
@ -254,9 +254,9 @@
'data': { 'type': 'CpuModelExpansionType', 'data': { 'type': 'CpuModelExpansionType',
'model': 'CpuModelInfo' }, 'model': 'CpuModelInfo' },
'returns': 'CpuModelExpansionInfo', 'returns': 'CpuModelExpansionInfo',
'if': { 'any': [ 'defined(TARGET_S390X)', 'if': { 'any': [ 'TARGET_S390X',
'defined(TARGET_I386)', 'TARGET_I386',
'defined(TARGET_ARM)' ] } } 'TARGET_ARM' ] } }
## ##
# @CpuDefinitionInfo: # @CpuDefinitionInfo:
@ -320,11 +320,11 @@
'typename': 'str', 'typename': 'str',
'*alias-of' : 'str', '*alias-of' : 'str',
'deprecated' : 'bool' }, 'deprecated' : 'bool' },
'if': { 'any': [ 'defined(TARGET_PPC)', 'if': { 'any': [ 'TARGET_PPC',
'defined(TARGET_ARM)', 'TARGET_ARM',
'defined(TARGET_I386)', 'TARGET_I386',
'defined(TARGET_S390X)', 'TARGET_S390X',
'defined(TARGET_MIPS)' ] } } 'TARGET_MIPS' ] } }
## ##
# @query-cpu-definitions: # @query-cpu-definitions:
@ -336,8 +336,8 @@
# Since: 1.2 # Since: 1.2
## ##
{ 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'], { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
'if': { 'any': [ 'defined(TARGET_PPC)', 'if': { 'any': [ 'TARGET_PPC',
'defined(TARGET_ARM)', 'TARGET_ARM',
'defined(TARGET_I386)', 'TARGET_I386',
'defined(TARGET_S390X)', 'TARGET_S390X',
'defined(TARGET_MIPS)' ] } } 'TARGET_MIPS' ] } }

View File

@ -533,7 +533,7 @@
## ##
{ 'enum': 'MultiFDCompression', { 'enum': 'MultiFDCompression',
'data': [ 'none', 'zlib', 'data': [ 'none', 'zlib',
{ 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] } { 'name': 'zstd', 'if': 'CONFIG_ZSTD' } ] }
## ##
# @BitmapMigrationBitmapAliasTransform: # @BitmapMigrationBitmapAliasTransform:
@ -1562,7 +1562,7 @@
## ##
{ 'command': 'xen-set-replication', { 'command': 'xen-set-replication',
'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' }, 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' },
'if': 'defined(CONFIG_REPLICATION)' } 'if': 'CONFIG_REPLICATION' }
## ##
# @ReplicationStatus: # @ReplicationStatus:
@ -1578,7 +1578,7 @@
## ##
{ 'struct': 'ReplicationStatus', { 'struct': 'ReplicationStatus',
'data': { 'error': 'bool', '*desc': 'str' }, 'data': { 'error': 'bool', '*desc': 'str' },
'if': 'defined(CONFIG_REPLICATION)' } 'if': 'CONFIG_REPLICATION' }
## ##
# @query-xen-replication-status: # @query-xen-replication-status:
@ -1596,7 +1596,7 @@
## ##
{ 'command': 'query-xen-replication-status', { 'command': 'query-xen-replication-status',
'returns': 'ReplicationStatus', 'returns': 'ReplicationStatus',
'if': 'defined(CONFIG_REPLICATION)' } 'if': 'CONFIG_REPLICATION' }
## ##
# @xen-colo-do-checkpoint: # @xen-colo-do-checkpoint:
@ -1613,7 +1613,7 @@
# Since: 2.9 # Since: 2.9
## ##
{ 'command': 'xen-colo-do-checkpoint', { 'command': 'xen-colo-do-checkpoint',
'if': 'defined(CONFIG_REPLICATION)' } 'if': 'CONFIG_REPLICATION' }
## ##
# @COLOStatus: # @COLOStatus:

View File

@ -23,17 +23,17 @@
## ##
{ 'event': 'RTC_CHANGE', { 'event': 'RTC_CHANGE',
'data': { 'offset': 'int' }, 'data': { 'offset': 'int' },
'if': { 'any': [ 'defined(TARGET_ALPHA)', 'if': { 'any': [ 'TARGET_ALPHA',
'defined(TARGET_ARM)', 'TARGET_ARM',
'defined(TARGET_HPPA)', 'TARGET_HPPA',
'defined(TARGET_I386)', 'TARGET_I386',
'defined(TARGET_MIPS)', 'TARGET_MIPS',
'defined(TARGET_MIPS64)', 'TARGET_MIPS64',
'defined(TARGET_PPC)', 'TARGET_PPC',
'defined(TARGET_PPC64)', 'TARGET_PPC64',
'defined(TARGET_S390X)', 'TARGET_S390X',
'defined(TARGET_SH4)', 'TARGET_SH4',
'defined(TARGET_SPARC)' ] } } 'TARGET_SPARC' ] } }
## ##
# @rtc-reset-reinjection: # @rtc-reset-reinjection:
@ -52,7 +52,7 @@
# #
## ##
{ 'command': 'rtc-reset-reinjection', { 'command': 'rtc-reset-reinjection',
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }
## ##
@ -79,7 +79,7 @@
{ 'enum': 'SevState', { 'enum': 'SevState',
'data': ['uninit', 'launch-update', 'launch-secret', 'running', 'data': ['uninit', 'launch-update', 'launch-secret', 'running',
'send-update', 'receive-update' ], 'send-update', 'receive-update' ],
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }
## ##
# @SevInfo: # @SevInfo:
@ -111,7 +111,7 @@
'state' : 'SevState', 'state' : 'SevState',
'handle' : 'uint32' 'handle' : 'uint32'
}, },
'if': 'defined(TARGET_I386)' 'if': 'TARGET_I386'
} }
## ##
@ -132,7 +132,7 @@
# #
## ##
{ 'command': 'query-sev', 'returns': 'SevInfo', { 'command': 'query-sev', 'returns': 'SevInfo',
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }
## ##
@ -146,7 +146,7 @@
# #
## ##
{ 'struct': 'SevLaunchMeasureInfo', 'data': {'data': 'str'}, { 'struct': 'SevLaunchMeasureInfo', 'data': {'data': 'str'},
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }
## ##
# @query-sev-launch-measure: # @query-sev-launch-measure:
@ -164,7 +164,7 @@
# #
## ##
{ 'command': 'query-sev-launch-measure', 'returns': 'SevLaunchMeasureInfo', { 'command': 'query-sev-launch-measure', 'returns': 'SevLaunchMeasureInfo',
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }
## ##
@ -189,7 +189,7 @@
'cert-chain': 'str', 'cert-chain': 'str',
'cbitpos': 'int', 'cbitpos': 'int',
'reduced-phys-bits': 'int'}, 'reduced-phys-bits': 'int'},
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }
## ##
# @query-sev-capabilities: # @query-sev-capabilities:
@ -209,7 +209,7 @@
# #
## ##
{ 'command': 'query-sev-capabilities', 'returns': 'SevCapability', { 'command': 'query-sev-capabilities', 'returns': 'SevCapability',
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }
## ##
# @sev-inject-launch-secret: # @sev-inject-launch-secret:
@ -227,7 +227,7 @@
## ##
{ 'command': 'sev-inject-launch-secret', { 'command': 'sev-inject-launch-secret',
'data': { 'packet-header': 'str', 'secret': 'str', '*gpa': 'uint64' }, 'data': { 'packet-header': 'str', 'secret': 'str', '*gpa': 'uint64' },
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }
## ##
# @dump-skeys: # @dump-skeys:
@ -249,7 +249,7 @@
## ##
{ 'command': 'dump-skeys', { 'command': 'dump-skeys',
'data': { 'filename': 'str' }, 'data': { 'filename': 'str' },
'if': 'defined(TARGET_S390X)' } 'if': 'TARGET_S390X' }
## ##
# @GICCapability: # @GICCapability:
@ -274,7 +274,7 @@
'data': { 'version': 'int', 'data': { 'version': 'int',
'emulated': 'bool', 'emulated': 'bool',
'kernel': 'bool' }, 'kernel': 'bool' },
'if': 'defined(TARGET_ARM)' } 'if': 'TARGET_ARM' }
## ##
# @query-gic-capabilities: # @query-gic-capabilities:
@ -294,7 +294,7 @@
# #
## ##
{ 'command': 'query-gic-capabilities', 'returns': ['GICCapability'], { 'command': 'query-gic-capabilities', 'returns': ['GICCapability'],
'if': 'defined(TARGET_ARM)' } 'if': 'TARGET_ARM' }
## ##
@ -310,7 +310,7 @@
## ##
{ 'struct': 'SevAttestationReport', { 'struct': 'SevAttestationReport',
'data': { 'data': 'str'}, 'data': { 'data': 'str'},
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }
## ##
# @query-sev-attestation-report: # @query-sev-attestation-report:
@ -332,4 +332,4 @@
## ##
{ 'command': 'query-sev-attestation-report', 'data': { 'mnonce': 'str' }, { 'command': 'query-sev-attestation-report', 'data': { 'mnonce': 'str' },
'returns': 'SevAttestationReport', 'returns': 'SevAttestationReport',
'if': 'defined(TARGET_I386)' } 'if': 'TARGET_I386' }

View File

@ -618,7 +618,7 @@
'data': { '*align': 'size', 'data': { '*align': 'size',
'*discard-data': 'bool', '*discard-data': 'bool',
'mem-path': 'str', 'mem-path': 'str',
'*pmem': { 'type': 'bool', 'if': 'defined(CONFIG_LIBPMEM)' }, '*pmem': { 'type': 'bool', 'if': 'CONFIG_LIBPMEM' },
'*readonly': 'bool' } } '*readonly': 'bool' } }
## ##
@ -782,7 +782,7 @@
'cryptodev-backend', 'cryptodev-backend',
'cryptodev-backend-builtin', 'cryptodev-backend-builtin',
{ 'name': 'cryptodev-vhost-user', { 'name': 'cryptodev-vhost-user',
'if': 'defined(CONFIG_VHOST_CRYPTO)' }, 'if': 'CONFIG_VHOST_CRYPTO' },
'dbus-vmstate', 'dbus-vmstate',
'filter-buffer', 'filter-buffer',
'filter-dump', 'filter-dump',
@ -795,7 +795,7 @@
'iothread', 'iothread',
'memory-backend-file', 'memory-backend-file',
{ 'name': 'memory-backend-memfd', { 'name': 'memory-backend-memfd',
'if': 'defined(CONFIG_LINUX)' }, 'if': 'CONFIG_LINUX' },
'memory-backend-ram', 'memory-backend-ram',
'pef-guest', 'pef-guest',
'pr-manager-helper', 'pr-manager-helper',
@ -840,7 +840,7 @@
'cryptodev-backend': 'CryptodevBackendProperties', 'cryptodev-backend': 'CryptodevBackendProperties',
'cryptodev-backend-builtin': 'CryptodevBackendProperties', 'cryptodev-backend-builtin': 'CryptodevBackendProperties',
'cryptodev-vhost-user': { 'type': 'CryptodevVhostUserProperties', 'cryptodev-vhost-user': { 'type': 'CryptodevVhostUserProperties',
'if': 'defined(CONFIG_VHOST_CRYPTO)' }, 'if': 'CONFIG_VHOST_CRYPTO' },
'dbus-vmstate': 'DBusVMStateProperties', 'dbus-vmstate': 'DBusVMStateProperties',
'filter-buffer': 'FilterBufferProperties', 'filter-buffer': 'FilterBufferProperties',
'filter-dump': 'FilterDumpProperties', 'filter-dump': 'FilterDumpProperties',
@ -853,7 +853,7 @@
'iothread': 'IothreadProperties', 'iothread': 'IothreadProperties',
'memory-backend-file': 'MemoryBackendFileProperties', 'memory-backend-file': 'MemoryBackendFileProperties',
'memory-backend-memfd': { 'type': 'MemoryBackendMemfdProperties', 'memory-backend-memfd': { 'type': 'MemoryBackendMemfdProperties',
'if': 'defined(CONFIG_LINUX)' }, 'if': 'CONFIG_LINUX' },
'memory-backend-ram': 'MemoryBackendProperties', 'memory-backend-ram': 'MemoryBackendProperties',
'pr-manager-helper': 'PrManagerHelperProperties', 'pr-manager-helper': 'PrManagerHelperProperties',
'qtest': 'QtestProperties', 'qtest': 'QtestProperties',

View File

@ -69,7 +69,7 @@
'*ipv4': 'bool', '*ipv4': 'bool',
'*ipv6': 'bool', '*ipv6': 'bool',
'*keep-alive': 'bool', '*keep-alive': 'bool',
'*mptcp': { 'type': 'bool', 'if': 'defined(IPPROTO_MPTCP)' } } } '*mptcp': { 'type': 'bool', 'if': 'IPPROTO_MPTCP' } } }
## ##
# @UnixSocketAddress: # @UnixSocketAddress:
@ -89,8 +89,8 @@
{ 'struct': 'UnixSocketAddress', { 'struct': 'UnixSocketAddress',
'data': { 'data': {
'path': 'str', 'path': 'str',
'*abstract': { 'type': 'bool', 'if': 'defined(CONFIG_LINUX)' }, '*abstract': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
'*tight': { 'type': 'bool', 'if': 'defined(CONFIG_LINUX)' } } } '*tight': { 'type': 'bool', 'if': 'CONFIG_LINUX' } } }
## ##
# @VsockSocketAddress: # @VsockSocketAddress:

View File

@ -18,7 +18,7 @@
# Since: 1.5 # Since: 1.5
## ##
{ 'enum': 'TpmModel', 'data': [ 'tpm-tis', 'tpm-crb', 'tpm-spapr' ], { 'enum': 'TpmModel', 'data': [ 'tpm-tis', 'tpm-crb', 'tpm-spapr' ],
'if': 'defined(CONFIG_TPM)' } 'if': 'CONFIG_TPM' }
## ##
# @query-tpm-models: # @query-tpm-models:
@ -36,7 +36,7 @@
# #
## ##
{ 'command': 'query-tpm-models', 'returns': ['TpmModel'], { 'command': 'query-tpm-models', 'returns': ['TpmModel'],
'if': 'defined(CONFIG_TPM)' } 'if': 'CONFIG_TPM' }
## ##
# @TpmType: # @TpmType:
@ -50,7 +50,7 @@
# Since: 1.5 # Since: 1.5
## ##
{ 'enum': 'TpmType', 'data': [ 'passthrough', 'emulator' ], { 'enum': 'TpmType', 'data': [ 'passthrough', 'emulator' ],
'if': 'defined(CONFIG_TPM)' } 'if': 'CONFIG_TPM' }
## ##
# @query-tpm-types: # @query-tpm-types:
@ -68,7 +68,7 @@
# #
## ##
{ 'command': 'query-tpm-types', 'returns': ['TpmType'], { 'command': 'query-tpm-types', 'returns': ['TpmType'],
'if': 'defined(CONFIG_TPM)' } 'if': 'CONFIG_TPM' }
## ##
# @TPMPassthroughOptions: # @TPMPassthroughOptions:
@ -85,7 +85,7 @@
{ 'struct': 'TPMPassthroughOptions', { 'struct': 'TPMPassthroughOptions',
'data': { '*path': 'str', 'data': { '*path': 'str',
'*cancel-path': 'str' }, '*cancel-path': 'str' },
'if': 'defined(CONFIG_TPM)' } 'if': 'CONFIG_TPM' }
## ##
# @TPMEmulatorOptions: # @TPMEmulatorOptions:
@ -97,7 +97,7 @@
# Since: 2.11 # Since: 2.11
## ##
{ 'struct': 'TPMEmulatorOptions', 'data': { 'chardev' : 'str' }, { 'struct': 'TPMEmulatorOptions', 'data': { 'chardev' : 'str' },
'if': 'defined(CONFIG_TPM)' } 'if': 'CONFIG_TPM' }
## ##
# @TpmTypeOptions: # @TpmTypeOptions:
@ -112,7 +112,7 @@
{ 'union': 'TpmTypeOptions', { 'union': 'TpmTypeOptions',
'data': { 'passthrough' : 'TPMPassthroughOptions', 'data': { 'passthrough' : 'TPMPassthroughOptions',
'emulator': 'TPMEmulatorOptions' }, 'emulator': 'TPMEmulatorOptions' },
'if': 'defined(CONFIG_TPM)' } 'if': 'CONFIG_TPM' }
## ##
# @TPMInfo: # @TPMInfo:
@ -131,7 +131,7 @@
'data': {'id': 'str', 'data': {'id': 'str',
'model': 'TpmModel', 'model': 'TpmModel',
'options': 'TpmTypeOptions' }, 'options': 'TpmTypeOptions' },
'if': 'defined(CONFIG_TPM)' } 'if': 'CONFIG_TPM' }
## ##
# @query-tpm: # @query-tpm:
@ -162,4 +162,4 @@
# #
## ##
{ 'command': 'query-tpm', 'returns': ['TPMInfo'], { 'command': 'query-tpm', 'returns': ['TPMInfo'],
'if': 'defined(CONFIG_TPM)' } 'if': 'CONFIG_TPM' }

View File

@ -123,7 +123,7 @@
'data': { 'host': 'str', 'data': { 'host': 'str',
'port': 'str', 'port': 'str',
'family': 'NetworkAddressFamily' }, 'family': 'NetworkAddressFamily' },
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @SpiceServerInfo: # @SpiceServerInfo:
@ -137,7 +137,7 @@
{ 'struct': 'SpiceServerInfo', { 'struct': 'SpiceServerInfo',
'base': 'SpiceBasicInfo', 'base': 'SpiceBasicInfo',
'data': { '*auth': 'str' }, 'data': { '*auth': 'str' },
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @SpiceChannel: # @SpiceChannel:
@ -163,7 +163,7 @@
'base': 'SpiceBasicInfo', 'base': 'SpiceBasicInfo',
'data': {'connection-id': 'int', 'channel-type': 'int', 'channel-id': 'int', 'data': {'connection-id': 'int', 'channel-type': 'int', 'channel-id': 'int',
'tls': 'bool'}, 'tls': 'bool'},
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @SpiceQueryMouseMode: # @SpiceQueryMouseMode:
@ -183,7 +183,7 @@
## ##
{ 'enum': 'SpiceQueryMouseMode', { 'enum': 'SpiceQueryMouseMode',
'data': [ 'client', 'server', 'unknown' ], 'data': [ 'client', 'server', 'unknown' ],
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @SpiceInfo: # @SpiceInfo:
@ -222,7 +222,7 @@
'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port': 'int', 'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port': 'int',
'*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str', '*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str',
'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']}, 'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']},
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @query-spice: # @query-spice:
@ -268,7 +268,7 @@
# #
## ##
{ 'command': 'query-spice', 'returns': 'SpiceInfo', { 'command': 'query-spice', 'returns': 'SpiceInfo',
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @SPICE_CONNECTED: # @SPICE_CONNECTED:
@ -294,7 +294,7 @@
{ 'event': 'SPICE_CONNECTED', { 'event': 'SPICE_CONNECTED',
'data': { 'server': 'SpiceBasicInfo', 'data': { 'server': 'SpiceBasicInfo',
'client': 'SpiceBasicInfo' }, 'client': 'SpiceBasicInfo' },
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @SPICE_INITIALIZED: # @SPICE_INITIALIZED:
@ -323,7 +323,7 @@
{ 'event': 'SPICE_INITIALIZED', { 'event': 'SPICE_INITIALIZED',
'data': { 'server': 'SpiceServerInfo', 'data': { 'server': 'SpiceServerInfo',
'client': 'SpiceChannel' }, 'client': 'SpiceChannel' },
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @SPICE_DISCONNECTED: # @SPICE_DISCONNECTED:
@ -349,7 +349,7 @@
{ 'event': 'SPICE_DISCONNECTED', { 'event': 'SPICE_DISCONNECTED',
'data': { 'server': 'SpiceBasicInfo', 'data': { 'server': 'SpiceBasicInfo',
'client': 'SpiceBasicInfo' }, 'client': 'SpiceBasicInfo' },
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# @SPICE_MIGRATE_COMPLETED: # @SPICE_MIGRATE_COMPLETED:
@ -365,7 +365,7 @@
# #
## ##
{ 'event': 'SPICE_MIGRATE_COMPLETED', { 'event': 'SPICE_MIGRATE_COMPLETED',
'if': 'defined(CONFIG_SPICE)' } 'if': 'CONFIG_SPICE' }
## ##
# == VNC # == VNC
@ -393,7 +393,7 @@
'service': 'str', 'service': 'str',
'family': 'NetworkAddressFamily', 'family': 'NetworkAddressFamily',
'websocket': 'bool' }, 'websocket': 'bool' },
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VncServerInfo: # @VncServerInfo:
@ -408,7 +408,7 @@
{ 'struct': 'VncServerInfo', { 'struct': 'VncServerInfo',
'base': 'VncBasicInfo', 'base': 'VncBasicInfo',
'data': { '*auth': 'str' }, 'data': { '*auth': 'str' },
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VncClientInfo: # @VncClientInfo:
@ -426,7 +426,7 @@
{ 'struct': 'VncClientInfo', { 'struct': 'VncClientInfo',
'base': 'VncBasicInfo', 'base': 'VncBasicInfo',
'data': { '*x509_dname': 'str', '*sasl_username': 'str' }, 'data': { '*x509_dname': 'str', '*sasl_username': 'str' },
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VncInfo: # @VncInfo:
@ -469,7 +469,7 @@
'data': {'enabled': 'bool', '*host': 'str', 'data': {'enabled': 'bool', '*host': 'str',
'*family': 'NetworkAddressFamily', '*family': 'NetworkAddressFamily',
'*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo']}, '*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo']},
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VncPrimaryAuth: # @VncPrimaryAuth:
@ -481,7 +481,7 @@
{ 'enum': 'VncPrimaryAuth', { 'enum': 'VncPrimaryAuth',
'data': [ 'none', 'vnc', 'ra2', 'ra2ne', 'tight', 'ultra', 'data': [ 'none', 'vnc', 'ra2', 'ra2ne', 'tight', 'ultra',
'tls', 'vencrypt', 'sasl' ], 'tls', 'vencrypt', 'sasl' ],
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VncVencryptSubAuth: # @VncVencryptSubAuth:
@ -496,7 +496,7 @@
'tls-vnc', 'x509-vnc', 'tls-vnc', 'x509-vnc',
'tls-plain', 'x509-plain', 'tls-plain', 'x509-plain',
'tls-sasl', 'x509-sasl' ], 'tls-sasl', 'x509-sasl' ],
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VncServerInfo2: # @VncServerInfo2:
@ -514,7 +514,7 @@
'base': 'VncBasicInfo', 'base': 'VncBasicInfo',
'data': { 'auth' : 'VncPrimaryAuth', 'data': { 'auth' : 'VncPrimaryAuth',
'*vencrypt' : 'VncVencryptSubAuth' }, '*vencrypt' : 'VncVencryptSubAuth' },
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VncInfo2: # @VncInfo2:
@ -547,7 +547,7 @@
'auth' : 'VncPrimaryAuth', 'auth' : 'VncPrimaryAuth',
'*vencrypt' : 'VncVencryptSubAuth', '*vencrypt' : 'VncVencryptSubAuth',
'*display' : 'str' }, '*display' : 'str' },
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @query-vnc: # @query-vnc:
@ -579,7 +579,7 @@
# #
## ##
{ 'command': 'query-vnc', 'returns': 'VncInfo', { 'command': 'query-vnc', 'returns': 'VncInfo',
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @query-vnc-servers: # @query-vnc-servers:
# #
@ -590,7 +590,7 @@
# Since: 2.3 # Since: 2.3
## ##
{ 'command': 'query-vnc-servers', 'returns': ['VncInfo2'], { 'command': 'query-vnc-servers', 'returns': ['VncInfo2'],
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @change-vnc-password: # @change-vnc-password:
@ -606,7 +606,7 @@
## ##
{ 'command': 'change-vnc-password', { 'command': 'change-vnc-password',
'data': { 'password': 'str' }, 'data': { 'password': 'str' },
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VNC_CONNECTED: # @VNC_CONNECTED:
@ -636,7 +636,7 @@
{ 'event': 'VNC_CONNECTED', { 'event': 'VNC_CONNECTED',
'data': { 'server': 'VncServerInfo', 'data': { 'server': 'VncServerInfo',
'client': 'VncBasicInfo' }, 'client': 'VncBasicInfo' },
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VNC_INITIALIZED: # @VNC_INITIALIZED:
@ -664,7 +664,7 @@
{ 'event': 'VNC_INITIALIZED', { 'event': 'VNC_INITIALIZED',
'data': { 'server': 'VncServerInfo', 'data': { 'server': 'VncServerInfo',
'client': 'VncClientInfo' }, 'client': 'VncClientInfo' },
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# @VNC_DISCONNECTED: # @VNC_DISCONNECTED:
@ -691,7 +691,7 @@
{ 'event': 'VNC_DISCONNECTED', { 'event': 'VNC_DISCONNECTED',
'data': { 'server': 'VncServerInfo', 'data': { 'server': 'VncServerInfo',
'client': 'VncClientInfo' }, 'client': 'VncClientInfo' },
'if': 'defined(CONFIG_VNC)' } 'if': 'CONFIG_VNC' }
## ##
# = Input # = Input
@ -1133,14 +1133,13 @@
'data' : [ 'data' : [
{ 'name': 'default' }, { 'name': 'default' },
{ 'name': 'none' }, { 'name': 'none' },
{ 'name': 'gtk', 'if': 'defined(CONFIG_GTK)' }, { 'name': 'gtk', 'if': 'CONFIG_GTK' },
{ 'name': 'sdl', 'if': 'defined(CONFIG_SDL)' }, { 'name': 'sdl', 'if': 'CONFIG_SDL' },
{ 'name': 'egl-headless', { 'name': 'egl-headless',
'if': { 'all': [ 'defined(CONFIG_OPENGL)', 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } },
'defined(CONFIG_GBM)' ] } }, { 'name': 'curses', 'if': 'CONFIG_CURSES' },
{ 'name': 'curses', 'if': 'defined(CONFIG_CURSES)' }, { 'name': 'cocoa', 'if': 'CONFIG_COCOA' },
{ 'name': 'cocoa', 'if': 'defined(CONFIG_COCOA)' }, { 'name': 'spice-app', 'if': 'CONFIG_SPICE'} ] }
{ 'name': 'spice-app', 'if': 'defined(CONFIG_SPICE)'} ] }
## ##
# @DisplayOptions: # @DisplayOptions:
@ -1165,11 +1164,10 @@
'*gl' : 'DisplayGLMode' }, '*gl' : 'DisplayGLMode' },
'discriminator' : 'type', 'discriminator' : 'type',
'data' : { 'data' : {
'gtk': { 'type': 'DisplayGTK', 'if': 'defined(CONFIG_GTK)' }, 'gtk': { 'type': 'DisplayGTK', 'if': 'CONFIG_GTK' },
'curses': { 'type': 'DisplayCurses', 'if': 'defined(CONFIG_CURSES)' }, 'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' },
'egl-headless': { 'type': 'DisplayEGLHeadless', 'egl-headless': { 'type': 'DisplayEGLHeadless',
'if': { 'all': [ 'defined(CONFIG_OPENGL)', 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } }
'defined(CONFIG_GBM)' ] } }
} }
} }

View File

@ -1380,7 +1380,7 @@
'data': { 'data': {
'keys': ['str'] 'keys': ['str']
}, },
'if': 'defined(CONFIG_POSIX)' } 'if': 'CONFIG_POSIX' }
## ##
@ -1398,7 +1398,7 @@
{ 'command': 'guest-ssh-get-authorized-keys', { 'command': 'guest-ssh-get-authorized-keys',
'data': { 'username': 'str' }, 'data': { 'username': 'str' },
'returns': 'GuestAuthorizedKeys', 'returns': 'GuestAuthorizedKeys',
'if': 'defined(CONFIG_POSIX)' } 'if': 'CONFIG_POSIX' }
## ##
# @guest-ssh-add-authorized-keys: # @guest-ssh-add-authorized-keys:
@ -1416,7 +1416,7 @@
## ##
{ 'command': 'guest-ssh-add-authorized-keys', { 'command': 'guest-ssh-add-authorized-keys',
'data': { 'username': 'str', 'keys': ['str'], '*reset': 'bool' }, 'data': { 'username': 'str', 'keys': ['str'], '*reset': 'bool' },
'if': 'defined(CONFIG_POSIX)' } 'if': 'CONFIG_POSIX' }
## ##
# @guest-ssh-remove-authorized-keys: # @guest-ssh-remove-authorized-keys:
@ -1434,4 +1434,4 @@
## ##
{ 'command': 'guest-ssh-remove-authorized-keys', { 'command': 'guest-ssh-remove-authorized-keys',
'data': { 'username': 'str', 'keys': ['str'] }, 'data': { 'username': 'str', 'keys': ['str'] },
'if': 'defined(CONFIG_POSIX)' } 'if': 'CONFIG_POSIX' }

View File

@ -204,7 +204,7 @@ def cgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> str:
if not ifcond: if not ifcond:
return '' return ''
if isinstance(ifcond, str): if isinstance(ifcond, str):
return ifcond return 'defined(' + ifcond + ')'
oper, operands = next(iter(ifcond.items())) oper, operands = next(iter(ifcond.items()))
if oper == 'not': if oper == 'not':

View File

@ -275,10 +275,10 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None:
def _check_if(cond: Union[str, object]) -> None: def _check_if(cond: Union[str, object]) -> None:
if isinstance(cond, str): if isinstance(cond, str):
if not cond.strip(): if not re.match(r'^[A-Z][A-Z0-9_]*$', cond):
raise QAPISemError( raise QAPISemError(
info, info,
"'if' condition '%s' of %s makes no sense" "'if' condition '%s' of %s is not a valid identifier"
% (cond, source)) % (cond, source))
return return

View File

@ -1,2 +1,2 @@
alternate-branch-if-invalid.json: In alternate 'Alt': alternate-branch-if-invalid.json: In alternate 'Alt':
alternate-branch-if-invalid.json:2: 'if' condition ' ' of 'data' member 'branch' makes no sense alternate-branch-if-invalid.json:2: 'if' condition ' ' of 'data' member 'branch' is not a valid identifier

View File

@ -1,2 +1,2 @@
bad-if-empty.json: In struct 'TestIfStruct': bad-if-empty.json: In struct 'TestIfStruct':
bad-if-empty.json:2: 'if' condition '' of struct makes no sense bad-if-empty.json:2: 'if' condition '' of struct is not a valid identifier

View File

@ -1,2 +1,2 @@
bad-if-list.json: In struct 'TestIfStruct': bad-if-list.json: In struct 'TestIfStruct':
bad-if-list.json:2: 'if' condition ' ' of struct makes no sense bad-if-list.json:2: 'if' condition 'foo' of struct is not a valid identifier

View File

@ -1,3 +1,3 @@
# check invalid 'if' type # check invalid 'if' type
{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' }, { 'struct': 'TestIfStruct', 'data': { 'foo': 'int' },
'if': ['defined(TEST_IF_STRUCT)'] } 'if': ['TEST_IF_STRUCT'] }

View File

@ -61,9 +61,9 @@
# @two is undocumented # @two is undocumented
## ##
{ 'enum': 'Enum', 'data': { 'enum': 'Enum', 'data':
[ { 'name': 'one', 'if': 'defined(IFONE)' }, 'two' ], [ { 'name': 'one', 'if': 'IFONE' }, 'two' ],
'features': [ 'enum-feat' ], 'features': [ 'enum-feat' ],
'if': 'defined(IFCOND)' } 'if': 'IFCOND' }
## ##
# @Base: # @Base:
@ -87,7 +87,7 @@
'features': [ 'variant1-feat' ], 'features': [ 'variant1-feat' ],
'data': { 'var1': { 'type': 'str', 'data': { 'var1': { 'type': 'str',
'features': [ 'member-feat' ], 'features': [ 'member-feat' ],
'if': 'defined(IFSTR)' } } } 'if': 'IFSTR' } } }
## ##
# @Variant2: # @Variant2:

View File

@ -12,16 +12,16 @@ enum QType
module doc-good.json module doc-good.json
enum Enum enum Enum
member one member one
if defined(IFONE) if IFONE
member two member two
if defined(IFCOND) if IFCOND
feature enum-feat feature enum-feat
object Base object Base
member base1: Enum optional=False member base1: Enum optional=False
if OrderedDict([('all', ['IFALL1', 'IFALL2'])]) if OrderedDict([('all', ['IFALL1', 'IFALL2'])])
object Variant1 object Variant1
member var1: str optional=False member var1: str optional=False
if defined(IFSTR) if IFSTR
feature member-feat feature member-feat
feature variant1-feat feature variant1-feat
object Variant2 object Variant2

View File

@ -43,7 +43,7 @@ Example:
Values Values
~~~~~~ ~~~~~~
"one" (**If: **"defined(IFONE)") "one" (**If: **"IFONE")
The _one_ {and only} The _one_ {and only}
"two" "two"
@ -62,7 +62,7 @@ Features
If If
~~ ~~
"defined(IFCOND)" "IFCOND"
"Base" (Object) "Base" (Object)
@ -93,7 +93,7 @@ Another paragraph (but no "var": line)
Members Members
~~~~~~~ ~~~~~~~
"var1": "string" (**If: **"defined(IFSTR)") "var1": "string" (**If: **"IFSTR")
Not documented Not documented

View File

@ -1,3 +1,3 @@
{ 'struct': 'FeatureStruct0', { 'struct': 'FeatureStruct0',
'data': { 'foo': 'int' }, 'data': { 'foo': 'int' },
'features': [ { 'if': 'defined(NAMELESS_FEATURES)' } ] } 'features': [ { 'if': 'NAMELESS_FEATURES' } ] }

View File

@ -222,45 +222,45 @@
{ 'struct': 'TestIfStruct', 'data': { 'struct': 'TestIfStruct', 'data':
{ 'foo': 'int', { 'foo': 'int',
'bar': { 'type': 'int', 'if': 'defined(TEST_IF_STRUCT_BAR)'} }, 'bar': { 'type': 'int', 'if': 'TEST_IF_STRUCT_BAR'} },
'if': 'defined(TEST_IF_STRUCT)' } 'if': 'TEST_IF_STRUCT' }
{ 'enum': 'TestIfEnum', 'data': { 'enum': 'TestIfEnum', 'data':
[ 'foo', { 'name' : 'bar', 'if': 'defined(TEST_IF_ENUM_BAR)' } ], [ 'foo', { 'name' : 'bar', 'if': 'TEST_IF_ENUM_BAR' } ],
'if': 'defined(TEST_IF_ENUM)' } 'if': 'TEST_IF_ENUM' }
{ 'union': 'TestIfUnion', 'data': { 'union': 'TestIfUnion', 'data':
{ 'foo': 'TestStruct', { 'foo': 'TestStruct',
'bar': { 'type': 'str', 'if': 'defined(TEST_IF_UNION_BAR)'} }, 'bar': { 'type': 'str', 'if': 'TEST_IF_UNION_BAR'} },
'if': { 'all': ['defined(TEST_IF_UNION)', 'defined(TEST_IF_STRUCT)'] } } 'if': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } }
{ 'command': 'test-if-union-cmd', { 'command': 'test-if-union-cmd',
'data': { 'union-cmd-arg': 'TestIfUnion' }, 'data': { 'union-cmd-arg': 'TestIfUnion' },
'if': 'defined(TEST_IF_UNION)' } 'if': 'TEST_IF_UNION' }
{ 'alternate': 'TestIfAlternate', 'data': { 'alternate': 'TestIfAlternate', 'data':
{ 'foo': 'int', { 'foo': 'int',
'bar': { 'type': 'TestStruct', 'if': 'defined(TEST_IF_ALT_BAR)'} }, 'bar': { 'type': 'TestStruct', 'if': 'TEST_IF_ALT_BAR'} },
'if': { 'all': ['defined(TEST_IF_ALT)', 'defined(TEST_IF_STRUCT)'] } } 'if': { 'all': ['TEST_IF_ALT', 'TEST_IF_STRUCT'] } }
{ 'command': 'test-if-alternate-cmd', { 'command': 'test-if-alternate-cmd',
'data': { 'alt-cmd-arg': 'TestIfAlternate' }, 'data': { 'alt-cmd-arg': 'TestIfAlternate' },
'if': { 'all': ['defined(TEST_IF_ALT)', 'if': { 'all': ['TEST_IF_ALT',
{'not': 'defined(TEST_IF_NOT_ALT)'}] } } {'not': 'TEST_IF_NOT_ALT'}] } }
{ 'command': 'test-if-cmd', { 'command': 'test-if-cmd',
'data': { 'data': {
'foo': 'TestIfStruct', 'foo': 'TestIfStruct',
'bar': { 'type': 'TestIfEnum', 'if': 'defined(TEST_IF_CMD_BAR)' } }, 'bar': { 'type': 'TestIfEnum', 'if': 'TEST_IF_CMD_BAR' } },
'returns': 'UserDefThree', 'returns': 'UserDefThree',
'if': { 'all': ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] } } 'if': { 'all': ['TEST_IF_CMD', 'TEST_IF_STRUCT'] } }
{ 'command': 'test-cmd-return-def-three', 'returns': 'UserDefThree' } { 'command': 'test-cmd-return-def-three', 'returns': 'UserDefThree' }
{ 'event': 'TEST_IF_EVENT', 'data': { 'event': 'TEST_IF_EVENT', 'data':
{ 'foo': 'TestIfStruct', { 'foo': 'TestIfStruct',
'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } }, 'bar': { 'type': ['TestIfEnum'], 'if': 'TEST_IF_EVT_BAR' } },
'if': { 'all': ['defined(TEST_IF_EVT)', 'defined(TEST_IF_STRUCT)'] } } 'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } }
# test 'features' # test 'features'
@ -282,21 +282,21 @@
{ 'struct': 'CondFeatureStruct1', { 'struct': 'CondFeatureStruct1',
'data': { 'foo': 'int' }, 'data': { 'foo': 'int' },
'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} ] } 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'} ] }
{ 'struct': 'CondFeatureStruct2', { 'struct': 'CondFeatureStruct2',
'data': { 'foo': 'int' }, 'data': { 'foo': 'int' },
'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'}, 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'},
{ 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} ] } { 'name': 'feature2', 'if': 'TEST_IF_FEATURE_2'} ] }
{ 'struct': 'CondFeatureStruct3', { 'struct': 'CondFeatureStruct3',
'data': { 'foo': 'int' }, 'data': { 'foo': 'int' },
'features': [ { 'name': 'feature1', 'features': [ { 'name': 'feature1',
'if': { 'all': [ 'defined(TEST_IF_COND_1)', 'if': { 'all': [ 'TEST_IF_COND_1',
'defined(TEST_IF_COND_2)'] } } ] } 'TEST_IF_COND_2'] } } ] }
{ 'struct': 'CondFeatureStruct4', { 'struct': 'CondFeatureStruct4',
'data': { 'foo': 'int' }, 'data': { 'foo': 'int' },
'features': [ { 'name': 'feature1', 'features': [ { 'name': 'feature1',
'if': {'any': ['defined(TEST_IF_COND_1)', 'if': {'any': ['TEST_IF_COND_1',
'defined(TEST_IF_COND_2)'] } } ] } 'TEST_IF_COND_2'] } } ] }
{ 'enum': 'FeatureEnum1', { 'enum': 'FeatureEnum1',
'data': [ 'eins', 'zwei', 'drei' ], 'data': [ 'eins', 'zwei', 'drei' ],
@ -331,14 +331,14 @@
'features': [ 'feature1', 'feature2' ] } 'features': [ 'feature1', 'feature2' ] }
{ 'command': 'test-command-cond-features1', { 'command': 'test-command-cond-features1',
'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} ] } 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'} ] }
{ 'command': 'test-command-cond-features2', { 'command': 'test-command-cond-features2',
'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'}, 'features': [ { 'name': 'feature1', 'if': 'TEST_IF_FEATURE_1'},
{ 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} ] } { 'name': 'feature2', 'if': 'TEST_IF_FEATURE_2'} ] }
{ 'command': 'test-command-cond-features3', { 'command': 'test-command-cond-features3',
'features': [ { 'name': 'feature1', 'features': [ { 'name': 'feature1',
'if': { 'all': [ 'defined(TEST_IF_COND_1)', 'if': { 'all': [ 'TEST_IF_COND_1',
'defined(TEST_IF_COND_2)'] } } ] } 'TEST_IF_COND_2'] } } ] }
{ 'event': 'TEST_EVENT_FEATURES0', { 'event': 'TEST_EVENT_FEATURES0',
'data': 'FeatureStruct1' } 'data': 'FeatureStruct1' }

View File

@ -298,65 +298,65 @@ command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_x-Unio
object TestIfStruct object TestIfStruct
member foo: int optional=False member foo: int optional=False
member bar: int optional=False member bar: int optional=False
if defined(TEST_IF_STRUCT_BAR) if TEST_IF_STRUCT_BAR
if defined(TEST_IF_STRUCT) if TEST_IF_STRUCT
enum TestIfEnum enum TestIfEnum
member foo member foo
member bar member bar
if defined(TEST_IF_ENUM_BAR) if TEST_IF_ENUM_BAR
if defined(TEST_IF_ENUM) if TEST_IF_ENUM
object q_obj_TestStruct-wrapper object q_obj_TestStruct-wrapper
member data: TestStruct optional=False member data: TestStruct optional=False
enum TestIfUnionKind enum TestIfUnionKind
member foo member foo
member bar member bar
if defined(TEST_IF_UNION_BAR) if TEST_IF_UNION_BAR
if OrderedDict([('all', ['defined(TEST_IF_UNION)', 'defined(TEST_IF_STRUCT)'])]) if OrderedDict([('all', ['TEST_IF_UNION', 'TEST_IF_STRUCT'])])
object TestIfUnion object TestIfUnion
member type: TestIfUnionKind optional=False member type: TestIfUnionKind optional=False
tag type tag type
case foo: q_obj_TestStruct-wrapper case foo: q_obj_TestStruct-wrapper
case bar: q_obj_str-wrapper case bar: q_obj_str-wrapper
if defined(TEST_IF_UNION_BAR) if TEST_IF_UNION_BAR
if OrderedDict([('all', ['defined(TEST_IF_UNION)', 'defined(TEST_IF_STRUCT)'])]) if OrderedDict([('all', ['TEST_IF_UNION', 'TEST_IF_STRUCT'])])
object q_obj_test-if-union-cmd-arg object q_obj_test-if-union-cmd-arg
member union-cmd-arg: TestIfUnion optional=False member union-cmd-arg: TestIfUnion optional=False
if defined(TEST_IF_UNION) if TEST_IF_UNION
command test-if-union-cmd q_obj_test-if-union-cmd-arg -> None command test-if-union-cmd q_obj_test-if-union-cmd-arg -> None
gen=True success_response=True boxed=False oob=False preconfig=False gen=True success_response=True boxed=False oob=False preconfig=False
if defined(TEST_IF_UNION) if TEST_IF_UNION
alternate TestIfAlternate alternate TestIfAlternate
tag type tag type
case foo: int case foo: int
case bar: TestStruct case bar: TestStruct
if defined(TEST_IF_ALT_BAR) if TEST_IF_ALT_BAR
if OrderedDict([('all', ['defined(TEST_IF_ALT)', 'defined(TEST_IF_STRUCT)'])]) if OrderedDict([('all', ['TEST_IF_ALT', 'TEST_IF_STRUCT'])])
object q_obj_test-if-alternate-cmd-arg object q_obj_test-if-alternate-cmd-arg
member alt-cmd-arg: TestIfAlternate optional=False member alt-cmd-arg: TestIfAlternate optional=False
if OrderedDict([('all', ['defined(TEST_IF_ALT)', OrderedDict([('not', 'defined(TEST_IF_NOT_ALT)')])])]) if OrderedDict([('all', ['TEST_IF_ALT', OrderedDict([('not', 'TEST_IF_NOT_ALT')])])])
command test-if-alternate-cmd q_obj_test-if-alternate-cmd-arg -> None command test-if-alternate-cmd q_obj_test-if-alternate-cmd-arg -> None
gen=True success_response=True boxed=False oob=False preconfig=False gen=True success_response=True boxed=False oob=False preconfig=False
if OrderedDict([('all', ['defined(TEST_IF_ALT)', OrderedDict([('not', 'defined(TEST_IF_NOT_ALT)')])])]) if OrderedDict([('all', ['TEST_IF_ALT', OrderedDict([('not', 'TEST_IF_NOT_ALT')])])])
object q_obj_test-if-cmd-arg object q_obj_test-if-cmd-arg
member foo: TestIfStruct optional=False member foo: TestIfStruct optional=False
member bar: TestIfEnum optional=False member bar: TestIfEnum optional=False
if defined(TEST_IF_CMD_BAR) if TEST_IF_CMD_BAR
if OrderedDict([('all', ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'])]) if OrderedDict([('all', ['TEST_IF_CMD', 'TEST_IF_STRUCT'])])
command test-if-cmd q_obj_test-if-cmd-arg -> UserDefThree command test-if-cmd q_obj_test-if-cmd-arg -> UserDefThree
gen=True success_response=True boxed=False oob=False preconfig=False gen=True success_response=True boxed=False oob=False preconfig=False
if OrderedDict([('all', ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'])]) if OrderedDict([('all', ['TEST_IF_CMD', 'TEST_IF_STRUCT'])])
command test-cmd-return-def-three None -> UserDefThree command test-cmd-return-def-three None -> UserDefThree
gen=True success_response=True boxed=False oob=False preconfig=False gen=True success_response=True boxed=False oob=False preconfig=False
array TestIfEnumList TestIfEnum array TestIfEnumList TestIfEnum
if defined(TEST_IF_ENUM) if TEST_IF_ENUM
object q_obj_TEST_IF_EVENT-arg object q_obj_TEST_IF_EVENT-arg
member foo: TestIfStruct optional=False member foo: TestIfStruct optional=False
member bar: TestIfEnumList optional=False member bar: TestIfEnumList optional=False
if defined(TEST_IF_EVT_BAR) if TEST_IF_EVT_BAR
if OrderedDict([('all', ['defined(TEST_IF_EVT)', 'defined(TEST_IF_STRUCT)'])]) if OrderedDict([('all', ['TEST_IF_EVT', 'TEST_IF_STRUCT'])])
event TEST_IF_EVENT q_obj_TEST_IF_EVENT-arg event TEST_IF_EVENT q_obj_TEST_IF_EVENT-arg
boxed=False boxed=False
if OrderedDict([('all', ['defined(TEST_IF_EVT)', 'defined(TEST_IF_STRUCT)'])]) if OrderedDict([('all', ['TEST_IF_EVT', 'TEST_IF_STRUCT'])])
object FeatureStruct0 object FeatureStruct0
member foo: int optional=False member foo: int optional=False
object FeatureStruct1 object FeatureStruct1
@ -379,21 +379,21 @@ object FeatureStruct4
object CondFeatureStruct1 object CondFeatureStruct1
member foo: int optional=False member foo: int optional=False
feature feature1 feature feature1
if defined(TEST_IF_FEATURE_1) if TEST_IF_FEATURE_1
object CondFeatureStruct2 object CondFeatureStruct2
member foo: int optional=False member foo: int optional=False
feature feature1 feature feature1
if defined(TEST_IF_FEATURE_1) if TEST_IF_FEATURE_1
feature feature2 feature feature2
if defined(TEST_IF_FEATURE_2) if TEST_IF_FEATURE_2
object CondFeatureStruct3 object CondFeatureStruct3
member foo: int optional=False member foo: int optional=False
feature feature1 feature feature1
if OrderedDict([('all', ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'])]) if OrderedDict([('all', ['TEST_IF_COND_1', 'TEST_IF_COND_2'])])
object CondFeatureStruct4 object CondFeatureStruct4
member foo: int optional=False member foo: int optional=False
feature feature1 feature feature1
if OrderedDict([('any', ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'])]) if OrderedDict([('any', ['TEST_IF_COND_1', 'TEST_IF_COND_2'])])
enum FeatureEnum1 enum FeatureEnum1
member eins member eins
member zwei member zwei
@ -434,17 +434,17 @@ command test-command-features3 None -> None
command test-command-cond-features1 None -> None command test-command-cond-features1 None -> None
gen=True success_response=True boxed=False oob=False preconfig=False gen=True success_response=True boxed=False oob=False preconfig=False
feature feature1 feature feature1
if defined(TEST_IF_FEATURE_1) if TEST_IF_FEATURE_1
command test-command-cond-features2 None -> None command test-command-cond-features2 None -> None
gen=True success_response=True boxed=False oob=False preconfig=False gen=True success_response=True boxed=False oob=False preconfig=False
feature feature1 feature feature1
if defined(TEST_IF_FEATURE_1) if TEST_IF_FEATURE_1
feature feature2 feature feature2
if defined(TEST_IF_FEATURE_2) if TEST_IF_FEATURE_2
command test-command-cond-features3 None -> None command test-command-cond-features3 None -> None
gen=True success_response=True boxed=False oob=False preconfig=False gen=True success_response=True boxed=False oob=False preconfig=False
feature feature1 feature feature1
if OrderedDict([('all', ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'])]) if OrderedDict([('all', ['TEST_IF_COND_1', 'TEST_IF_COND_2'])])
event TEST_EVENT_FEATURES0 FeatureStruct1 event TEST_EVENT_FEATURES0 FeatureStruct1
boxed=False boxed=False
event TEST_EVENT_FEATURES1 None event TEST_EVENT_FEATURES1 None

View File

@ -1,3 +1,3 @@
# we reject duplicate events # we reject duplicate events
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } } { 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
{ 'event': 'EVENT_A', 'data': { 'myint': 'int' }, 'if': 'defined(FOO)' } { 'event': 'EVENT_A', 'data': { 'myint': 'int' }, 'if': 'FOO' }

View File

@ -1,2 +1,2 @@
union-branch-if-invalid.json: In union 'Uni': union-branch-if-invalid.json: In union 'Uni':
union-branch-if-invalid.json:4: 'if' condition '' of 'data' member 'branch1' makes no sense union-branch-if-invalid.json:4: 'if' condition '' of 'data' member 'branch1' is not a valid identifier