Skip to contentSkip to conversation

qapi/block-core: gate protocol block drivers behind their CONFIG symbols

PATCH New Rohitashv Kumar 1 participant 2 messages Jul 27 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 qapi/block-core: gate protocol block drivers behind their CONFIG symbols

From: Rohitashv Kumar <[email protected]>

BlockdevDriver enumerates every block driver and is exposed through query-qmp-schema so that management tools can discover which drivers a QEMU binary supports. Some members are already gated with 'if' conditionals (replication, the CONFIG_BLKIO virtio-blk drivers, the host-device drivers) so that they only appear when actually compiled in.

The protocol drivers backed by an external library were not gated: ftp, ftps, http and https (curl), iscsi (libiscsi), nfs (libnfs), rbd (librbd) and ssh (libssh). When QEMU is built without the corresponding library the driver is not registered -- it is absent from "-drive format=help" and attempts to use it fail with "Unknown driver" -- yet query-qmp-schema still advertises it, so management layers are told a driver is available when it is not.

Gate these enum members, and their branches in the BlockdevOptions and BlockdevCreateOptions unions, with the CONFIG_* symbols that already control whether the drivers are built (CONFIG_CURL, CONFIG_LIBISCSI, CONFIG_LIBNFS, CONFIG_RBD, CONFIG_LIBSSH). query-qmp-schema now reflects the protocol drivers actually present in the binary.

---
 qapi/block-core.json | 52 +++++++++++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 17 deletions(-)
qapi/block-core.json +35 -17
index 1f87b07850..1087c2cbd4 100644
@@ -3339,18 +3339,25 @@
 { 'enum': 'BlockdevDriver',
   'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
             'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg',
-            'file', 'snapshot-access', 'ftp', 'ftps',
+            'file', 'snapshot-access',
+            { 'name': 'ftp', 'if': 'CONFIG_CURL' },
+            { 'name': 'ftps', 'if': 'CONFIG_CURL' },
             {'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
             {'name': 'host_device', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
-            'http', 'https',
+            { 'name': 'http', 'if': 'CONFIG_CURL' },
+            { 'name': 'https', 'if': 'CONFIG_CURL' },
             { 'name': 'io_uring', 'if': 'CONFIG_BLKIO' },
-            'iscsi',
-            'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme',
+            { 'name': 'iscsi', 'if': 'CONFIG_LIBISCSI' },
+            'luks', 'nbd',
+            { 'name': 'nfs', 'if': 'CONFIG_LIBNFS' },
+            'null-aio', 'null-co', 'nvme',
             { 'name': 'nvme-io_uring', 'if': 'CONFIG_BLKIO' },
             'parallels', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum',
-            'raw', 'rbd',
+            'raw',
+            { 'name': 'rbd', 'if': 'CONFIG_RBD' },
             { 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
-            'ssh', 'throttle', 'vdi', 'vhdx',
+            { 'name': 'ssh', 'if': 'CONFIG_LIBSSH' },
+            'throttle', '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' },
@@ -4843,20 +4850,26 @@
       'copy-on-read':'BlockdevOptionsCor',
       'dmg':        'BlockdevOptionsGenericFormat',
       'file':       'BlockdevOptionsFile',
-      'ftp':        'BlockdevOptionsCurlFtp',
-      'ftps':       'BlockdevOptionsCurlFtps',
+      'ftp':        { 'type': 'BlockdevOptionsCurlFtp',
+                      'if': 'CONFIG_CURL' },
+      'ftps':       { 'type': 'BlockdevOptionsCurlFtps',
+                      'if': 'CONFIG_CURL' },
       'host_cdrom':  { 'type': 'BlockdevOptionsFile',
                        'if': 'HAVE_HOST_BLOCK_DEVICE' },
       'host_device': { 'type': 'BlockdevOptionsFile',
                        'if': 'HAVE_HOST_BLOCK_DEVICE' },
-      'http':       'BlockdevOptionsCurlHttp',
-      'https':      'BlockdevOptionsCurlHttps',
+      'http':       { 'type': 'BlockdevOptionsCurlHttp',
+                      'if': 'CONFIG_CURL' },
+      'https':      { 'type': 'BlockdevOptionsCurlHttps',
+                      'if': 'CONFIG_CURL' },
       'io_uring':   { 'type': 'BlockdevOptionsIoUring',
                       'if': 'CONFIG_BLKIO' },
-      'iscsi':      'BlockdevOptionsIscsi',
+      'iscsi':      { 'type': 'BlockdevOptionsIscsi',
+                      'if': 'CONFIG_LIBISCSI' },
       'luks':       'BlockdevOptionsLUKS',
       'nbd':        'BlockdevOptionsNbd',
-      'nfs':        'BlockdevOptionsNfs',
+      'nfs':        { 'type': 'BlockdevOptionsNfs',
+                      'if': 'CONFIG_LIBNFS' },
       'null-aio':   'BlockdevOptionsNull',
       'null-co':    'BlockdevOptionsNull',
       'nvme':       'BlockdevOptionsNVMe',
@@ -4869,11 +4882,13 @@
       'qed':        'BlockdevOptionsGenericCOWFormat',
       'quorum':     'BlockdevOptionsQuorum',
       'raw':        'BlockdevOptionsRaw',
-      'rbd':        'BlockdevOptionsRbd',
+      'rbd':        { 'type': 'BlockdevOptionsRbd',
+                      'if': 'CONFIG_RBD' },
       'replication': { 'type': 'BlockdevOptionsReplication',
                        'if': 'CONFIG_REPLICATION' },
       'snapshot-access': 'BlockdevOptionsGenericFormat',
-      'ssh':        'BlockdevOptionsSsh',
+      'ssh':        { 'type': 'BlockdevOptionsSsh',
+                      'if': 'CONFIG_LIBSSH' },
       'throttle':   'BlockdevOptionsThrottle',
       'vdi':        'BlockdevOptionsGenericFormat',
       'vhdx':       'BlockdevOptionsGenericFormat',
@@ -5543,13 +5558,16 @@
   'data': {
       'file':           'BlockdevCreateOptionsFile',
       'luks':           'BlockdevCreateOptionsLUKS',
-      'nfs':            'BlockdevCreateOptionsNfs',
+      'nfs':            { 'type': 'BlockdevCreateOptionsNfs',
+                          'if': 'CONFIG_LIBNFS' },
       'parallels':      'BlockdevCreateOptionsParallels',
       'qcow':           'BlockdevCreateOptionsQcow',
       'qcow2':          'BlockdevCreateOptionsQcow2',
       'qed':            'BlockdevCreateOptionsQed',
-      'rbd':            'BlockdevCreateOptionsRbd',
-      'ssh':            'BlockdevCreateOptionsSsh',
+      'rbd':            { 'type': 'BlockdevCreateOptionsRbd',
+                          'if': 'CONFIG_RBD' },
+      'ssh':            { 'type': 'BlockdevCreateOptionsSsh',
+                          'if': 'CONFIG_LIBSSH' },
       'vdi':            'BlockdevCreateOptionsVdi',
       'vhdx':           'BlockdevCreateOptionsVhdx',
       'vmdk':           'BlockdevCreateOptionsVmdk',
Signature · 1 line
2.50.1
#1 lore raw

PATCH 2/2 block: gate optional format block drivers in the QAPI schema

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".

---
 meson.build          | 10 +++++++
 qapi/block-core.json | 71 ++++++++++++++++++++++++++++++--------------
 2 files changed, 59 insertions(+), 22 deletions(-)
meson.build +10 -0
index 49a5baf5b5..de164f9bc6 100644
@@ -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)
 
qapi/block-core.json +49 -22

130 lines not on this page · raw message

Signature · 1 line
2.50.1