From: Thomas Huth <[email protected]> Other command line options like "-chardev", "-netdev" or "-device" already present the user with a list of available parameters, but when running "-blockdev help", there is currently only an error message. There is already the possibility to run "-drive format=help", but it does not seem to be documented, so this is not very useful for the average user. Thus let's improve this situation by providing a proper list of available drivers when running QEMU with "-blockdev help".
Signed-off-by: Thomas Huth <[email protected]> Message-ID: <[email protected]> Reviewed-by: Eric Blake <[email protected]> Tested-by: Eric Blake <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> --- include/block/block-common.h | 1 + block.c | 15 +++++++++++++++ system/vl.c | 7 +++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/block/block-common.h b/include/block/block-common.h index 3932ff86156..1667fe5b625 100644 --- a/include/block/block-common.h +++ b/include/block/block-common.h @@ -583,5 +583,6 @@ char *path_combine(const char *base_path, const char *filename); char *bdrv_get_full_backing_filename_from_filename(const char *backed, const char *backing, Error **errp); +void bdrv_show_help(void); #endif /* BLOCK_COMMON_H */ diff --git a/block.c b/block.c index e72268db8d9..609763b635e 100644 --- a/block.c +++ b/block.c @@ -524,6 +524,21 @@ bool bdrv_uses_whitelist(void) return use_bdrv_whitelist; } +static void bdrv_help_format_print(void *opaque, const char *name) +{ + if (bdrv_format_is_whitelisted(name, false)) { + printf("%s\n", name); + } else { + printf("%s (read-only)\n", name); + } +} + +void bdrv_show_help(void) +{ + printf("Available blockdev drivers:\n"); + bdrv_iterate_format(bdrv_help_format_print, NULL, true); +} + typedef struct CreateCo { BlockDriver *drv; char *filename; diff --git a/system/vl.c b/system/vl.c index fbe580746d3..7ae6a8298fc 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2975,7 +2975,10 @@ void qemu_init(int argc, char **argv) HD_OPTS); break; case QEMU_OPTION_blockdev: - { + if (is_help_option(optarg)) { + bdrv_show_help(); + exit(EXIT_SUCCESS); + } else { Visitor *v; BlockdevOptionsQueueEntry *bdo; @@ -2988,8 +2991,8 @@ void qemu_init(int argc, char **argv) visit_free(v); loc_save(&bdo->loc); QSIMPLEQ_INSERT_TAIL(&bdo_queue, bdo, entry); - break; } + break; case QEMU_OPTION_drive: if (!qemu_opts_parse_noisily(qemu_find_opts("drive"), optarg, false)) { -- 2.56.0
