From: Rohitashv Kumar <[email protected]>
The optional format drivers can be disabled at configure time
(--disable-dmg, --disable-bochs, --disable-cloop, --disable-vvfat,
--disable-qed, --disable-parallels, --disable-vdi, --disable-vmdk,
--disable-vpc, --disable-qcow1), but their BlockdevDriver enum members
were advertised unconditionally by query-qmp-schema even when the driver
was compiled out, mirroring the protocol-driver problem fixed in the
previous patch.
Unlike the protocol drivers these had no CONFIG_* symbol to gate on:
block/meson.build only compiles the driver source conditionally via
get_option('x').allowed(). Export a config-host symbol for each optional
format driver (CONFIG_QCOW1, CONFIG_VDI, CONFIG_VMDK, CONFIG_VPC,
CONFIG_CLOOP, CONFIG_BOCHS, CONFIG_VVFAT, CONFIG_DMG, CONFIG_QED,
CONFIG_PARALLELS) and use it to gate the matching BlockdevDriver enum
members and the BlockdevOptions / BlockdevCreateOptions union branches.
The always-built drivers (qcow2, raw, luks, nbd, vhdx, ...) remain
ungated. query-qmp-schema now lists only the format drivers actually
compiled in, matching "-drive format=help".
Signed-off-by: Rohitashv Kumar <[email protected]>
---
meson.build | 10 +++++++
qapi/block-core.json | 71 ++++++++++++++++++++++++++++++--------------
2 files changed, 59 insertions(+), 22 deletions(-)
diff --git a/meson.build b/meson.build
index 49a5baf5b5..de164f9bc6 100644
--- a/meson.build
+++ b/meson.build
@@ -2581,6 +2581,16 @@ config_host_data.set('CONFIG_DEBUG_TCG',
get_option('debug_tcg'))
config_host_data.set('CONFIG_DEBUG_REMAP', get_option('debug_remap'))
config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug'))
config_host_data.set('CONFIG_REPLICATION', get_option('replication').allowed())
+config_host_data.set('CONFIG_QCOW1', get_option('qcow1').allowed())
+config_host_data.set('CONFIG_VDI', get_option('vdi').allowed())
+config_host_data.set('CONFIG_VMDK', get_option('vmdk').allowed())
+config_host_data.set('CONFIG_VPC', get_option('vpc').allowed())
+config_host_data.set('CONFIG_CLOOP', get_option('cloop').allowed())
+config_host_data.set('CONFIG_BOCHS', get_option('bochs').allowed())
+config_host_data.set('CONFIG_VVFAT', get_option('vvfat').allowed())
+config_host_data.set('CONFIG_DMG', get_option('dmg').allowed())
+config_host_data.set('CONFIG_QED', get_option('qed').allowed())
+config_host_data.set('CONFIG_PARALLELS', get_option('parallels').allowed())
config_host_data.set('CONFIG_FSFREEZE', qga_fsfreeze)
config_host_data.set('CONFIG_FSTRIM', qga_fstrim)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 1087c2cbd4..34ef1c70e1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3337,8 +3337,11 @@
# Since: 2.9
##
{ 'enum': 'BlockdevDriver',
- 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
- 'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg',
+ 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify',
+ { 'name': 'bochs', 'if': 'CONFIG_BOCHS' },
+ { 'name': 'cloop', 'if': 'CONFIG_CLOOP' },
+ 'compress', 'copy-before-write', 'copy-on-read',
+ { 'name': 'dmg', 'if': 'CONFIG_DMG' },
'file', 'snapshot-access',
{ 'name': 'ftp', 'if': 'CONFIG_CURL' },
{ 'name': 'ftps', 'if': 'CONFIG_CURL' },
@@ -3352,16 +3355,24 @@
{ 'name': 'nfs', 'if': 'CONFIG_LIBNFS' },
'null-aio', 'null-co', 'nvme',
{ 'name': 'nvme-io_uring', 'if': 'CONFIG_BLKIO' },
- 'parallels', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum',
- 'raw',
+ { 'name': 'parallels', 'if': 'CONFIG_PARALLELS' },
+ 'preallocate',
+ { 'name': 'qcow', 'if': 'CONFIG_QCOW1' },
+ 'qcow2',
+ { 'name': 'qed', 'if': 'CONFIG_QED' },
+ 'quorum', 'raw',
{ 'name': 'rbd', 'if': 'CONFIG_RBD' },
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
{ 'name': 'ssh', 'if': 'CONFIG_LIBSSH' },
- 'throttle', 'vdi', 'vhdx',
+ 'throttle',
+ { 'name': 'vdi', 'if': 'CONFIG_VDI' },
+ 'vhdx',
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' },
- 'vmdk', 'vpc', 'vvfat' ] }
+ { 'name': 'vmdk', 'if': 'CONFIG_VMDK' },
+ { 'name': 'vpc', 'if': 'CONFIG_VPC' },
+ { 'name': 'vvfat', 'if': 'CONFIG_VVFAT' } ] }
##
# @BlockdevOptionsFile:
@@ -4843,12 +4854,15 @@
'blklogwrites':'BlockdevOptionsBlklogwrites',
'blkverify': 'BlockdevOptionsBlkverify',
'blkreplay': 'BlockdevOptionsBlkreplay',
- 'bochs': 'BlockdevOptionsGenericFormat',
- 'cloop': 'BlockdevOptionsGenericFormat',
+ 'bochs': { 'type': 'BlockdevOptionsGenericFormat',
+ 'if': 'CONFIG_BOCHS' },
+ 'cloop': { 'type': 'BlockdevOptionsGenericFormat',
+ 'if': 'CONFIG_CLOOP' },
'compress': 'BlockdevOptionsGenericFormat',
'copy-before-write':'BlockdevOptionsCbw',
'copy-on-read':'BlockdevOptionsCor',
- 'dmg': 'BlockdevOptionsGenericFormat',
+ 'dmg': { 'type': 'BlockdevOptionsGenericFormat',
+ 'if': 'CONFIG_DMG' },
'file': 'BlockdevOptionsFile',
'ftp': { 'type': 'BlockdevOptionsCurlFtp',
'if': 'CONFIG_CURL' },
@@ -4875,11 +4889,14 @@
'nvme': 'BlockdevOptionsNVMe',
'nvme-io_uring': { 'type': 'BlockdevOptionsNvmeIoUring',
'if': 'CONFIG_BLKIO' },
- 'parallels': 'BlockdevOptionsGenericFormat',
+ 'parallels': { 'type': 'BlockdevOptionsGenericFormat',
+ 'if': 'CONFIG_PARALLELS' },
'preallocate':'BlockdevOptionsPreallocate',
'qcow2': 'BlockdevOptionsQcow2',
- 'qcow': 'BlockdevOptionsQcow',
- 'qed': 'BlockdevOptionsGenericCOWFormat',
+ 'qcow': { 'type': 'BlockdevOptionsQcow',
+ 'if': 'CONFIG_QCOW1' },
+ 'qed': { 'type': 'BlockdevOptionsGenericCOWFormat',
+ 'if': 'CONFIG_QED' },
'quorum': 'BlockdevOptionsQuorum',
'raw': 'BlockdevOptionsRaw',
'rbd': { 'type': 'BlockdevOptionsRbd',
@@ -4890,7 +4907,8 @@
'ssh': { 'type': 'BlockdevOptionsSsh',
'if': 'CONFIG_LIBSSH' },
'throttle': 'BlockdevOptionsThrottle',
- 'vdi': 'BlockdevOptionsGenericFormat',
+ 'vdi': { 'type': 'BlockdevOptionsGenericFormat',
+ 'if': 'CONFIG_VDI' },
'vhdx': 'BlockdevOptionsGenericFormat',
'virtio-blk-vfio-pci':
{ 'type': 'BlockdevOptionsVirtioBlkVfioPci',
@@ -4901,9 +4919,12 @@
'virtio-blk-vhost-vdpa':
{ 'type': 'BlockdevOptionsVirtioBlkVhostVdpa',
'if': 'CONFIG_BLKIO' },
- 'vmdk': 'BlockdevOptionsGenericCOWFormat',
- 'vpc': 'BlockdevOptionsGenericFormat',
- 'vvfat': 'BlockdevOptionsVVFAT'
+ 'vmdk': { 'type': 'BlockdevOptionsGenericCOWFormat',
+ 'if': 'CONFIG_VMDK' },
+ 'vpc': { 'type': 'BlockdevOptionsGenericFormat',
+ 'if': 'CONFIG_VPC' },
+ 'vvfat': { 'type': 'BlockdevOptionsVVFAT',
+ 'if': 'CONFIG_VVFAT' }
} }
##
@@ -5560,18 +5581,24 @@
'luks': 'BlockdevCreateOptionsLUKS',
'nfs': { 'type': 'BlockdevCreateOptionsNfs',
'if': 'CONFIG_LIBNFS' },
- 'parallels': 'BlockdevCreateOptionsParallels',
- 'qcow': 'BlockdevCreateOptionsQcow',
+ 'parallels': { 'type': 'BlockdevCreateOptionsParallels',
+ 'if': 'CONFIG_PARALLELS' },
+ 'qcow': { 'type': 'BlockdevCreateOptionsQcow',
+ 'if': 'CONFIG_QCOW1' },
'qcow2': 'BlockdevCreateOptionsQcow2',
- 'qed': 'BlockdevCreateOptionsQed',
+ 'qed': { 'type': 'BlockdevCreateOptionsQed',
+ 'if': 'CONFIG_QED' },
'rbd': { 'type': 'BlockdevCreateOptionsRbd',
'if': 'CONFIG_RBD' },
'ssh': { 'type': 'BlockdevCreateOptionsSsh',
'if': 'CONFIG_LIBSSH' },
- 'vdi': 'BlockdevCreateOptionsVdi',
+ 'vdi': { 'type': 'BlockdevCreateOptionsVdi',
+ 'if': 'CONFIG_VDI' },
'vhdx': 'BlockdevCreateOptionsVhdx',
- 'vmdk': 'BlockdevCreateOptionsVmdk',
- 'vpc': 'BlockdevCreateOptionsVpc'
+ 'vmdk': { 'type': 'BlockdevCreateOptionsVmdk',
+ 'if': 'CONFIG_VMDK' },
+ 'vpc': { 'type': 'BlockdevCreateOptionsVpc',
+ 'if': 'CONFIG_VPC' }
} }
##
--
2.50.1