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. Signed-off-by: Rohitashv Kumar <[email protected]> --- qapi/block-core.json | 52 +++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 1f87b07850..1087c2cbd4 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -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', -- 2.50.1
