Remove support for command-line option parameters without values. Only key=val from now on. However, keep 'help' without a value.
Stop passing around pointers to booleans. This is mostly due to the handling of 'help'. In the process, fix 'help=foo' which is currently accepted. Cleanup the arguments of qemu_opts_parse* (due to the above, but also) to stop passing in the return of qemu_opts_find() as first argument, which can return NULL and lead to segfault. Add _parse_list and _parse_list_noisily versions to keep things clear. Replace instances of the _parse_*noisily functions with the non-noisily variant wherever possible. CI run: https://gitlab.com/farosas/qemu/-/pipelines/2897412802 Thanks! --- RFC: https://lore.kernel.org/r/[email protected] The call chain around qemu_opts_parse() is a bit convoluted. The main issues are: - It's split in two versions, one that uses Error and another that prints messages directly. - Callers sometimes fetch the QemuOptsList with qemu_opts_find() before calling into qemu_opts_parse, sometimes a list is already available. - The printing of help options, warnings and errors is done at different levels, passing booleans and pointers to booleans around to get the information at the right place. - It can't always handle a NULL list (segfaults). https://lore.kernel.org/r/[email protected] This series attempts to make it simpler by: - Merging the code into a single function with wrappers taking either QemuOpts or QemuOptsList; - Removing a couple of function arguments by always setting the Error at the leaf level and letting the callers decide what to do with it. Plain refactoring, no functional change intended. CI run: https://gitlab.com/farosas/qemu/-/pipelines/2862893421 Fabiano Rosas (11): qemu-option: Use g_autofree when calling get_opt_name_value() tests/unit/test-qemu-opts: Validate help=foo options qemu-option: Remove short form options support qemu-option: Fix 'help' parameter parsing qemu-option: Add qemu_opts_parse_list qemu-option: Change qemu_parse_opts() to take the group name qemu-option: Add qemu_opts_parse_list_noisily qemu-option: Use qemu_opts_parse_list_noisily where appropriate qemu-option: Change qemu_opts_parse_noisily() to take the group qemu-option: Check for NULL list at qemu_opts_parse() qemu-option: Remove a few instances of noisily parsing block/monitor/block-hmp-cmds.c | 6 +- blockdev.c | 2 +- chardev/char-hmp-cmds.c | 5 +- docs/about/deprecated.rst | 13 -- include/qemu/option.h | 8 +- include/qemu/option_int.h | 1 + include/system/tpm.h | 3 +- monitor/hmp.c | 4 +- net/net.c | 4 +- plugins/loader.c | 5 +- qemu-img.c | 14 +- qemu-io-cmds.c | 2 +- qemu-io.c | 10 +- qemu-nbd.c | 6 +- semihosting/config.c | 4 +- storage-daemon/qemu-storage-daemon.c | 4 +- system/qdev-monitor.c | 2 +- system/tpm.c | 8 +- system/vl.c | 114 +++++------- tests/qemu-iotests/084 | 2 +- tests/qemu-iotests/146 | 2 +- tests/qemu-iotests/197 | 2 +- tests/qemu-iotests/215 | 2 +- tests/unit/test-char.c | 12 +- tests/unit/test-opts-visitor.c | 12 +- tests/unit/test-qemu-opts.c | 252 ++++++++++++++++----------- tests/unit/test-replication.c | 17 +- tests/unit/test-seccomp.c | 6 +- tests/unit/test-util-sockets.c | 33 ---- tools/qemu-vnc/qemu-vnc.c | 2 +- trace/control.c | 3 +- ui/vnc.c | 3 +- util/qemu-option.c | 202 +++++++++++++-------- util/qemu-sockets.c | 2 +- 34 files changed, 395 insertions(+), 372 deletions(-) -- 2.53.0
