Skip to content

Commit 8a9f1e1

Browse files
elmarcoMarkus Armbruster
authored and
Markus Armbruster
committed
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 <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Tested-by: John Snow <[email protected]> Message-Id: <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> [Rebased with semantic conflict in redefined-event.json] Signed-off-by: Markus Armbruster <[email protected]>
1 parent 2b7d214 commit 8a9f1e1

25 files changed

+206
-208
lines changed

qapi/block-core.json

+17-17
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@
914914
'data': {
915915
'file': 'BlockStatsSpecificFile',
916916
'host_device': { 'type': 'BlockStatsSpecificFile',
917-
'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' },
917+
'if': 'HAVE_HOST_BLOCK_DEVICE' },
918918
'nvme': 'BlockStatsSpecificNvme' } }
919919

920920
##
@@ -2796,7 +2796,7 @@
27962796
##
27972797
{ 'enum': 'BlockdevAioOptions',
27982798
'data': [ 'threads', 'native',
2799-
{ 'name': 'io_uring', 'if': 'defined(CONFIG_LINUX_IO_URING)' } ] }
2799+
{ 'name': 'io_uring', 'if': 'CONFIG_LINUX_IO_URING' } ] }
28002800

28012801
##
28022802
# @BlockdevCacheOptions:
@@ -2832,12 +2832,12 @@
28322832
'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
28332833
'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps',
28342834
'gluster',
2835-
{'name': 'host_cdrom', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' },
2836-
{'name': 'host_device', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' },
2835+
{'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
2836+
{'name': 'host_device', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
28372837
'http', 'https', 'iscsi',
28382838
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
28392839
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
2840-
{ 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' },
2840+
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
28412841
'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
28422842

28432843
##
@@ -2879,10 +2879,10 @@
28792879
'*locking': 'OnOffAuto',
28802880
'*aio': 'BlockdevAioOptions',
28812881
'*drop-cache': {'type': 'bool',
2882-
'if': 'defined(CONFIG_LINUX)'},
2882+
'if': 'CONFIG_LINUX'},
28832883
'*x-check-cache-dropped': 'bool' },
28842884
'features': [ { 'name': 'dynamic-auto-read-only',
2885-
'if': 'defined(CONFIG_POSIX)' } ] }
2885+
'if': 'CONFIG_POSIX' } ] }
28862886

28872887
##
28882888
# @BlockdevOptionsNull:
@@ -3774,7 +3774,7 @@
37743774
# Since: 2.9
37753775
##
37763776
{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ],
3777-
'if': 'defined(CONFIG_REPLICATION)' }
3777+
'if': 'CONFIG_REPLICATION' }
37783778

37793779
##
37803780
# @BlockdevOptionsReplication:
@@ -3793,7 +3793,7 @@
37933793
'base': 'BlockdevOptionsGenericFormat',
37943794
'data': { 'mode': 'ReplicationMode',
37953795
'*top-id': 'str' },
3796-
'if': 'defined(CONFIG_REPLICATION)' }
3796+
'if': 'CONFIG_REPLICATION' }
37973797

37983798
##
37993799
# @NFSTransport:
@@ -4108,9 +4108,9 @@
41084108
'ftps': 'BlockdevOptionsCurlFtps',
41094109
'gluster': 'BlockdevOptionsGluster',
41104110
'host_cdrom': { 'type': 'BlockdevOptionsFile',
4111-
'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' },
4111+
'if': 'HAVE_HOST_BLOCK_DEVICE' },
41124112
'host_device': { 'type': 'BlockdevOptionsFile',
4113-
'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' },
4113+
'if': 'HAVE_HOST_BLOCK_DEVICE' },
41144114
'http': 'BlockdevOptionsCurlHttp',
41154115
'https': 'BlockdevOptionsCurlHttps',
41164116
'iscsi': 'BlockdevOptionsIscsi',
@@ -4129,7 +4129,7 @@
41294129
'raw': 'BlockdevOptionsRaw',
41304130
'rbd': 'BlockdevOptionsRbd',
41314131
'replication': { 'type': 'BlockdevOptionsReplication',
4132-
'if': 'defined(CONFIG_REPLICATION)' },
4132+
'if': 'CONFIG_REPLICATION' },
41334133
'ssh': 'BlockdevOptionsSsh',
41344134
'throttle': 'BlockdevOptionsThrottle',
41354135
'vdi': 'BlockdevOptionsGenericFormat',
@@ -4307,8 +4307,8 @@
43074307
# @size: Size of the virtual disk in bytes
43084308
# @preallocation: Preallocation mode for the new image (default: off;
43094309
# allowed values: off,
4310-
# falloc (if defined CONFIG_POSIX_FALLOCATE),
4311-
# full (if defined CONFIG_POSIX))
4310+
# falloc (if CONFIG_POSIX_FALLOCATE),
4311+
# full (if CONFIG_POSIX))
43124312
# @nocow: Turn off copy-on-write (valid only on btrfs; default: off)
43134313
# @extent-size-hint: Extent size hint to add to the image file; 0 for not
43144314
# adding an extent size hint (default: 1 MB, since 5.1)
@@ -4331,8 +4331,8 @@
43314331
# @size: Size of the virtual disk in bytes
43324332
# @preallocation: Preallocation mode for the new image (default: off;
43334333
# allowed values: off,
4334-
# falloc (if defined CONFIG_GLUSTERFS_FALLOCATE),
4335-
# full (if defined CONFIG_GLUSTERFS_ZEROFILL))
4334+
# falloc (if CONFIG_GLUSTERFS_FALLOCATE),
4335+
# full (if CONFIG_GLUSTERFS_ZEROFILL))
43364336
#
43374337
# Since: 2.12
43384338
##
@@ -4432,7 +4432,7 @@
44324432
# Since: 5.1
44334433
##
44344434
{ 'enum': 'Qcow2CompressionType',
4435-
'data': [ 'zlib', { 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] }
4435+
'data': [ 'zlib', { 'name': 'zstd', 'if': 'CONFIG_ZSTD' } ] }
44364436

44374437
##
44384438
# @BlockdevCreateOptionsQcow2:

qapi/block-export.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
'data': { 'mountpoint': 'str',
169169
'*growable': 'bool',
170170
'*allow-other': 'FuseExportAllowOther' },
171-
'if': 'defined(CONFIG_FUSE)' }
171+
'if': 'CONFIG_FUSE' }
172172

173173
##
174174
# @NbdServerAddOptions:
@@ -278,7 +278,7 @@
278278
##
279279
{ 'enum': 'BlockExportType',
280280
'data': [ 'nbd', 'vhost-user-blk',
281-
{ 'name': 'fuse', 'if': 'defined(CONFIG_FUSE)' } ] }
281+
{ 'name': 'fuse', 'if': 'CONFIG_FUSE' } ] }
282282

283283
##
284284
# @BlockExportOptions:
@@ -321,7 +321,7 @@
321321
'nbd': 'BlockExportOptionsNbd',
322322
'vhost-user-blk': 'BlockExportOptionsVhostUserBlk',
323323
'fuse': { 'type': 'BlockExportOptionsFuse',
324-
'if': 'defined(CONFIG_FUSE)' }
324+
'if': 'CONFIG_FUSE' }
325325
} }
326326

327327
##

qapi/char.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
{ 'struct': 'ChardevSpiceChannel',
343343
'data': { 'type': 'str' },
344344
'base': 'ChardevCommon',
345-
'if': 'defined(CONFIG_SPICE)' }
345+
'if': 'CONFIG_SPICE' }
346346

347347
##
348348
# @ChardevSpicePort:
@@ -356,7 +356,7 @@
356356
{ 'struct': 'ChardevSpicePort',
357357
'data': { 'fqdn': 'str' },
358358
'base': 'ChardevCommon',
359-
'if': 'defined(CONFIG_SPICE)' }
359+
'if': 'CONFIG_SPICE' }
360360

361361
##
362362
# @ChardevVC:
@@ -405,7 +405,7 @@
405405
'data': { '*mouse': 'bool',
406406
'*clipboard': 'bool' },
407407
'base': 'ChardevCommon',
408-
'if': 'defined(CONFIG_SPICE_PROTOCOL)' }
408+
'if': 'CONFIG_SPICE_PROTOCOL' }
409409

410410
##
411411
# @ChardevBackend:
@@ -431,11 +431,11 @@
431431
'stdio': 'ChardevStdio',
432432
'console': 'ChardevCommon',
433433
'spicevmc': { 'type': 'ChardevSpiceChannel',
434-
'if': 'defined(CONFIG_SPICE)' },
434+
'if': 'CONFIG_SPICE' },
435435
'spiceport': { 'type': 'ChardevSpicePort',
436-
'if': 'defined(CONFIG_SPICE)' },
436+
'if': 'CONFIG_SPICE' },
437437
'qemu-vdagent': { 'type': 'ChardevQemuVDAgent',
438-
'if': 'defined(CONFIG_SPICE_PROTOCOL)' },
438+
'if': 'CONFIG_SPICE_PROTOCOL' },
439439
'vc': 'ChardevVC',
440440
'ringbuf': 'ChardevRingbuf',
441441
# next one is just for compatibility

qapi/machine-target.json

+20-20
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
##
9090
{ 'struct': 'CpuModelBaselineInfo',
9191
'data': { 'model': 'CpuModelInfo' },
92-
'if': 'defined(TARGET_S390X)' }
92+
'if': 'TARGET_S390X' }
9393

9494
##
9595
# @CpuModelCompareInfo:
@@ -112,7 +112,7 @@
112112
{ 'struct': 'CpuModelCompareInfo',
113113
'data': { 'result': 'CpuModelCompareResult',
114114
'responsible-properties': ['str'] },
115-
'if': 'defined(TARGET_S390X)' }
115+
'if': 'TARGET_S390X' }
116116

117117
##
118118
# @query-cpu-model-comparison:
@@ -156,7 +156,7 @@
156156
{ 'command': 'query-cpu-model-comparison',
157157
'data': { 'modela': 'CpuModelInfo', 'modelb': 'CpuModelInfo' },
158158
'returns': 'CpuModelCompareInfo',
159-
'if': 'defined(TARGET_S390X)' }
159+
'if': 'TARGET_S390X' }
160160

161161
##
162162
# @query-cpu-model-baseline:
@@ -200,7 +200,7 @@
200200
'data': { 'modela': 'CpuModelInfo',
201201
'modelb': 'CpuModelInfo' },
202202
'returns': 'CpuModelBaselineInfo',
203-
'if': 'defined(TARGET_S390X)' }
203+
'if': 'TARGET_S390X' }
204204

205205
##
206206
# @CpuModelExpansionInfo:
@@ -213,9 +213,9 @@
213213
##
214214
{ 'struct': 'CpuModelExpansionInfo',
215215
'data': { 'model': 'CpuModelInfo' },
216-
'if': { 'any': [ 'defined(TARGET_S390X)',
217-
'defined(TARGET_I386)',
218-
'defined(TARGET_ARM)'] } }
216+
'if': { 'any': [ 'TARGET_S390X',
217+
'TARGET_I386',
218+
'TARGET_ARM' ] } }
219219

220220
##
221221
# @query-cpu-model-expansion:
@@ -254,9 +254,9 @@
254254
'data': { 'type': 'CpuModelExpansionType',
255255
'model': 'CpuModelInfo' },
256256
'returns': 'CpuModelExpansionInfo',
257-
'if': { 'any': [ 'defined(TARGET_S390X)',
258-
'defined(TARGET_I386)',
259-
'defined(TARGET_ARM)' ] } }
257+
'if': { 'any': [ 'TARGET_S390X',
258+
'TARGET_I386',
259+
'TARGET_ARM' ] } }
260260

261261
##
262262
# @CpuDefinitionInfo:
@@ -320,11 +320,11 @@
320320
'typename': 'str',
321321
'*alias-of' : 'str',
322322
'deprecated' : 'bool' },
323-
'if': { 'any': [ 'defined(TARGET_PPC)',
324-
'defined(TARGET_ARM)',
325-
'defined(TARGET_I386)',
326-
'defined(TARGET_S390X)',
327-
'defined(TARGET_MIPS)' ] } }
323+
'if': { 'any': [ 'TARGET_PPC',
324+
'TARGET_ARM',
325+
'TARGET_I386',
326+
'TARGET_S390X',
327+
'TARGET_MIPS' ] } }
328328

329329
##
330330
# @query-cpu-definitions:
@@ -336,8 +336,8 @@
336336
# Since: 1.2
337337
##
338338
{ 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
339-
'if': { 'any': [ 'defined(TARGET_PPC)',
340-
'defined(TARGET_ARM)',
341-
'defined(TARGET_I386)',
342-
'defined(TARGET_S390X)',
343-
'defined(TARGET_MIPS)' ] } }
339+
'if': { 'any': [ 'TARGET_PPC',
340+
'TARGET_ARM',
341+
'TARGET_I386',
342+
'TARGET_S390X',
343+
'TARGET_MIPS' ] } }

qapi/migration.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@
533533
##
534534
{ 'enum': 'MultiFDCompression',
535535
'data': [ 'none', 'zlib',
536-
{ 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] }
536+
{ 'name': 'zstd', 'if': 'CONFIG_ZSTD' } ] }
537537

538538
##
539539
# @BitmapMigrationBitmapAliasTransform:
@@ -1562,7 +1562,7 @@
15621562
##
15631563
{ 'command': 'xen-set-replication',
15641564
'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' },
1565-
'if': 'defined(CONFIG_REPLICATION)' }
1565+
'if': 'CONFIG_REPLICATION' }
15661566

15671567
##
15681568
# @ReplicationStatus:
@@ -1578,7 +1578,7 @@
15781578
##
15791579
{ 'struct': 'ReplicationStatus',
15801580
'data': { 'error': 'bool', '*desc': 'str' },
1581-
'if': 'defined(CONFIG_REPLICATION)' }
1581+
'if': 'CONFIG_REPLICATION' }
15821582

15831583
##
15841584
# @query-xen-replication-status:
@@ -1596,7 +1596,7 @@
15961596
##
15971597
{ 'command': 'query-xen-replication-status',
15981598
'returns': 'ReplicationStatus',
1599-
'if': 'defined(CONFIG_REPLICATION)' }
1599+
'if': 'CONFIG_REPLICATION' }
16001600

16011601
##
16021602
# @xen-colo-do-checkpoint:
@@ -1613,7 +1613,7 @@
16131613
# Since: 2.9
16141614
##
16151615
{ 'command': 'xen-colo-do-checkpoint',
1616-
'if': 'defined(CONFIG_REPLICATION)' }
1616+
'if': 'CONFIG_REPLICATION' }
16171617

16181618
##
16191619
# @COLOStatus:

0 commit comments

Comments
 (0)