qemu-options: Spring cleanup
Subsystems (2)
v2 cover qemu-options: Spring cleanup
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(-)
Signature · 1 line
2.53.0
PATCH v2 1/11 qemu-option: Use g_autofree when calling get_opt_name_value()
The get_opt_name_value function takes two pointer arguments that must be freed by the callers when not used. This is a good situation to use g_autofree. Steal the pointers that need to be passed forward.
--- util/qemu-option.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
util/qemu-option.c +11 -15
@@ -813,27 +813,24 @@ static bool opts_do_parse(QemuOpts *opts, const char *params,const char *firstname, bool warn_on_flag, bool *help_wanted, Error **errp) { - char *option, *value; const char *p;QemuOpt *opt;for (p = params; *p;) { + g_autofree char *option = NULL; + g_autofree char *value = NULL; + p =get_opt_name_value (p, firstname, warn_on_flag, help_wanted, &option, &value);if (help_wanted && *help_wanted) { -g_free (option); -g_free (value);return false; } firstname =NULL ;if (!strcmp (option,"id" )) { -g_free (option); -g_free (value);continue ; } - opt =opt_create (opts, option, value); -g_free (option); + opt =opt_create (opts, option,g_steal_pointer (&value));if (!opt_validate (opt, errp)) {qemu_opt_del (opt);return false;
@@ -846,16 +843,15 @@ static bool opts_do_parse(QemuOpts *opts, const char *params,static char *opts_parse_id (const char *params) {const char *p; -char *name, *value;for (p = params; *p;) { + g_autofree char *name = NULL; + g_autofree char *value = NULL; + p =get_opt_name_value (p,NULL , false,NULL , &name, &value);if (!strcmp (name,"id" )) { -g_free (name); -return value; +return g_steal_pointer (&value); } -g_free (name); -g_free (value); }return NULL ;
@@ -864,13 +860,13 @@ static char *opts_parse_id(const char *params)bool has_help_option (const char *params) {const char *p; -char *name, *value;bool ret = false;for (p = params; *p;) { + g_autofree char *name = NULL; + g_autofree char *value = NULL; + p =get_opt_name_value (p,NULL , false, &ret, &name, &value); -g_free (name); -g_free (value);if (ret) {return true; }
Signature · 1 line
2.53.0
Re: [PATCH v2 01/11] qemu-option: Use g_autofree when calling get_opt_name_value()
Quoted 3 lines · Fabiano Rosas
The
get_opt_name_valuefunction takes two pointer arguments that must be freed by the callers when not used. This is a good situation to useg_autofree. Steal the pointers that need to be passed forward.
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 2/11 tests/unit/test-qemu-opts: Validate help=foo options
In reply to Fabiano RosasThe test_has_help_option currently tests two functions:has_help_option() and qemu_opt_has_help_opt(). The former is only used by qemu-img and has a significant difference from the latter, which is used by QOM and qdev:
- has_help_option() REJECTS help=on and all variants that provide a value, including invalid ones such as help=foo.
- qemu_opt_has_help_opt() ACCEPTS help=on and all variants that provide a value, including invalid ones such as help=foo.
Add a new test that validates these cases separately.
--- tests/unit/test-qemu-opts.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
tests/unit/test-qemu-opts.c +27 -0
@@ -750,6 +750,31 @@ static void test_has_help_option(void) } } +static void test_has_help_option_with_value (void ) +{ +static const struct { +const char *params; + } test[] = { + {"help=on" }, + {"help=off" }, + {"help=foo" }, + {"help=" }, + }; +int i; +QemuOpts *opts; + +for (i =0 ; i <ARRAY_SIZE (test); i++) { +/* reject all */ + g_assert_cmpint(has_help_option(test[i].params), ==, false); + +/* accept all */ + opts =qemu_opts_parse (&opts_list_03, test[i].params, false, + &error_abort); + g_assert_cmpint(qemu_opt_has_help_opt(opts), ==, true); +qemu_opts_del (opts); + } +} +static void append_verify_list_01 (QemuOptDesc *desc,bool with_overlapping) {int i =0 ;
@@ -1012,6 +1037,8 @@ int main(int argc, char *argv[])g_test_add_func ("/qemu-opts/opts_parse/number" , test_opts_parse_number);g_test_add_func ("/qemu-opts/opts_parse/size" , test_opts_parse_size);g_test_add_func ("/qemu-opts/has_help_option" , test_has_help_option); +g_test_add_func ("/qemu-opts/has_help_option_with_value" , + test_has_help_option_with_value);g_test_add_func ("/qemu-opts/append_to_null" , test_opts_append_to_null);g_test_add_func ("/qemu-opts/append" , test_opts_append);g_test_add_func ("/qemu-opts/to_qdict/basic" , test_opts_to_qdict_basic);
Signature · 1 line
2.53.0
Re: [PATCH v2 02/11] tests/unit/test-qemu-opts: Validate help=foo options
Quoted 9 lines · Fabiano Rosas
The
test_has_help_optioncurrently tests two functions:has_help_option()andqemu_opt_has_help_opt(). The former is only used by qemu-img and has a significant difference from the latter, which is used by QOM and qdev:-
has_help_option()REJECTS help=on and all variants that provide a value, including invalid ones such as help=foo.[...]
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 3/11 qemu-option: Remove short form options support
In reply to Fabiano RosasOption parameters without a value (i.e. key vs. key=val) are deprecated. The missing value is currently implied to be either "on" or "off" depending on whether the parameter name starts with "no".
Remove the implied behavior and start rejecting option parameters without values by emitting the error message:
"Parameter 'foo' without a value."
Two special cases remain:
1) The 'help' parameter is special and still supported. Keep a positive value attached to it ("on").
Note that currently there is no validation for the value (if any) attached to the help parameter. help, help=on, help=off, help=foo all result in the help text being emitted. This is not changed by this patch.
2) The empty value is allowed if the key is also empty. This can be achieved in the command line by adding commas.
E.g.: share=on,, is parsed as:
key:"share" value:"on" and
key:"" value:"on"
One effect of this change that might not be obvious is that parameter combinations of the form:
id=mem0,share,help
no longer produce the help output. The lack of value for the 'share' parameter is reported with precedence. Users will need to either use a valid value or omit the parameter entirely:
id=mem0,share=on,help
id=mem0,help
About testing:
A few strings from the test_has_help_option test were removed because they now trigger the missing value error during parsing and therefore cannot be used for testing the qemu_opt_has_help_opt() routine which needs the parsed QemuOpts.
The two "Implied value" tests were replaced with 8 new tests.
The "Implied key" test has had the extra parameters with implied values removed, otherwise the implied key cannot be tested due to the rejected missing values.
The test_inet_parse_all_implicit_bool_good was removed entirely because it only tested the use case that is being removed.
A few block tests were updated to use the key=value form.
--- docs/about/deprecated.rst | 13 ------- tests/qemu-iotests/084 | 2 +- tests/qemu-iotests/146 | 2 +- tests/qemu-iotests/197 | 2 +- tests/qemu-iotests/215 | 2 +- tests/unit/test-qemu-opts.c | 67 +++++++++++++++++++++------------- tests/unit/test-util-sockets.c | 33 ----------------- util/qemu-option.c | 57 ++++++++++++++--------------- 8 files changed, 73 insertions(+), 105 deletions(-)
docs/about/deprecated.rst +0 -13
@@ -30,19 +30,6 @@ deprecated. System emulator command line arguments -------------------------------------- -Short-form boolean options (since 6.0) -'''''''''''''''''''''''''''''''''''''' - -Boolean options such as ``share=on``/``share=off`` could be written -in short form as ``share`` and ``noshare``. This is now deprecated -and will cause a warning. - -``delay`` option for socket character devices (since 6.0) -''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -The replacement for the ``nodelay`` short-form boolean option is ``nodelay=on`` -rather than ``delay=off``. - Plugin argument passing through ``arg=<string>`` (since 6.1) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
tests/qemu-iotests/084 +1 -1
@@ -51,7 +51,7 @@ bii_offset=384 # block in image field offset echo echo "=== Statically allocated image creation ===" echo -_make_test_img $size -o static +_make_test_img $size -o static=on _img_info stat -c"disk image file size in bytes: %s" "${TEST_IMG}" _cleanup_test_img
tests/qemu-iotests/146 +1 -1
@@ -165,7 +165,7 @@ echo echo === Testing Image create, force_size === echo -_make_test_img -o force_size 4G +_make_test_img -o force_size=on 4G echo echo === Read created image, default opts ====
tests/qemu-iotests/197 +1 -1
@@ -63,7 +63,7 @@ echo # Prep the images # VPC rounds image sizes to a specific geometry, force a specific size. if [ "$IMGFMT" = "vpc" ]; then - IMGOPTS=$(_optstr_add "$IMGOPTS" "force_size") + IMGOPTS=$(_optstr_add "$IMGOPTS" "force_size=on") fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io
tests/qemu-iotests/215 +1 -1
@@ -60,7 +60,7 @@ echo # Prep the images # VPC rounds image sizes to a specific geometry, force a specific size. if [ "$IMGFMT" = "vpc" ]; then - IMGOPTS=$(_optstr_add "$IMGOPTS" "force_size") + IMGOPTS=$(_optstr_add "$IMGOPTS" "force_size=on") fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io
tests/unit/test-qemu-opts.c +41 -26
89 lines not on this page · raw message
tests/unit/test-util-sockets.c +0 -33
@@ -516,36 +516,6 @@ static void test_inet_parse_all_options_good(void) , &exp_addr, true); } -static void test_inet_parse_all_implicit_bool_good (void ) -{ -char host[] ="::1" ; -char port[] ="5000" ; -InetSocketAddress exp_addr = { - .host = host, - .port = port, - .has_numeric = true, - .numeric = true, - .has_to = true, - .to =5006 , - .has_ipv4 = true, - .ipv4 = true, - .has_ipv6 = true, - .ipv6 = true, - .has_keep_alive = true, - .keep_alive = true, -#ifdef HAVE_IPPROTO_MPTCP - .has_mptcp = true, - .mptcp = true, -#endif - }; -inet_parse_test_helper ( -"[::1]:5000,numeric,to=5006,ipv4,ipv6,keep-alive" -#ifdef HAVE_IPPROTO_MPTCP -",mptcp" -#endif - , &exp_addr, true); -} -int main (int argc,char **argv) {bool has_ipv4, has_ipv6;
@@ -613,9 +583,6 @@ int main(int argc, char **argv) test_inet_parse_hostname_good);g_test_add_func ("/util/socket/inet-parse/all-options-good" , test_inet_parse_all_options_good); -g_test_add_func ("/util/socket/inet-parse/all-bare-bool-good" , - test_inet_parse_all_implicit_bool_good); - end:return g_test_run (); }
util/qemu-option.c +28 -29
133 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v2 03/11] qemu-option: Remove short form options support
Quoted 8 lines · Fabiano Rosas
Option parameters without a value (i.e. key vs. key=val) are deprecated. The missing value is currently implied to be either "on" or "off" depending on whether the parameter name starts with "no".
Remove the implied behavior and start rejecting option parameters without values by emitting the error message:
[...]
Signature · 1 line
Marc-André Lureau <[email protected]>
Re: [PATCH v2 03/11] qemu-option: Remove short form options support
In reply to Fabiano RosasQuoted 3 lines · Fabiano Rosas
Option parameters without a value (i.e. key vs. key=val) are deprecated. The missing value is currently implied to be either "on" or "off" depending on whether the parameter name starts with "no".
Commit ccd3b3b811 (qemu-option: warn for short-form boolean options, 2020-11-09). Six years of warnings should suffice.
Quoted 7 lines
Remove the implied behavior and start rejecting option parameters without values by emitting the error message:
"Parameter 'foo' without a value."
Two special cases remain:
Quoted 7 lines
1) The 'help' parameter is special and still supported. Keep a positive value attached to it ("on").
Note that currently there is no validation for the value (if any) attached to the help parameter. help, help=on, help=off, help=foo all result in the help text being emitted. This is not changed by this patch.
Really?
$ qemu-system-x86_64 -chardev help=foo
qemu-system-x86_64: -chardev help=foo: Invalid parameter 'help'Quoted 5 lines
2) The empty value is allowed if the key is also empty. This can be achieved in the command line by adding commas.
E.g.: share=on,, is parsed as:
key:"share" value:"on" and
key:"" value:"on"
I don't think so:
$ qemu-system-x86_64 -object memory-backend-ram,id=mem0,share=on,,
qemu-system-x86_64: -object memory-backend-ram,id=mem0,share=on,,: Parameter 'share' expects 'on' or 'off'Set a breakpoint on qapi_bool_parse() to see the actual value. It's "on,". In QemuOpts syntax, double comma is an escape, so you can put comma in values.
Quoted 11 lines
One effect of this change that might not be obvious is that parameter combinations of the form:
id=mem0,share,help
no longer produce the help output. The lack of value for the 'share' parameter is reported with precedence. Users will need to either use a valid value or omit the parameter entirely:
id=mem0,share=on,help
id=mem0,help
That's unfortunate.
[...]
Re: [PATCH v2 03/11] qemu-option: Remove short form options support
Quoted 24 lines · Markus Armbruster
Quoted 3 lines · Fabiano Rosas
Option parameters without a value (i.e. key vs. key=val) are deprecated. The missing value is currently implied to be either "on" or "off" depending on whether the parameter name starts with "no".
Commit
ccd3b3b811(qemu-option: warn for short-form boolean options, 2020-11-09). Six years of warnings should suffice.Quoted 7 lines
Remove the implied behavior and start rejecting option parameters without values by emitting the error message:
"Parameter 'foo' without a value."
Two special cases remain:
Quoted 7 lines
1) The 'help' parameter is special and still supported. Keep a positive value attached to it ("on").
Note that currently there is no validation for the value (if any) attached to the help parameter. help, help=on, help=off, help=foo all result in the help text being emitted. This is not changed by this patch.
Quoted 5 lines
Really?
$ qemu-system-x86_64 -chardev help=foo qemu-system-x86_64: -chardev help=foo: Invalid parameter 'help'
Ah, ok, it depends on whether the option accepts any parameter (i.e. opts_accepts_any()). Here's -object failing to reject the bogus value:
$ qemu-system-x86_64 -object memory-backend-ram,id=m1,help=foo memory-backend-ram options: dump=<bool> - Set to 'off' to exclude from core dump host-nodes=<[uint16]> - Binds memory to the list of NUMA host nodes merge=<bool> - Mark memory as mergeable policy=<HostMemPolicy> - Set the NUMA policy prealloc-context=<link<thread-context>> - Context to use for creating CPU threads for preallocation prealloc-threads=<int> - Number of CPU threads to use for prealloc prealloc=<bool> - Preallocate memory reserve=<bool> - Reserve swap space (or huge pages) if applicable share=<bool> - Mark the memory as private to QEMU or shared size=<size> - Size of the memory region (ex: 500M) x-use-canonical-path-for-ramblock-id=<bool>
Quoted 11 lines
Quoted 5 lines
2) The empty value is allowed if the key is also empty. This can be achieved in the command line by adding commas.
E.g.: share=on,, is parsed as:
key:"share" value:"on" and
key:"" value:"on"I don't think so:
$ qemu-system-x86_64 -object memory-backend-ram,id=mem0,share=on,, qemu-system-x86_64: -object memory-backend-ram,id=mem0,share=on,,: Parameter 'share' expects 'on' or 'off'
Bah, I wrote the example for the commit message but haven't tried it. I'm trying to refer to the single leading comma scenario, we have a test for it:
/* Except when it isn't */
opts = qemu_opts_parse(&opts_list_03, ",", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpstr(qemu_opt_get(opts, ""), ==, "on");The following are parsed as valid and only reject the empty key further down the line:
$ qemu-system-x86_64 -drive , qemu-system-x86_64: -drive ,: warning: short-form boolean option '' deprecated Please use =on instead qemu-system-x86_64: -drive ,: Must specify either driver or file
$ qemu-system-x86_64 -drive ,file=dummy
qemu-system-x86_64: -drive ,file=dummy: warning: short-form boolean option '' deprecated
Please use =on instead
WARNING: Image format was not specified for 'dummy' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
qemu-system-x86_64: -drive ,file=dummy: Block format 'raw' does not support the option ''Quoted 19 lines
Set a breakpoint on
qapi_bool_parse()to see the actual value. It's "on,". In QemuOpts syntax, double comma is an escape, so you can put comma in values.Quoted 11 lines
One effect of this change that might not be obvious is that parameter combinations of the form:
id=mem0,share,help
no longer produce the help output. The lack of value for the 'share' parameter is reported with precedence. Users will need to either use a valid value or omit the parameter entirely:
id=mem0,share=on,help
id=mem0,helpThat's unfortunate.
[...]
Re: [PATCH v2 03/11] qemu-option: Remove short form options support
Quoted 36 lines · Fabiano Rosas
Quoted 24 lines · Markus Armbruster
Quoted 3 lines · Fabiano Rosas
Option parameters without a value (i.e. key vs. key=val) are deprecated. The missing value is currently implied to be either "on" or "off" depending on whether the parameter name starts with "no".
Commit
ccd3b3b811(qemu-option: warn for short-form boolean options, 2020-11-09). Six years of warnings should suffice.Quoted 7 lines
Remove the implied behavior and start rejecting option parameters without values by emitting the error message:
"Parameter 'foo' without a value."
Two special cases remain:
Quoted 7 lines
1) The 'help' parameter is special and still supported. Keep a positive value attached to it ("on").
Note that currently there is no validation for the value (if any) attached to the help parameter. help, help=on, help=off, help=foo all result in the help text being emitted. This is not changed by this patch.
Quoted 5 lines
Really?
$ qemu-system-x86_64 -chardev help=foo qemu-system-x86_64: -chardev help=foo: Invalid parameter 'help'Ah, ok, it depends on whether the option accepts any parameter (i.e.
opts_accepts_any()). Here's -object failing to reject the bogus value:
Quoted 13 lines
$ qemu-system-x86_64 -object memory-backend-ram,id=m1,help=foo memory-backend-ram options: dump=<bool> - Set to 'off' to exclude from core dump host-nodes=<[uint16]> - Binds memory to the list of NUMA host nodes merge=<bool> - Mark memory as mergeable policy=<HostMemPolicy> - Set the NUMA policy prealloc-context=<link<thread-context>> - Context to use for creating CPU threads for preallocation prealloc-threads=<int> - Number of CPU threads to use for prealloc prealloc=<bool> - Preallocate memory reserve=<bool> - Reserve swap space (or huge pages) if applicable share=<bool> - Mark the memory as private to QEMU or shared size=<size> - Size of the memory region (ex: 500M) x-use-canonical-path-for-ramblock-id=<bool>
Bizarre :)
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
2) The empty value is allowed if the key is also empty. This can be achieved in the command line by adding commas.
E.g.: share=on,, is parsed as:
key:"share" value:"on" and
key:"" value:"on"I don't think so:
$ qemu-system-x86_64 -object memory-backend-ram,id=mem0,share=on,, qemu-system-x86_64: -object memory-backend-ram,id=mem0,share=on,,: Parameter 'share' expects 'on' or 'off'
Quoted 8 lines
Bah, I wrote the example for the commit message but haven't tried it. I'm trying to refer to the single leading comma scenario, we have a test for it:
/* Except when it isn't */ opts = qemu_opts_parse(&opts_list_03, ",", false, &error_abort); g_assert_cmpuint(opts_count(opts), ==, 1); g_assert_cmpstr(qemu_opt_get(opts, ""), ==, "on");
The "except when it isn't" comment refers to the test right above:
/* Trailing comma is ignored */
opts = qemu_opts_parse(&opts_list_03, "x=y,", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpstr(qemu_opt_get(opts, "x"), ==, "y");This is about trailing comma. Is the exception is only possible when the trailing comma is also the leading comma?
Quoted 11 lines
The following are parsed as valid and only reject the empty key further down the line:
$ qemu-system-x86_64 -drive , qemu-system-x86_64: -drive ,: warning: short-form boolean option '' deprecated Please use =on instead qemu-system-x86_64: -drive ,: Must specify either driver or file$ qemu-system-x86_64 -drive ,file=dummy qemu-system-x86_64: -drive ,file=dummy: warning: short-form boolean option '' deprecated Please use =on instead
Looks like the answer is no. The tests could be clearer there. Might not matter after your series.
Quoted 4 lines
WARNING: Image format was not specified for 'dummy' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions.
qemu-system-x86_64: -drive ,file=dummy: Block format 'raw' does not support the option ''
The entire parser should be burned with fire.
What are the remaining differences to the keyval.c parser after your series? Can we deprecate them?
Quoted 19 lines
Quoted 19 lines
Set a breakpoint on
qapi_bool_parse()to see the actual value. It's "on,". In QemuOpts syntax, double comma is an escape, so you can put comma in values.Quoted 11 lines
One effect of this change that might not be obvious is that parameter combinations of the form:
id=mem0,share,help
no longer produce the help output. The lack of value for the 'share' parameter is reported with precedence. Users will need to either use a valid value or omit the parameter entirely:
id=mem0,share=on,help
id=mem0,helpThat's unfortunate.
[...]
Re: [PATCH v2 03/11] qemu-option: Remove short form options support
Quoted 105 lines · Markus Armbruster
Quoted 36 lines · Fabiano Rosas
Quoted 24 lines · Markus Armbruster
Quoted 3 lines · Fabiano Rosas
Option parameters without a value (i.e. key vs. key=val) are deprecated. The missing value is currently implied to be either "on" or "off" depending on whether the parameter name starts with "no".
Commit
ccd3b3b811(qemu-option: warn for short-form boolean options, 2020-11-09). Six years of warnings should suffice.Quoted 7 lines
Remove the implied behavior and start rejecting option parameters without values by emitting the error message:
"Parameter 'foo' without a value."
Two special cases remain:
Quoted 7 lines
1) The 'help' parameter is special and still supported. Keep a positive value attached to it ("on").
Note that currently there is no validation for the value (if any) attached to the help parameter. help, help=on, help=off, help=foo all result in the help text being emitted. This is not changed by this patch.
Quoted 5 lines
Really?
$ qemu-system-x86_64 -chardev help=foo qemu-system-x86_64: -chardev help=foo: Invalid parameter 'help'Ah, ok, it depends on whether the option accepts any parameter (i.e.
opts_accepts_any()). Here's -object failing to reject the bogus value:Quoted 13 lines
$ qemu-system-x86_64 -object memory-backend-ram,id=m1,help=foo memory-backend-ram options: dump=<bool> - Set to 'off' to exclude from core dump host-nodes=<[uint16]> - Binds memory to the list of NUMA host nodes merge=<bool> - Mark memory as mergeable policy=<HostMemPolicy> - Set the NUMA policy prealloc-context=<link<thread-context>> - Context to use for creating CPU threads for preallocation prealloc-threads=<int> - Number of CPU threads to use for prealloc prealloc=<bool> - Preallocate memory reserve=<bool> - Reserve swap space (or huge pages) if applicable share=<bool> - Mark the memory as private to QEMU or shared size=<size> - Size of the memory region (ex: 500M) x-use-canonical-path-for-ramblock-id=<bool>Bizarre :)
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
2) The empty value is allowed if the key is also empty. This can be achieved in the command line by adding commas.
E.g.: share=on,, is parsed as:
key:"share" value:"on" and
key:"" value:"on"I don't think so:
$ qemu-system-x86_64 -object memory-backend-ram,id=mem0,share=on,, qemu-system-x86_64: -object memory-backend-ram,id=mem0,share=on,,: Parameter 'share' expects 'on' or 'off'Quoted 8 lines
Bah, I wrote the example for the commit message but haven't tried it. I'm trying to refer to the single leading comma scenario, we have a test for it:
/* Except when it isn't */ opts = qemu_opts_parse(&opts_list_03, ",", false, &error_abort); g_assert_cmpuint(opts_count(opts), ==, 1); g_assert_cmpstr(qemu_opt_get(opts, ""), ==, "on");The "except when it isn't" comment refers to the test right above:
/* Trailing comma is ignored */ opts = qemu_opts_parse(&opts_list_03, "x=y,", false, &error_abort); g_assert_cmpuint(opts_count(opts), ==, 1); g_assert_cmpstr(qemu_opt_get(opts, "x"), ==, "y");This is about trailing comma. Is the exception is only possible when the trailing comma is also the leading comma?
Quoted 11 lines
The following are parsed as valid and only reject the empty key further down the line:
$ qemu-system-x86_64 -drive , qemu-system-x86_64: -drive ,: warning: short-form boolean option '' deprecated Please use =on instead qemu-system-x86_64: -drive ,: Must specify either driver or file$ qemu-system-x86_64 -drive ,file=dummy qemu-system-x86_64: -drive ,file=dummy: warning: short-form boolean option '' deprecated Please use =on insteadLooks like the answer is no. The tests could be clearer there. Might not matter after your series.
Quoted 4 lines
WARNING: Image format was not specified for 'dummy' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions.
qemu-system-x86_64: -drive ,file=dummy: Block format 'raw' does not support the option ''
Quoted 5 lines
The entire parser should be burned with fire.
What are the remaining differences to the
keyval.cparser after your series? Can we deprecate them?
I ran a few of the qemu-opts tests with the keyval code and it differs mostly in the handling of empty (non-implied) key and implied key + empty value. I'll take a close look next week but I think we should deprecate them anyway.
It looks easy to add a flag to keyval_parse_one() to turn its errors into deprecation warnings ("warning: madness deprecated"). We could then gradually make the conversion without having to wait for the deprecated parts to be removed. The child is almost 10 years old.
d454dbe0ee3 ("keyval: New keyval_parse()")
Author: Markus Armbruster <[email protected]>
Date: Tue Feb 28 22:26:49 2017 +0100
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Set a breakpoint on
qapi_bool_parse()to see the actual value. It's "on,". In QemuOpts syntax, double comma is an escape, so you can put comma in values.Quoted 11 lines
One effect of this change that might not be obvious is that parameter combinations of the form:
id=mem0,share,help
no longer produce the help output. The lack of value for the 'share' parameter is reported with precedence. Users will need to either use a valid value or omit the parameter entirely:
id=mem0,share=on,help
id=mem0,helpThat's unfortunate.
[...]
Re: [PATCH v2 03/11] qemu-option: Remove short form options support
Quoted 1 line · Fabiano Rosas
Markus Armbruster <[email protected]> writes:
[...]
Quoted 11 lines
Quoted 5 lines
The entire parser should be burned with fire.
What are the remaining differences to the
keyval.cparser after your series? Can we deprecate them?I ran a few of the qemu-opts tests with the keyval code and it differs mostly in the handling of empty (non-implied) key and implied key + empty value. I'll take a close look next week but I think we should deprecate them anyway.
Quoted 8 lines
It looks easy to add a flag to
keyval_parse_one()to turn its errors into deprecation warnings ("warning: madness deprecated"). We could then gradually make the conversion without having to wait for the deprecated parts to be removed. The child is almost 10 years old.
d454dbe0ee3("keyval: Newkeyval_parse()")
Author: Markus Armbruster <[email protected]>
Date: Tue Feb 28 22:26:49 2017 +0100
Worth a try, I think.
Thanks!
[...]
Re: [PATCH v2 03/11] qemu-option: Remove short form options support
In reply to Fabiano RosasQuoted 8 lines · Fabiano Rosas
Option parameters without a value (i.e. key vs. key=val) are deprecated. The missing value is currently implied to be either "on" or "off" depending on whether the parameter name starts with "no".
Remove the implied behavior and start rejecting option parameters without values by emitting the error message:
"Parameter 'foo' without a value."
[...]
Quoted 14 lines
docs/about/deprecated.rst +0
-6@@ -30,19 +30,6 @@ deprecated. System emulator command line arguments -------------------------------------- -Short-form boolean options (since 6.0) -'''''''''''''''''''''''''''''''''''''' - -Boolean options such as ``share=on``/``share=off`` could be written -in short form as ``share`` and ``noshare``. This is now deprecated -and will cause a warning.
docs/about/deprecated.rst deprecated. · line 35
Quoted 10 lines
docs/about/deprecated.rst +0
-7- -``delay`` option for socket character devices (since 6.0) -''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -The replacement for the ``nodelay`` short-form boolean option is ``nodelay=on`` -rather than ``delay=off``. - Plugin argument passing through ``arg=<string>`` (since 6.1) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
No docs/about/removed-features.rst update?
[...]
PATCH v2 4/11 qemu-option: Fix 'help' parameter parsing
In reply to Fabiano RosasReject invalid values such as help= and help=foo.
Reject valid, but not applicable values such has help=on and help=off.
To achieve the above:
Add an 'is_help' member to QemuOpt so that information can be stored while creating the option. This allows moving the help handling out of get_opt_name_value(), which is necessary because that function doesn't take an Error.
At the caller, opts_do_parse(), let the QemuOpt be created with the name and value fields as they come out of get_opt_name_value().
With a new routine, validate the new QemuOpt against the 'help' parameter rules (to fix the bug), then let the existing opt_validate() reject any NULL values. The two validations need to be separate because in between there needs to be a setting of opt->str to "on" whenever the special short-form parameters require it.
The "on" value is required because of the conversions of QemuOpts from/to QDict since QDict cannot take a NULL value. The conversions also cause opt_validate() to be reentrant via qemu_opt_set(), so the initial validation of 'help' needs to be out of that function, otherwise there's no way to distinguish an user-set help=on vs. the help=on set for compatibility with QDict (the "in between" part from the previous paragraph).
The passing around of help_wanted becomes redundant since opt->is_help can be checked throughout. Remove that argument everywhere.
Stop returning false from opts_do_parse() when is_help=true. Only return false when there's an error and let the callers decide what to do when is_help=true. However, still break the loop when is_help=true to keep the behavior of stopping parsing once the 'help' parameter is seen.
At qemu_opts_parse_noisily(), due to the change of return value mentioned above, it becomes clear when to report the error and when to print the help text. Use qemu_opt_has_help_opt() to obtain the is_help information from QemuOpt.
Since get_opt_name_value() can now return while value=NULL, the other two callsites need to be updated. At opts_parse_id(), assert value != NULL. At has_help_option(), use the NULL value to keep the existing behavior of rejecting anything but 'help'.
The unit tests are updated accordingly.
--- include/qemu/option_int.h | 1 + tests/unit/test-qemu-opts.c | 9 ++-- util/qemu-option.c | 104 ++++++++++++++++++++---------------- 3 files changed, 63 insertions(+), 51 deletions(-)
include/qemu/option_int.h +1 -0
@@ -32,6 +32,7 @@struct QemuOpt {char *name;char *str; +bool is_help;const QemuOptDesc *desc;union {
tests/unit/test-qemu-opts.c +4 -5
@@ -777,16 +777,15 @@ static void test_has_help_option_with_value(void) };int i;QemuOpts *opts; +Error *err =NULL ;for (i =0 ; i <ARRAY_SIZE (test); i++) {/* reject all */ g_assert_cmpint(has_help_option(test[i].params), ==, false); -/* accept all */ - opts =qemu_opts_parse (&opts_list_03, test[i].params, false, - &error_abort); - g_assert_cmpint(qemu_opt_has_help_opt(opts), ==, true); -qemu_opts_del (opts); + opts =qemu_opts_parse (&opts_list_03, test[i].params, false, &err); +error_free_or_abort (&err); +g_assert (!opts); } }
util/qemu-option.c +58 -46
207 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v2 04/11] qemu-option: Fix 'help' parameter parsing
Quoted 211 lines
Reject invalid values such as help= and help=foo.
Reject valid, but not applicable values such has help=on and help=off.
To achieve the above:
Add an '
is_help' member to QemuOpt so that information can be stored while creating the option. This allows moving the help handling out ofget_opt_name_value(), which is necessary because that function doesn't take an Error.At the caller,
opts_do_parse(), let the QemuOpt be created with the name and value fields as they come out ofget_opt_name_value().With a new routine, validate the new QemuOpt against the 'help' parameter rules (to fix the bug), then let the existing
opt_validate()reject any NULL values. The two validations need to be separate because in between there needs to be a setting ofopt->strto "on" whenever the special short-form parameters require it.The "on" value is required because of the conversions of QemuOpts from/to QDict since QDict cannot take a NULL value. The conversions also cause
opt_validate()to be reentrant viaqemu_opt_set(), so the initial validation of 'help' needs to be out of that function, otherwise there's no way to distinguish an user-set help=on vs. the help=on set for compatibility with QDict (the "in between" part from the previous paragraph).The passing around of
help_wantedbecomes redundant sinceopt->is_helpcan be checked throughout. Remove that argument everywhere.Stop returning false from
opts_do_parse()when is_help=true. Only return false when there's an error and let the callers decide what to do when is_help=true. However, still break the loop when is_help=true to keep the behavior of stopping parsing once the 'help' parameter is seen.At
qemu_opts_parse_noisily(), due to the change of return value mentioned above, it becomes clear when to report the error and when to print the help text. Useqemu_opt_has_help_opt()to obtain theis_helpinformation from QemuOpt.Since
get_opt_name_value()can now return while value=NULL, the other two callsites need to be updated. Atopts_parse_id(), assert value != NULL. Athas_help_option(), use the NULL value to keep the existing behavior of rejecting anything but 'help'.The unit tests are updated accordingly.
Signed-off-by Fabiano Rosas <[email protected]>Message-ID: <[email protected]>
include/qemu/option_int.h +1
-0@@ -32,6 +32,7 @@struct QemuOpt {char *name;char *str; +bool is_help;const QemuOptDesc *desc;union {tests/unit/test-qemu-opts.c +4
-5@@ -777,16 +777,15 @@ static void test_has_help_option_with_value(void) };int i;QemuOpts *opts; +Error *err =NULL ;for (i =0 ; i <ARRAY_SIZE (test); i++) {/* reject all */ g_assert_cmpint(has_help_option(test[i].params), ==, false); -/* accept all */ - opts =qemu_opts_parse (&opts_list_03, test[i].params, false, - &error_abort); - g_assert_cmpint(qemu_opt_has_help_opt(opts), ==, true); -qemu_opts_del (opts); + opts =qemu_opts_parse (&opts_list_03, test[i].params, false, &err); +error_free_or_abort (&err); +g_assert (!opts); } }util/qemu-option.c +36
-28@@ -331,7 +331,7 @@ bool qemu_opt_has_help_opt(QemuOpts *opts)QemuOpt *opt; QTAILQ_FOREACH_REVERSE(opt, &opts->head, next) { -if (is_help_option (opt->name)) { +if (opt->is_help) {return true; } }@@ -499,6 +499,7 @@ static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value) opt->name =g_strdup (name); opt->str = value; opt->opts = opts; + opt->is_help =is_help_option (name);QTAILQ_INSERT_TAIL (&opts->head, opt, next);return opt;@@ -760,12 +761,10 @@ void qemu_opts_print(QemuOpts *opts, const char *separator)static const char *get_opt_name_value (const char *params,const char *firstname, -bool *help_wanted,char **name,char **value) {const char *p;size_t len; -bool is_help = false; len =strcspn (params,"=," );if (params[len] !='=' ) {@@ -776,22 +775,6 @@ static const char *get_opt_name_value(const char *params, p =get_opt_value (params, value); }else { p =get_opt_name (params, name, len); - -/* -* Short-form flags (i.e. without any value) are not -* supported, except for two cases: -*/ - -/* the 'help' or '?' flag */ - is_help =is_help_option (*name); -if (is_help) { - *value =g_strdup ("on" ); - } - -/* a missing, non-implicit key, i.e. a single comma ',' */ -if (g_str_equal (*name,"" ) && *p ==',' ) { - *value =g_strdup ("on" ); - } } }else {/* found "foo=bar,more" */ @@ -802,18 +785,46 @@ static const char *get_opt_name_value(const char *params, }assert (!*p || *p ==',' ); -if (help_wanted && is_help) { - *help_wanted = true; - }if (*p ==',' ) { p++; }return p; } +/* +* Short-form parameters (i.e. without any value) are not +* supported, except for two cases: +* +* - the 'help' or '?' flag +* - the empty, non-implicit key combined with an empty +* non-implicit value, i.e. a single comma ',' +* +* The rest of the code is not prepared to deal with empty values, set +* the special cases to "on". +*/ +static bool opt_short_form_compat (QemuOpt *opt,Error **errp) +{ +if (opt->str) { +/* +* Validate the 'help' parameter at this point because the +* opt_validate() routine can be reentrant and this very check +* would fail once the "on" value is set below. +*/ +if (opt->is_help) { +error_setg (errp,"Parameter '%s' doesn't take any values" , + opt->name); +return false; + } + }else { +if (opt->is_help ||g_str_equal (opt->name,"" )) { + opt->str =g_strdup ("on" ); + } + } +return true; +} +static bool opts_do_parse (QemuOpts *opts,const char *params, -const char *firstname, -bool *help_wanted,Error **errp) +const char *firstname,Error **errp) {const char *p;QemuOpt *opt;@@ -822,10 +833,7 @@ static bool opts_do_parse(QemuOpts *opts, const char *params, g_autofree char *option = NULL; g_autofree char *value = NULL; - p =get_opt_name_value (p, firstname, help_wanted, &option, &value); -if (help_wanted && *help_wanted) { -return false; - } + p =get_opt_name_value (p, firstname, &option, &value); firstname =NULL ;if (!strcmp (option,"id" )) {
util/qemu-option.c static bool opts_do_parse(QemuOpts *opts, const char *params, · line 845
Quoted 6 lines
util/qemu-option.c +2
-1@@ -833,10 +841,15 @@ static bool opts_do_parse(QemuOpts *opts, const char *params, } opt =opt_create (opts, option,g_steal_pointer (&value)); -if (!opt_validate (opt, errp)) { +if (!opt_short_form_compat (opt, errp) || + !opt_validate (opt, errp)) {
opt_validate() will reject "help" as an invalid parameter beofre the is_help check below. Change it to?:
opt = opt_create(opts, option, g_steal_pointer(&value));
if (!opt_short_form_compat(opt, errp)) {
qemu_opt_del(opt);
return false;
}
if (opt->is_help) {
return true;
}
if (!opt_validate(opt, errp)) {
qemu_opt_del(opt);
return false;
}Quoted 82 lines
util/qemu-option.c +13
-13qemu_opt_del (opt);return false; } + +if (opt->is_help) { +return true; + } }return true;@@ -850,8 +863,9 @@ static char *opts_parse_id(const char *params) g_autofree char *name = NULL; g_autofree char *value = NULL; - p =get_opt_name_value (p,NULL ,NULL , &name, &value); + p =get_opt_name_value (p,NULL , &name, &value);if (!strcmp (name,"id" )) { +assert (value);return g_steal_pointer (&value); } }@@ -862,14 +876,13 @@ static char *opts_parse_id(const char *params)bool has_help_option (const char *params) {const char *p; -bool ret = false;for (p = params; *p;) { g_autofree char *name = NULL; g_autofree char *value = NULL; - p =get_opt_name_value (p,NULL , &ret, &name, &value); -if (ret) { + p =get_opt_name_value (p,NULL , &name, &value); +if (is_help_option (name) && !value) {return true; } }@@ -886,11 +899,11 @@ bool has_help_option(const char *params)bool qemu_opts_do_parse (QemuOpts *opts,const char *params,const char *firstname,Error **errp) { -return opts_do_parse (opts, params, firstname,NULL , errp); +return opts_do_parse (opts, params, firstname, errp); }static QemuOpts *opts_parse (QemuOptsList *list,const char *params, -bool permit_abbrev,bool *help_wanted,Error **errp) +bool permit_abbrev,Error **errp) {const char *firstname;char *id =opts_parse_id (params);@@ -905,7 +918,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,return NULL ; } -if (!opts_do_parse (opts, params, firstname, help_wanted, errp)) { +if (!opts_do_parse (opts, params, firstname, errp)) {qemu_opts_del (opts);return NULL ; }@@ -923,7 +936,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,QemuOpts *qemu_opts_parse (QemuOptsList *list,const char *params,bool permit_abbrev,Error **errp) { -return opts_parse (list, params, permit_abbrev,NULL , errp); +return opts_parse (list, params, permit_abbrev, errp); }/** @@ -939,17 +952,16 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, {Error *err =NULL ;QemuOpts *opts; -bool help_wanted = false; - opts =opts_parse (list, params, permit_abbrev, -opts_accepts_any (list) ?NULL : &help_wanted, &err); + opts =opts_parse (list, params, permit_abbrev, &err);if (!opts) { -assert (!!err + !!help_wanted ==1 ); -if (help_wanted) {
util/qemu-option.c QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, · line 963
Quoted 10 lines
util/qemu-option.c +6
-4-qemu_opts_print_help (list, true); - }else { -error_report_err (err); - } +error_report_err (err); +return NULL ; + } + +if (qemu_opt_has_help_opt (opts) && !opts_accepts_any (list)) { +qemu_opts_print_help (list, true);
qemu_opts_del(opts) missing
Signature · 1 line
Marc-André Lureau <[email protected]>
Re: [PATCH v2 04/11] qemu-option: Fix 'help' parameter parsing
Quoted 213 lines · [email protected] writes:
Quoted 213 lines
Reject invalid values such as help= and help=foo.
Reject valid, but not applicable values such has help=on and help=off.
To achieve the above:
Add an '
is_help' member to QemuOpt so that information can be stored while creating the option. This allows moving the help handling out ofget_opt_name_value(), which is necessary because that function doesn't take an Error.At the caller,
opts_do_parse(), let the QemuOpt be created with the name and value fields as they come out ofget_opt_name_value().With a new routine, validate the new QemuOpt against the 'help' parameter rules (to fix the bug), then let the existing
opt_validate()reject any NULL values. The two validations need to be separate because in between there needs to be a setting ofopt->strto "on" whenever the special short-form parameters require it.The "on" value is required because of the conversions of QemuOpts from/to QDict since QDict cannot take a NULL value. The conversions also cause
opt_validate()to be reentrant viaqemu_opt_set(), so the initial validation of 'help' needs to be out of that function, otherwise there's no way to distinguish an user-set help=on vs. the help=on set for compatibility with QDict (the "in between" part from the previous paragraph).The passing around of
help_wantedbecomes redundant sinceopt->is_helpcan be checked throughout. Remove that argument everywhere.Stop returning false from
opts_do_parse()when is_help=true. Only return false when there's an error and let the callers decide what to do when is_help=true. However, still break the loop when is_help=true to keep the behavior of stopping parsing once the 'help' parameter is seen.At
qemu_opts_parse_noisily(), due to the change of return value mentioned above, it becomes clear when to report the error and when to print the help text. Useqemu_opt_has_help_opt()to obtain theis_helpinformation from QemuOpt.Since
get_opt_name_value()can now return while value=NULL, the other two callsites need to be updated. Atopts_parse_id(), assert value != NULL. Athas_help_option(), use the NULL value to keep the existing behavior of rejecting anything but 'help'.The unit tests are updated accordingly.
Signed-off-by Fabiano Rosas <[email protected]>Message-ID: <[email protected]>
include/qemu/option_int.h +1
-0@@ -32,6 +32,7 @@struct QemuOpt {char *name;char *str; +bool is_help;const QemuOptDesc *desc;union {tests/unit/test-qemu-opts.c +4
-5@@ -777,16 +777,15 @@ static void test_has_help_option_with_value(void) };int i;QemuOpts *opts; +Error *err =NULL ;for (i =0 ; i <ARRAY_SIZE (test); i++) {/* reject all */ g_assert_cmpint(has_help_option(test[i].params), ==, false); -/* accept all */ - opts =qemu_opts_parse (&opts_list_03, test[i].params, false, - &error_abort); - g_assert_cmpint(qemu_opt_has_help_opt(opts), ==, true); -qemu_opts_del (opts); + opts =qemu_opts_parse (&opts_list_03, test[i].params, false, &err); +error_free_or_abort (&err); +g_assert (!opts); } }util/qemu-option.c +36
-28@@ -331,7 +331,7 @@ bool qemu_opt_has_help_opt(QemuOpts *opts)QemuOpt *opt; QTAILQ_FOREACH_REVERSE(opt, &opts->head, next) { -if (is_help_option (opt->name)) { +if (opt->is_help) {return true; } }@@ -499,6 +499,7 @@ static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value) opt->name =g_strdup (name); opt->str = value; opt->opts = opts; + opt->is_help =is_help_option (name);QTAILQ_INSERT_TAIL (&opts->head, opt, next);return opt;@@ -760,12 +761,10 @@ void qemu_opts_print(QemuOpts *opts, const char *separator)static const char *get_opt_name_value (const char *params,const char *firstname, -bool *help_wanted,char **name,char **value) {const char *p;size_t len; -bool is_help = false; len =strcspn (params,"=," );if (params[len] !='=' ) {@@ -776,22 +775,6 @@ static const char *get_opt_name_value(const char *params, p =get_opt_value (params, value); }else { p =get_opt_name (params, name, len); - -/* -* Short-form flags (i.e. without any value) are not -* supported, except for two cases: -*/ - -/* the 'help' or '?' flag */ - is_help =is_help_option (*name); -if (is_help) { - *value =g_strdup ("on" ); - } - -/* a missing, non-implicit key, i.e. a single comma ',' */ -if (g_str_equal (*name,"" ) && *p ==',' ) { - *value =g_strdup ("on" ); - } } }else {/* found "foo=bar,more" */ @@ -802,18 +785,46 @@ static const char *get_opt_name_value(const char *params, }assert (!*p || *p ==',' ); -if (help_wanted && is_help) { - *help_wanted = true; - }if (*p ==',' ) { p++; }return p; } +/* +* Short-form parameters (i.e. without any value) are not +* supported, except for two cases: +* +* - the 'help' or '?' flag +* - the empty, non-implicit key combined with an empty +* non-implicit value, i.e. a single comma ',' +* +* The rest of the code is not prepared to deal with empty values, set +* the special cases to "on". +*/ +static bool opt_short_form_compat (QemuOpt *opt,Error **errp) +{ +if (opt->str) { +/* +* Validate the 'help' parameter at this point because the +* opt_validate() routine can be reentrant and this very check +* would fail once the "on" value is set below. +*/ +if (opt->is_help) { +error_setg (errp,"Parameter '%s' doesn't take any values" , + opt->name); +return false; + } + }else { +if (opt->is_help ||g_str_equal (opt->name,"" )) { + opt->str =g_strdup ("on" ); + } + } +return true; +} +static bool opts_do_parse (QemuOpts *opts,const char *params, -const char *firstname, -bool *help_wanted,Error **errp) +const char *firstname,Error **errp) {const char *p;QemuOpt *opt;@@ -822,10 +833,7 @@ static bool opts_do_parse(QemuOpts *opts, const char *params, g_autofree char *option = NULL; g_autofree char *value = NULL; - p =get_opt_name_value (p, firstname, help_wanted, &option, &value); -if (help_wanted && *help_wanted) { -return false; - } + p =get_opt_name_value (p, firstname, &option, &value); firstname =NULL ;if (!strcmp (option,"id" )) {@@ -833,10 +841,15 @@ static bool opts_do_parse(QemuOpts *opts, const char *params, }
Quoted 7 lines
util/qemu-option.c static bool opts_do_parse(QemuOpts *opts, const char *params, · line 845
Quoted 4 lines
util/qemu-option.c +2
-1opt =opt_create (opts, option,g_steal_pointer (&value)); -if (!opt_validate (opt, errp)) { +if (!opt_short_form_compat (opt, errp) || + !opt_validate (opt, errp)) {
opt_validate()will reject "help" as an invalid parameter beofre theis_helpcheck below. Change it to?:
It does already happen before the series, I'll add a test case for that.
Is it something we want to fix? The situation is that 'help' was present but the QemuOptsList declares a set of parameters of which 'help' is a part of. I'm not sure if this is an oversight in that it wants to reject unlisted parameters, but 'help' should have been special-cased or if the API is that options that list a set of parameters must also list the 'help'.
Quoted 99 lines
opt = opt_create(opts, option, g_steal_pointer(&value)); if (!opt_short_form_compat(opt, errp)) { qemu_opt_del(opt); return false; } if (opt->is_help) { return true; } if (!opt_validate(opt, errp)) { qemu_opt_del(opt); return false; }Quoted 86 lines
util/qemu-option.c +13
-17qemu_opt_del (opt);return false; } + +if (opt->is_help) { +return true; + } }return true;@@ -850,8 +863,9 @@ static char *opts_parse_id(const char *params) g_autofree char *name = NULL; g_autofree char *value = NULL; - p =get_opt_name_value (p,NULL ,NULL , &name, &value); + p =get_opt_name_value (p,NULL , &name, &value);if (!strcmp (name,"id" )) { +assert (value);return g_steal_pointer (&value); } }@@ -862,14 +876,13 @@ static char *opts_parse_id(const char *params)bool has_help_option (const char *params) {const char *p; -bool ret = false;for (p = params; *p;) { g_autofree char *name = NULL; g_autofree char *value = NULL; - p =get_opt_name_value (p,NULL , &ret, &name, &value); -if (ret) { + p =get_opt_name_value (p,NULL , &name, &value); +if (is_help_option (name) && !value) {return true; } }@@ -886,11 +899,11 @@ bool has_help_option(const char *params)bool qemu_opts_do_parse (QemuOpts *opts,const char *params,const char *firstname,Error **errp) { -return opts_do_parse (opts, params, firstname,NULL , errp); +return opts_do_parse (opts, params, firstname, errp); }static QemuOpts *opts_parse (QemuOptsList *list,const char *params, -bool permit_abbrev,bool *help_wanted,Error **errp) +bool permit_abbrev,Error **errp) {const char *firstname;char *id =opts_parse_id (params);@@ -905,7 +918,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,return NULL ; } -if (!opts_do_parse (opts, params, firstname, help_wanted, errp)) { +if (!opts_do_parse (opts, params, firstname, errp)) {qemu_opts_del (opts);return NULL ; }@@ -923,7 +936,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,QemuOpts *qemu_opts_parse (QemuOptsList *list,const char *params,bool permit_abbrev,Error **errp) { -return opts_parse (list, params, permit_abbrev,NULL , errp); +return opts_parse (list, params, permit_abbrev, errp); }/** @@ -939,17 +952,16 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, {Error *err =NULL ;QemuOpts *opts; -bool help_wanted = false; - opts =opts_parse (list, params, permit_abbrev, -opts_accepts_any (list) ?NULL : &help_wanted, &err); + opts =opts_parse (list, params, permit_abbrev, &err);if (!opts) { -assert (!!err + !!help_wanted ==1 ); -if (help_wanted) { -qemu_opts_print_help (list, true); - }else { -error_report_err (err); - }
Quoted 8 lines
util/qemu-option.c QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, · line 963
Quoted 6 lines
util/qemu-option.c +6
-0+error_report_err (err); +return NULL ; + } + +if (qemu_opt_has_help_opt (opts) && !opts_accepts_any (list)) { +qemu_opts_print_help (list, true);
qemu_opts_del(opts)missing
Indeed. Thanks!
PATCH v2 5/11 qemu-option: Add qemu_opts_parse_list
In reply to Fabiano RosasCurrently the qemu_opts_parse and qemu_opts_parse_noisily functions are called in one two ways:
1) qemu_opts_parse|_noisily(&some_group_list, ...)
2) qemu_opts_parse|_noisily(qemu_find_opts("some_opt"), ...)
The second form is problematic. Having the result of qemu_find_opts() going directly into the first argument makes it difficult to handle a possible NULL pointer retuned by it.
Next patches will change qemu_opts_parse() and qemu_opts_parse_noisily() to receive the option name and call qemu_find_opts() in their body so the return of the function can be handled properly.
Add a new qemu_opts_parse_list() and change all callsites that pass the list directly to use it. In the next patches this new _list version will become the inner function, but at this point, simply make it defer to qemu_opts_parse() to make the refactoring easier.
--- include/qemu/option.h | 2 + tests/unit/test-qemu-opts.c | 179 +++++++++++++++++++----------------- util/qemu-option.c | 13 +++ util/qemu-sockets.c | 2 +- 4 files changed, 109 insertions(+), 87 deletions(-)
include/qemu/option.h +2 -0
@@ -132,6 +132,8 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params, bool permit_abbrev);QemuOpts *qemu_opts_parse (QemuOptsList *list,const char *params,bool permit_abbrev,Error **errp); +QemuOpts *qemu_opts_parse_list (QemuOptsList *list,const char *params, +bool permit_abbrev,Error **errp);QemuOpts *qemu_opts_from_qdict (QemuOptsList *list,const QDict *qdict,Error **errp); QDict *qemu_opts_to_qdict_filtered(QemuOpts *opts, QDict *qdict,
tests/unit/test-qemu-opts.c +93 -86
419 lines not on this page · raw message
util/qemu-option.c +13 -0
@@ -939,6 +939,19 @@ QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,return opts_parse (list, params, permit_abbrev, errp); } +/** +* Create a QemuOpts from @list with options parsed from @params. If +* @permit_abbrev, the first key=value in @params may omit key= and is +* treated as if key was @list->implied_opt_name. On error, store an +* error object through @errp if non-null. Return the new QemuOpts on +* success, null pointer on error. +*/ +QemuOpts *qemu_opts_parse_list (QemuOptsList *list,const char *params, +bool permit_abbrev,Error **errp) +{ +return qemu_opts_parse (list, params, permit_abbrev, errp); +} +/** * Create a QemuOpts in @list and with options parsed from @params. * If @permit_abbrev, the first key=value in @params may omit key=,
util/qemu-sockets.c +1 -1
@@ -704,7 +704,7 @@ static QemuOptsList inet_opts = {int inet_parse (InetSocketAddress *addr,const char *str,Error **errp) { -QemuOpts *opts =qemu_opts_parse (&inet_opts, str, true, errp); +QemuOpts *opts =qemu_opts_parse_list (&inet_opts, str, true, errp);if (!opts) {return -1 ; }
Signature · 1 line
2.53.0
Re: [PATCH v2 05/11] qemu-option: Add qemu_opts_parse_list
Quoted 11 lines · Fabiano Rosas
Currently the
qemu_opts_parseandqemu_opts_parse_noisilyfunctions are called in one two ways:1) qemu_opts_parse|_noisily(&some_group_list, ...)
2) qemu_opts_parse|_noisily(qemu_find_opts("some_opt"), ...)The second form is problematic. Having the result of
qemu_find_opts()going directly into the first argument makes it difficult to handle a possible NULL pointer retuned by it.[...]
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 6/11 qemu-option: Change qemu_parse_opts() to take the group name
In reply to Fabiano RosasGet rid of the pattern qemu_parse_opts(qemu_find_opts("some-opt")) by passing the string directly to qemu_parse_opts().
Don't check for NULL list at this time to preserve the old behavior. A subsequent patch will correct that.
--- include/qemu/option.h | 2 +- system/vl.c | 5 ++--- tests/unit/test-opts-visitor.c | 12 ++++-------- util/qemu-option.c | 19 +++++++++++-------- 4 files changed, 18 insertions(+), 20 deletions(-)
include/qemu/option.h +1 -1
@@ -130,7 +130,7 @@ bool qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, Error **errp);QemuOpts *qemu_opts_parse_noisily (QemuOptsList *list,const char *params,bool permit_abbrev); -QemuOpts *qemu_opts_parse (QemuOptsList *list,const char *params, +QemuOpts *qemu_opts_parse (const char *group,const char *params,bool permit_abbrev,Error **errp);QemuOpts *qemu_opts_parse_list (QemuOptsList *list,const char *params,bool permit_abbrev,Error **errp);
system/vl.c +2 -3
@@ -1441,10 +1441,9 @@ static void qemu_create_default_devices(void) }if (default_net) { -QemuOptsList *net =qemu_find_opts ("net" ); -qemu_opts_parse (net,"nic" , true, &error_abort); +qemu_opts_parse ("net" ,"nic" , true, &error_abort);#ifdef CONFIG_SLIRP -qemu_opts_parse (net,"user" , true, &error_abort); +qemu_opts_parse ("net" ,"user" , true, &error_abort);#endif }
tests/unit/test-opts-visitor.c +4 -8
@@ -39,8 +39,7 @@ setup_fixture(OptsVisitorFixture *f, gconstpointer test_data)QemuOpts *opts;Visitor *v; - opts =qemu_opts_parse (qemu_find_opts ("userdef" ), opts_string, false, -NULL ); + opts =qemu_opts_parse ("userdef" , opts_string, false,NULL );g_assert (opts !=NULL ); v =opts_visitor_new (opts);
@@ -181,8 +180,7 @@ test_opts_range_unvisited(void)QemuOpts *opts;Visitor *v; - opts =qemu_opts_parse (qemu_find_opts ("userdef" ),"ilist=0-2" , false, - &error_abort); + opts =qemu_opts_parse ("userdef" ,"ilist=0-2" , false, &error_abort); v =opts_visitor_new (opts);
@@ -222,8 +220,7 @@ test_opts_range_beyond(void)Visitor *v;int64_t val; - opts =qemu_opts_parse (qemu_find_opts ("userdef" ),"ilist=0" , false, - &error_abort); + opts =qemu_opts_parse ("userdef" ,"ilist=0" , false, &error_abort); v =opts_visitor_new (opts);
@@ -257,8 +254,7 @@ test_opts_dict_unvisited(void)Visitor *v;UserDefOptions *userdef; - opts =qemu_opts_parse (qemu_find_opts ("userdef" ),"i64x=0,bogus=1" , false, - &error_abort); + opts =qemu_opts_parse ("userdef" ,"i64x=0,bogus=1" , false, &error_abort); v =opts_visitor_new (opts);visit_type_UserDefOptions (v,NULL , &userdef, &err);
util/qemu-option.c +11 -8
@@ -26,6 +26,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/config-file.h" #include "qemu/error-report.h" #include "qobject/qbool.h" #include "qobject/qdict.h"
@@ -927,16 +928,18 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params, }/** -* Create a QemuOpts in @list and with options parsed from @params. -* If @permit_abbrev, the first key=value in @params may omit key=, -* and is treated as if key was @list->implied_opt_name. -* On error, store an error object through @errp if non-null. -* Return the new QemuOpts on success, null pointer on error. +* Find the @group and create a QemuOpts with options parsed from +* @params. If @permit_abbrev, the first key=value in @params may +* omit key=. On error, store an error object through @errp if +* non-null. Return the new QemuOpts on success, null pointer on +* error. */ -QemuOpts *qemu_opts_parse (QemuOptsList *list,const char *params, +QemuOpts *qemu_opts_parse (const char *group,const char *params,bool permit_abbrev,Error **errp) { -return opts_parse (list, params, permit_abbrev, errp); +QemuOptsList *list =qemu_find_opts_err (group, errp); + +return qemu_opts_parse_list (list, params, permit_abbrev, errp); }/**
@@ -949,7 +952,7 @@ QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,QemuOpts *qemu_opts_parse_list (QemuOptsList *list,const char *params,bool permit_abbrev,Error **errp) { -return qemu_opts_parse (list, params, permit_abbrev, errp); +return opts_parse (list, params, permit_abbrev, errp); }/**
Signature · 1 line
2.53.0
Re: [PATCH v2 06/11] qemu-option: Change qemu_parse_opts() to take the group name
Quoted 8 lines · Fabiano Rosas
Get rid of the pattern qemu_parse_opts(qemu_find_opts("some-opt")) by passing the string directly to
qemu_parse_opts().Don't check for NULL list at this time to preserve the old behavior. A subsequent patch will correct that.
[...]
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 7/11 qemu-option: Add qemu_opts_parse_list_noisily
In reply to Fabiano RosasAdd a new function that takes a QemuOptsList pointer and expects informative messages to be printed instead of returned in an Error object. This makes the _noisily version simmetric with the "non-noisily". The next patch will convert the callers to use the appropriate version.
--- include/qemu/option.h | 2 ++ util/qemu-option.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)
include/qemu/option.h +2 -0
@@ -134,6 +134,8 @@ QemuOpts *qemu_opts_parse(const char *group, const char *params, bool permit_abbrev, Error **errp);QemuOpts *qemu_opts_parse_list (QemuOptsList *list,const char *params,bool permit_abbrev,Error **errp); +QemuOpts *qemu_opts_parse_list_noisily (QemuOptsList *list,const char *params, +bool permit_abbrev);QemuOpts *qemu_opts_from_qdict (QemuOptsList *list,const QDict *qdict,Error **errp); QDict *qemu_opts_to_qdict_filtered(QemuOpts *opts, QDict *qdict,
util/qemu-option.c +14 -0
@@ -965,6 +965,20 @@ QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params,*/ QemuOpts *qemu_opts_parse_noisily (QemuOptsList *list,const char *params,bool permit_abbrev) +{ +return qemu_opts_parse_list_noisily (list, params, permit_abbrev); +} + +/** +* Create a QemuOpts in @list and with options parsed from @params. +* If @permit_abbrev, the first key=value in @params may omit key=, +* and is treated as if key was @list->implied_opt_name. +* Report errors with error_report_err(). This is inappropriate in +* QMP context. Do not use this function there! +* Return the new QemuOpts on success, null pointer on error. +*/ +QemuOpts *qemu_opts_parse_list_noisily (QemuOptsList *list,const char *params, +bool permit_abbrev) {Error *err =NULL ;QemuOpts *opts;
Signature · 1 line
2.53.0
Re: [PATCH v2 07/11] qemu-option: Add qemu_opts_parse_list_noisily
Quoted 8 lines · Fabiano Rosas
Add a new function that takes a QemuOptsList pointer and expects informative messages to be printed instead of returned in an Error object. This makes the
_noisilyversion simmetric with the "non-noisily". The next patch will convert the callers to use the appropriate version.[...]
Signature · 1 line
Marc-André Lureau <[email protected]>
Re: [PATCH v2 07/11] qemu-option: Add qemu_opts_parse_list_noisily
In reply to Fabiano RosasQuoted 3 lines · Fabiano Rosas
Add a new function that takes a QemuOptsList pointer and expects informative messages to be printed instead of returned in an Error object. This makes the
_noisilyversion simmetric with the
symmetric
Quoted 5 lines
"non-noisily". The next patch will convert the callers to use the appropriate version.
Signed-off-by Fabiano Rosas <[email protected]>---
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org
PATCH v2 8/11 qemu-option: Use qemu_opts_parse_list_noisily where appropriate
In reply to Fabiano RosasChange the callers of qemu_opts_parse_noisily() that currently take a QemuOptsList pointer to call qemu_opts_parse_list_noisily().
This is done to free up the qemu_opts_parse_noisily() version to be used to take the group name instead.
--- block/monitor/block-hmp-cmds.c | 2 +- monitor/hmp.c | 2 +- net/net.c | 2 +- qemu-img.c | 8 ++++---- qemu-io-cmds.c | 2 +- qemu-io.c | 7 ++++--- qemu-nbd.c | 6 +++--- storage-daemon/qemu-storage-daemon.c | 4 ++-- system/qdev-monitor.c | 2 +- system/tpm.c | 2 +- system/vl.c | 6 +++--- tests/unit/test-replication.c | 6 +++--- tools/qemu-vnc/qemu-vnc.c | 2 +- 13 files changed, 26 insertions(+), 25 deletions(-)
block/monitor/block-hmp-cmds.c +1 -1
@@ -63,7 +63,7 @@ static void hmp_drive_add_node(MonitorHMP *hmp, const char *optstr)QDict *qdict;Error *err =NULL ; - opts =qemu_opts_parse_noisily (&qemu_drive_opts, optstr, false); + opts =qemu_opts_parse_list_noisily (&qemu_drive_opts, optstr, false);if (!opts) {return ; }
monitor/hmp.c +1 -1
@@ -897,7 +897,7 @@ static QDict *monitor_parse_arguments(MonitorHMP *mon,if (get_str (buf,sizeof (buf), &p) <0 ) { goto fail; } - opts =qemu_opts_parse_noisily (opts_list, buf, true); + opts =qemu_opts_parse_list_noisily (opts_list, buf, true);if (!opts) { goto fail; }
net/net.c +1 -1
@@ -2029,7 +2029,7 @@ void netdev_parse_modern(const char *optstr)void net_client_parse (QemuOptsList *opts_list,const char *optstr) { -if (!qemu_opts_parse_noisily (opts_list, optstr, true)) { +if (!qemu_opts_parse_list_noisily (opts_list, optstr, true)) {exit (1 ); } }
qemu-img.c +4 -4
@@ -2383,8 +2383,8 @@ static int img_convert(const img_cmd_t *ccmd, int argc, char **argv)break ;case 'l' :if (strstart (optarg,SNAPSHOT_OPT_BASE ,NULL )) { - sn_opts =qemu_opts_parse_noisily (&internal_snapshot_opts, - optarg, false); + sn_opts =qemu_opts_parse_list_noisily (&internal_snapshot_opts, + optarg, false);if (!sn_opts) {error_report ("Failed in parsing snapshot param '%s'" , optarg);
@@ -5768,8 +5768,8 @@ static int img_measure(const img_cmd_t *ccmd, int argc, char **argv)break ;case 'l' :if (strstart (optarg,SNAPSHOT_OPT_BASE ,NULL )) { - sn_opts =qemu_opts_parse_noisily (&internal_snapshot_opts, - optarg, false); + sn_opts =qemu_opts_parse_list_noisily (&internal_snapshot_opts, + optarg, false);if (!sn_opts) {error_report ("Failed in parsing snapshot param '%s'" , optarg);
qemu-io-cmds.c +1 -1
@@ -2540,7 +2540,7 @@ static int reopen_f(BlockBackend *blk, int argc, char **argv, Error **errp) has_cache_option = true;break ;case 'o' : -if (!qemu_opts_parse_noisily (&reopen_opts, optarg,0 )) { +if (!qemu_opts_parse_list_noisily (&reopen_opts, optarg,0 )) {qemu_opts_reset (&reopen_opts);return -EINVAL ; }
qemu-io.c +4 -3
@@ -220,7 +220,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv, Error **errp)qemu_opts_reset (&empty_opts);return -EINVAL ; } -if (!qemu_opts_parse_noisily (&empty_opts, optarg, false)) { +if (!qemu_opts_parse_list_noisily (&empty_opts, optarg, false)) {qemu_opts_reset (&empty_opts);return -EINVAL ; }
@@ -240,7 +240,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv, Error **errp) }if (imageOpts && (optind == argc -1 )) { -if (!qemu_opts_parse_noisily (&empty_opts, argv[optind], false)) { +if (!qemu_opts_parse_list_noisily (&empty_opts, argv[optind], false)) {qemu_opts_reset (&empty_opts);return -EINVAL ; }
@@ -659,7 +659,8 @@ int main(int argc, char **argv)if ((argc - optind) ==1 ) {if (imageOpts) {QemuOpts *qopts =NULL ; - qopts =qemu_opts_parse_noisily (&file_opts, argv[optind], false); + qopts =qemu_opts_parse_list_noisily (&file_opts, argv[optind], + false);if (!qopts) {exit (1 ); }
qemu-nbd.c +3 -3
@@ -706,8 +706,8 @@ int main(int argc, char **argv)break ;case 'l' :if (strstart (optarg,SNAPSHOT_OPT_BASE ,NULL )) { - sn_opts =qemu_opts_parse_noisily (&internal_snapshot_opts, - optarg, false); + sn_opts =qemu_opts_parse_list_noisily (&internal_snapshot_opts, + optarg, false);if (!sn_opts) {error_report ("Failed in parsing snapshot param `%s'" , optarg);
@@ -1117,7 +1117,7 @@ int main(int argc, char **argv)error_report ("--image-opts and -f are mutually exclusive" );exit (EXIT_FAILURE ); } - o =qemu_opts_parse_noisily (&file_opts, opts.srcpath, true); + o =qemu_opts_parse_list_noisily (&file_opts, opts.srcpath, true);if (!o) {qemu_opts_reset (&file_opts);exit (EXIT_FAILURE );
storage-daemon/qemu-storage-daemon.c +2 -2
@@ -283,8 +283,8 @@ static void process_options(int argc, char *argv[], bool pre_init_pass)case OPTION_CHARDEV : {/* TODO This interface is not stable until we QAPIfy it */ -QemuOpts *opts =qemu_opts_parse_noisily (&qemu_chardev_opts, - optarg, true); +QemuOpts *opts =qemu_opts_parse_list_noisily ( + &qemu_chardev_opts, optarg, true);if (opts ==NULL ) {exit (EXIT_FAILURE ); }
system/qdev-monitor.c +1 -1
@@ -1204,7 +1204,7 @@ int qemu_global_option(const char *str)return 0 ; } - opts =qemu_opts_parse_noisily (&qemu_global_opts, str, false); + opts =qemu_opts_parse_list_noisily (&qemu_global_opts, str, false);if (!opts) {return -1 ; }
system/tpm.c +1 -1
@@ -184,7 +184,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optstr)tpm_display_backend_drivers ();exit (EXIT_SUCCESS ); } - opts =qemu_opts_parse_noisily (opts_list, optstr, true); + opts =qemu_opts_parse_list_noisily (opts_list, optstr, true);if (!opts) {return -1 ; }
system/vl.c +3 -3
@@ -3277,7 +3277,7 @@ void qemu_init(int argc, char **argv)error_report ("fsdev support is disabled" );exit (1 ); } -if (!qemu_opts_parse_noisily (olist, optarg, true)) { +if (!qemu_opts_parse_list_noisily (olist, optarg, true)) {exit (1 ); }break ;
@@ -3292,7 +3292,7 @@ void qemu_init(int argc, char **argv)error_report ("virtfs support is disabled" );exit (1 ); } - opts =qemu_opts_parse_noisily (olist, optarg, true); + opts =qemu_opts_parse_list_noisily (olist, optarg, true);if (!opts) {exit (1 ); }
@@ -3644,7 +3644,7 @@ void qemu_init(int argc, char **argv)exit (1 ); } - opts =qemu_opts_parse_noisily (olist, optarg, true); + opts =qemu_opts_parse_list_noisily (olist, optarg, true);if (!opts) {exit (1 ); }
tests/unit/test-replication.c +3 -3
@@ -179,7 +179,7 @@ static BlockBackend *start_primary(void)"file.driver=qcow2,file.file.filename=%s," "file.file.locking=off" , p_local_disk); - opts =qemu_opts_parse_noisily (&qemu_drive_opts, cmdline, false); + opts =qemu_opts_parse_list_noisily (&qemu_drive_opts, cmdline, false);g_free (cmdline); qdict =qemu_opts_to_qdict (opts,NULL );
@@ -295,7 +295,7 @@ static BlockBackend *start_secondary(void) cmdline =g_strdup_printf ("file.filename=%s,driver=qcow2," "file.locking=off" , s_local_disk); - opts =qemu_opts_parse_noisily (&qemu_drive_opts, cmdline, false); + opts =qemu_opts_parse_list_noisily (&qemu_drive_opts, cmdline, false);g_free (cmdline); qdict =qemu_opts_to_qdict (opts,NULL );
@@ -321,7 +321,7 @@ static BlockBackend *start_secondary(void)"file.backing.backing=%s" ,S_ID , s_active_disk, s_hidden_disk , S_LOCAL_DISK_ID); - opts =qemu_opts_parse_noisily (&qemu_drive_opts, cmdline, false); + opts =qemu_opts_parse_list_noisily (&qemu_drive_opts, cmdline, false);g_free (cmdline); qdict =qemu_opts_to_qdict (opts,NULL );
tools/qemu-vnc/qemu-vnc.c +1 -1
@@ -377,7 +377,7 @@ setup_vnc_opts(const char *vnc_addr, const char *tls_creds_dir,g_string_append (opts_str,",non-adaptive=on" ); } - opts =qemu_opts_parse_noisily (olist, opts_str->str, true); + opts =qemu_opts_parse_list_noisily (olist, opts_str->str, true);if (!opts) {return false; }
Signature · 1 line
2.53.0
Re: [PATCH v2 08/11] qemu-option: Use qemu_opts_parse_list_noisily where appropriate
Quoted 8 lines · Fabiano Rosas
Change the callers of
qemu_opts_parse_noisily()that currently take a QemuOptsList pointer to callqemu_opts_parse_list_noisily().This is done to free up the
qemu_opts_parse_noisily()version to be used to take the group name instead.[...]
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 9/11 qemu-option: Change qemu_opts_parse_noisily() to take the group
In reply to Fabiano RosasPass the group name as argument to qemu_opts_parse_noisily() to make it simmetric with qemu_opts_parse().
This change solves the issue of qemu_opts_parse_noisily() crashing on a NULL return from qemu_find_opts(), which can happen when an option is invoked for code in a module that is not loaded.
--- block/monitor/block-hmp-cmds.c | 2 +- blockdev.c | 2 +- chardev/char-hmp-cmds.c | 5 +-- include/qemu/option.h | 2 +- plugins/loader.c | 2 +- qemu-img.c | 3 +- semihosting/config.c | 4 +- system/vl.c | 75 ++++++++++++---------------------- tests/unit/test-char.c | 12 ++---- tests/unit/test-seccomp.c | 6 +-- trace/control.c | 3 +- ui/vnc.c | 3 +- util/qemu-option.c | 12 +++++- 13 files changed, 52 insertions(+), 79 deletions(-)
block/monitor/block-hmp-cmds.c +1 -1
@@ -101,7 +101,7 @@ void hmp_drive_add(MonitorHMP *hmp, const QDict *qdict)return ; } - opts =qemu_opts_parse_noisily (qemu_find_opts ("drive" ), optstr, false); + opts =qemu_opts_parse_noisily ("drive" , optstr, false);if (!opts)return ;
blockdev.c +1 -1
@@ -203,7 +203,7 @@ QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,GLOBAL_STATE_CODE (); - opts =qemu_opts_parse_noisily (qemu_find_opts ("drive" ), optstr, false); + opts =qemu_opts_parse_noisily ("drive" , optstr, false);if (!opts) {return NULL ; }
chardev/char-hmp-cmds.c +2 -3
@@ -83,7 +83,7 @@ void hmp_chardev_add(MonitorHMP *hmp, const QDict *qdict)Error *err =NULL ;QemuOpts *opts; - opts =qemu_opts_parse_noisily (qemu_find_opts ("chardev" ), args, true); + opts =qemu_opts_parse_noisily ("chardev" , args, true);if (opts ==NULL ) {error_setg (&err,"Parsing chardev args failed" ); }else {
@@ -100,8 +100,7 @@ void hmp_chardev_change(MonitorHMP *hmp, const QDict *qdict)Error *err =NULL ;ChardevBackend *backend =NULL ;ChardevReturn *ret =NULL ; -QemuOpts *opts =qemu_opts_parse_noisily (qemu_find_opts ("chardev" ), args, - true); +QemuOpts *opts =qemu_opts_parse_noisily ("chardev" , args, true);if (!opts) {error_setg (&err,"Parsing chardev args failed" ); goto end;
include/qemu/option.h +1 -1
@@ -128,7 +128,7 @@ void qemu_opts_del(QemuOpts *opts);bool qemu_opts_validate (QemuOpts *opts,const QemuOptDesc *desc,Error **errp);bool qemu_opts_do_parse (QemuOpts *opts,const char *params,const char *firstname,Error **errp); -QemuOpts *qemu_opts_parse_noisily (QemuOptsList *list,const char *params, +QemuOpts *qemu_opts_parse_noisily (const char *group,const char *params,bool permit_abbrev);QemuOpts *qemu_opts_parse (const char *group,const char *params,bool permit_abbrev,Error **errp);
plugins/loader.c +1 -1
@@ -147,7 +147,7 @@ void qemu_plugin_opt_parse(const char *optstr, QemuPluginList *head)struct qemu_plugin_parse_arg arg;QemuOpts *opts; - opts =qemu_opts_parse_noisily (qemu_find_opts ("plugin" ), optstr, true); + opts =qemu_opts_parse_noisily ("plugin" , optstr, true);if (opts ==NULL ) {exit (1 ); }
qemu-img.c +1 -2
@@ -358,8 +358,7 @@ static BlockBackend *img_open(bool image_opts,error_report ("--image-opts and --format are mutually exclusive" );return NULL ; } - opts =qemu_opts_parse_noisily (qemu_find_opts ("source" ), - filename, true); + opts =qemu_opts_parse_noisily ("source" , filename, true);if (!opts) {return NULL ; }
semihosting/config.c +2 -2
@@ -134,8 +134,8 @@ void qemu_semihosting_enable(void)int qemu_semihosting_config_options (const char *optstr) { -QemuOptsList *opt_list =qemu_find_opts ("semihosting-config" ); -QemuOpts *opts =qemu_opts_parse_noisily (opt_list, optstr, false); +QemuOpts *opts =qemu_opts_parse_noisily ("semihosting-config" , optstr, + false); semihosting.enabled = true;
system/vl.c +26 -49
219 lines not on this page · raw message
tests/unit/test-char.c +4 -8
@@ -1210,8 +1210,7 @@ static void char_socket_server_test(gconstpointer opaque) config->fd_pass,NULL , true); - opts =qemu_opts_parse_noisily (qemu_find_opts ("chardev" ), - optstr, true); + opts =qemu_opts_parse_noisily ("chardev" , optstr, true);g_assert_nonnull (opts); chr =qemu_chr_new_from_opts (opts,NULL , &error_abort);qemu_opts_del (opts);
@@ -1352,8 +1351,7 @@ static void char_socket_client_dupid_test(gconstpointer opaque) config->reconnect, false); - opts =qemu_opts_parse_noisily (qemu_find_opts ("chardev" ), - optstr, true); + opts =qemu_opts_parse_noisily ("chardev" , optstr, true);g_assert_nonnull (opts); chr1 =qemu_chr_new_from_opts (opts,NULL , &error_abort);g_assert_nonnull (chr1);
@@ -1412,8 +1410,7 @@ static void char_socket_client_test(gconstpointer opaque) config->reconnect, false); - opts =qemu_opts_parse_noisily (qemu_find_opts ("chardev" ), - optstr, true); + opts =qemu_opts_parse_noisily ("chardev" , optstr, true);g_assert_nonnull (opts); chr =qemu_chr_new_from_opts (opts,NULL , &error_abort);qemu_opts_del (opts);
@@ -1544,8 +1541,7 @@ static void char_socket_server_two_clients_test(gconstpointer opaque) false,NULL , true); - opts =qemu_opts_parse_noisily (qemu_find_opts ("chardev" ), - optstr, true); + opts =qemu_opts_parse_noisily ("chardev" , optstr, true);g_assert_nonnull (opts); chr =qemu_chr_new_from_opts (opts,NULL , &error_abort);qemu_opts_del (opts);
tests/unit/test-seccomp.c +1 -5
@@ -31,15 +31,11 @@ static void test_seccomp_helper(const char *args, bool killed, int errnum, int (*doit)(void)) { if (g_test_subprocess()) { - QemuOptsList *olist; QemuOpts *opts;int ret;module_call_init (MODULE_INIT_OPTS ); - olist =qemu_find_opts ("sandbox" ); -g_assert (olist !=NULL ); - - opts =qemu_opts_parse_noisily (olist, args, true); + opts =qemu_opts_parse_noisily ("sandbox" , args, true);g_assert (opts !=NULL );parse_sandbox (NULL , opts, &error_abort);
trace/control.c +1 -2
@@ -288,8 +288,7 @@ bool trace_init_backends(void)void trace_opt_parse (const char *optstr) { -QemuOpts *opts =qemu_opts_parse_noisily (qemu_find_opts ("trace" ), - optstr, true); +QemuOpts *opts =qemu_opts_parse_noisily ("trace" , optstr, true);if (!opts) {exit (1 ); }
ui/vnc.c +1 -2
@@ -4324,8 +4324,7 @@ static char *vnc_auto_assign_id(QemuOpts *opts)void vnc_parse (const char *str) { -QemuOptsList *olist =qemu_find_opts ("vnc" ); -QemuOpts *opts =qemu_opts_parse_noisily (olist, str, !is_help_option (str)); +QemuOpts *opts =qemu_opts_parse_noisily ("vnc" , str, !is_help_option (str));if (!opts) {exit (1 );
util/qemu-option.c +10 -2
@@ -956,16 +956,24 @@ QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params, }/** -* Create a QemuOpts in @list and with options parsed from @params. +* Find the @group and create a QemuOpts with options parsed from @params. * If @permit_abbrev, the first key=value in @params may omit key=, * and is treated as if key was @list->implied_opt_name. * Report errors with error_report_err(). This is inappropriate in * QMP context. Do not use this function there! * Return the new QemuOpts on success, null pointer on error. */ -QemuOpts *qemu_opts_parse_noisily (QemuOptsList *list,const char *params, +QemuOpts *qemu_opts_parse_noisily (const char *group,const char *params,bool permit_abbrev) { +Error *err =NULL ; +QemuOptsList *list =qemu_find_opts_err (group, &err); + +if (!list) { +error_report_err (err); +return NULL ; + } +return qemu_opts_parse_list_noisily (list, params, permit_abbrev); }
Signature · 1 line
2.53.0
Re: [PATCH v2 09/11] qemu-option: Change qemu_opts_parse_noisily() to take the group
Quoted 8 lines · Fabiano Rosas
Pass the group name as argument to
qemu_opts_parse_noisily()to make it simmetric withqemu_opts_parse().This change solves the issue of
qemu_opts_parse_noisily()crashing on a NULL return fromqemu_find_opts(), which can happen when an option is invoked for code in a module that is not loaded.[...]
Signature · 1 line
Marc-André Lureau <[email protected]>
Re: [PATCH v2 09/11] qemu-option: Change qemu_opts_parse_noisily() to take the group
In reply to Fabiano RosasQuoted 2 lines · Fabiano Rosas
Pass the group name as argument to
qemu_opts_parse_noisily()to make it simmetric withqemu_opts_parse().
symmetric
Quoted 5 lines
This change solves the issue of
qemu_opts_parse_noisily()crashing on a NULL return fromqemu_find_opts(), which can happen when an option is invoked for code in a module that is not loaded.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org
PATCH v2 10/11 qemu-option: Check for NULL list at qemu_opts_parse()
In reply to Fabiano RosasNow that qemu_opts_parse_noisily() is protected against NULL list, do the same for the non noisy version.
--- util/qemu-option.c | 4 ++++ 1 file changed, 4 insertions(+)
util/qemu-option.c +4 -0
@@ -939,6 +939,10 @@ QemuOpts *qemu_opts_parse(const char *group, const char *params, {QemuOptsList *list =qemu_find_opts_err (group, errp); +if (!list) { +return NULL ; + } +return qemu_opts_parse_list (list, params, permit_abbrev, errp); }
Signature · 1 line
2.53.0
Re: [PATCH v2 10/11] qemu-option: Check for NULL list at qemu_opts_parse()
Quoted 2 lines · Fabiano Rosas
Now that
qemu_opts_parse_noisily()is protected against NULL list, do the same for the non noisy version.
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 11/11 qemu-option: Remove a few instances of noisily parsing
In reply to Fabiano RosasWith the removal of the support for short-form flags, the only other source of "noise" in the qemu_parse_*noisily() functions aside from errors is the printing of the help text.
Therefore, the only difference from the _noisily versions to the normal ones is this block:
if (qemu_opt_has_help_opt(opts) && !opts_accepts_any(list)) {
qemu_opts_print_help(list, true);
return NULL;
}Stop calling qemu_parse_*noisily() in any case where it's certain that opts_accepts_any(list) returns true, i.e. when list->desc is empty.
This creates some instances of the pattern: error_report -> exit(1). Use &error_fatal instead.
--- block/monitor/block-hmp-cmds.c | 4 ++-- include/system/tpm.h | 3 ++- monitor/hmp.c | 4 +++- net/net.c | 4 +--- plugins/loader.c | 5 +--- qemu-img.c | 5 +++- qemu-io-cmds.c | 2 +- qemu-io.c | 7 ++---- system/tpm.c | 8 +++---- system/vl.c | 42 +++++++++++++++------------------- tests/unit/test-replication.c | 17 +++++++++++--- util/qemu-option.c | 3 +++ 12 files changed, 55 insertions(+), 49 deletions(-)
block/monitor/block-hmp-cmds.c +2 -2
@@ -63,9 +63,9 @@ static void hmp_drive_add_node(MonitorHMP *hmp, const char *optstr)QDict *qdict;Error *err =NULL ; - opts =qemu_opts_parse_list_noisily (&qemu_drive_opts, optstr, false); + opts =qemu_opts_parse_list (&qemu_drive_opts, optstr, false, &err);if (!opts) { -return ; + goto out; } qdict =qemu_opts_to_qdict (opts,NULL );
include/system/tpm.h +2 -1
@@ -17,7 +17,8 @@#ifdef CONFIG_TPM -int tpm_config_parse (QemuOptsList *opts_list,const char *optstr); +bool tpm_config_parse (QemuOptsList *opts_list,const char *optstr, +Error **errp);int tpm_init (void );void tpm_cleanup (void );
monitor/hmp.c +3 -1
@@ -883,6 +883,7 @@ static QDict *monitor_parse_arguments(MonitorHMP *mon, {QemuOptsList *opts_list;QemuOpts *opts; +Error *err =NULL ; opts_list =qemu_find_opts (key);if (!opts_list || opts_list->desc->name) {
@@ -897,8 +898,9 @@ static QDict *monitor_parse_arguments(MonitorHMP *mon,if (get_str (buf,sizeof (buf), &p) <0 ) { goto fail; } - opts =qemu_opts_parse_list_noisily (opts_list, buf, true); + opts =qemu_opts_parse_list (opts_list, buf, true, &err);if (!opts) { +error_report_err (err); goto fail; }qemu_opts_to_qdict (opts, qdict);
net/net.c +1 -3
@@ -2029,9 +2029,7 @@ void netdev_parse_modern(const char *optstr)void net_client_parse (QemuOptsList *opts_list,const char *optstr) { -if (!qemu_opts_parse_list_noisily (opts_list, optstr, true)) { -exit (1 ); - } +qemu_opts_parse_list (opts_list, optstr, true, &error_fatal); }/* From FreeBSD */
plugins/loader.c +1 -4
@@ -147,10 +147,7 @@ void qemu_plugin_opt_parse(const char *optstr, QemuPluginList *head)struct qemu_plugin_parse_arg arg;QemuOpts *opts; - opts =qemu_opts_parse_noisily ("plugin" , optstr, true); -if (opts ==NULL ) { -exit (1 ); - } + opts =qemu_opts_parse ("plugin" , optstr, true, &error_fatal); arg.head = head; arg.curr =NULL ;qemu_opt_foreach (opts, plugin_add, &arg, &error_fatal);
qemu-img.c +4 -1
@@ -354,12 +354,15 @@ static BlockBackend *img_open(bool image_opts,BlockBackend *blk;if (image_opts) {QemuOpts *opts; +Error *err =NULL ; +if (fmt) {error_report ("--image-opts and --format are mutually exclusive" );return NULL ; } - opts =qemu_opts_parse_noisily ("source" , filename, true); + opts =qemu_opts_parse ("source" , filename, true, &err);if (!opts) { +error_report_err (err);return NULL ; } blk = img_open_opts(filename, opts, flags, writethrough, quiet,
qemu-io-cmds.c +1 -1
@@ -2540,7 +2540,7 @@ static int reopen_f(BlockBackend *blk, int argc, char **argv, Error **errp) has_cache_option = true;break ;case 'o' : -if (!qemu_opts_parse_list_noisily (&reopen_opts, optarg,0 )) { +if (!qemu_opts_parse_list (&reopen_opts, optarg,0 , errp)) {qemu_opts_reset (&reopen_opts);return -EINVAL ; }
qemu-io.c +2 -5
@@ -659,11 +659,8 @@ int main(int argc, char **argv)if ((argc - optind) ==1 ) {if (imageOpts) {QemuOpts *qopts =NULL ; - qopts =qemu_opts_parse_list_noisily (&file_opts, argv[optind], - false); -if (!qopts) { -exit (1 ); - } + qopts =qemu_opts_parse_list (&file_opts, argv[optind], false, + &error_fatal); opts =qemu_opts_to_qdict (qopts,NULL );if (openfile (NULL , flags, writethrough, force_share, opts)) {exit (1 );
system/tpm.c +4 -4
@@ -176,7 +176,7 @@ int tpm_init(void)* Parse the TPM configuration options. * To display all available TPM backends the user may use '-tpmdev help' */ -int tpm_config_parse (QemuOptsList *opts_list,const char *optstr) +bool tpm_config_parse (QemuOptsList *opts_list,const char *optstr,Error **errp) {QemuOpts *opts;
@@ -184,11 +184,11 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optstr)tpm_display_backend_drivers ();exit (EXIT_SUCCESS ); } - opts =qemu_opts_parse_list_noisily (opts_list, optstr, true); + opts =qemu_opts_parse_list (opts_list, optstr, true, errp);if (!opts) { -return -1 ; +return false; } -return 0 ; +return true; }/*
system/vl.c +18 -24
98 lines not on this page · raw message
tests/unit/test-replication.c +14 -3
@@ -174,12 +174,16 @@ static BlockBackend *start_primary(void)QemuOpts *opts;QDict *qdict;char *cmdline; +Error *err =NULL ; cmdline =g_strdup_printf ("driver=replication,mode=primary,node-name=xxx," "file.driver=qcow2,file.file.filename=%s," "file.file.locking=off" , p_local_disk); - opts =qemu_opts_parse_list_noisily (&qemu_drive_opts, cmdline, false); + opts =qemu_opts_parse_list (&qemu_drive_opts, cmdline, false, &err); +if (!opts) { +error_report_err (err); + }g_free (cmdline); qdict =qemu_opts_to_qdict (opts,NULL );
@@ -290,12 +294,16 @@ static BlockBackend *start_secondary(void)QDict *qdict;BlockBackend *blk;char *cmdline; +Error *err =NULL ;/* add s_local_disk and forge S_LOCAL_DISK_ID */ cmdline =g_strdup_printf ("file.filename=%s,driver=qcow2," "file.locking=off" , s_local_disk); - opts =qemu_opts_parse_list_noisily (&qemu_drive_opts, cmdline, false); + opts =qemu_opts_parse_list (&qemu_drive_opts, cmdline, false, &err); +if (!opts) { +error_report_err (err); + }g_free (cmdline); qdict =qemu_opts_to_qdict (opts,NULL );
@@ -321,7 +329,10 @@ static BlockBackend *start_secondary(void)"file.backing.backing=%s" ,S_ID , s_active_disk, s_hidden_disk , S_LOCAL_DISK_ID); - opts =qemu_opts_parse_list_noisily (&qemu_drive_opts, cmdline, false); + opts =qemu_opts_parse_list (&qemu_drive_opts, cmdline, false, &err); +if (!opts) { +error_report_err (err); + }g_free (cmdline); qdict =qemu_opts_to_qdict (opts,NULL );
util/qemu-option.c +3 -0
@@ -995,6 +995,9 @@ QemuOpts *qemu_opts_parse_list_noisily(QemuOptsList *list, const char *params,Error *err =NULL ;QemuOpts *opts; +assert (g_str_equal ("drive" , list->name) || + !opts_accepts_any (list)); + opts =opts_parse (list, params, permit_abbrev, &err);if (!opts) {error_report_err (err);
Signature · 1 line
2.53.0
Re: [PATCH v2 11/11] qemu-option: Remove a few instances of noisily parsing
Quoted 8 lines · Fabiano Rosas
With the removal of the support for short-form flags, the only other source of "noise" in the qemu_parse_*noisily() functions aside from errors is the printing of the help text.
Therefore, the only difference from the
_noisilyversions to the normal ones is this block:[...]
Signature · 1 line
Marc-André Lureau <[email protected]>