From: Fabiano Rosas <farosas@suse.de>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Michael Roth <michael.roth@amd.com>
Subject: Re: [RFC PATCH 07/14] qemu-options: Consolidate qemu_opts_parse* functions
Date: Fri, 25 Sep 2026 09:21:20 -0300 [thread overview]
Message-ID: <87qzih8qtb.fsf@suse.de> (raw)
In-Reply-To: <arZLO5A3S5A_2yE3@redhat.com>
Daniel P. Berrangé <berrange@redhat.com> writes:
> On Fri, Sep 18, 2026 at 07:29:54PM -0300, Fabiano Rosas wrote:
>> The qemu_opts_parse, qemu_opts_parse_list and qemu_opts_parse_noisily
>> functions all call opts_parse(), they can reuse code.
>>
>> Consolidate them at qemu_opts_parse_list(). Use the presence of the
>> Error pointer to determine whether the caller wants to be noisy: if
>> there is an Error pointer, then use it, otherwise print the message.
>>
>> This makes the code more opaque, so keep the qemu_opts_parse and
>> qemu_opts_parse_noisily functions as wrappers to make sure the intent
>> at the callers is still clear.
>
> It is also somewhat differnt from the normal semantics in QEMU.
>
> The behaviour of passing NULL for an "Error **errp" parameter
> indicates that the errors are to be ignored/discarded.
>
> This patch introduces atypical semantics, that the errors must
> be printed, so I'm not entirely convinced this patch is a win.
>
I understand. This is the main reason why this series is RFC. I could
exchange the implicit "pass NULL to mean noisily" with an explicit
parameter 'bool noisily'.
>>
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>> ---
>> tests/unit/test-opts-visitor.c | 2 +-
>> util/qemu-option.c | 32 ++++++++++++++++++--------------
>> 2 files changed, 19 insertions(+), 15 deletions(-)
>
>> diff --git a/util/qemu-option.c b/util/qemu-option.c
>> index bb38d305c9..c8e552823b 100644
>> --- a/util/qemu-option.c
>> +++ b/util/qemu-option.c
>> @@ -938,7 +938,23 @@ QemuOpts *qemu_opts_parse(const char *group, const char *params,
>> QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params,
>> bool permit_abbrev, Error **errp)
>> {
>> - return opts_parse(list, params, permit_abbrev, false, false, errp);
>> + bool noisily = !errp;
>> + QemuOpts *opts = NULL;
>> +
>> + if (noisily) {
>> + Error *err = NULL;
>> + bool help_wanted = !opts_accepts_any(list);
>> +
>> + opts = opts_parse(list, params, permit_abbrev, true, help_wanted, &err);
>> + if (!opts && err) {
>> + error_report_err(err);
>> + }
>> +
>> + } else {
>> + opts = opts_parse(list, params, permit_abbrev, false, false, errp);
>> + }
>> +
>> + return opts;
>> }
>>
>> /**
>> @@ -952,19 +968,7 @@ QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params,
>> QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
>> bool permit_abbrev)
>> {
>> - Error *err = NULL;
>> - QemuOpts *opts;
>> - bool help_wanted = !opts_accepts_any(list);
>> -
>> - opts = opts_parse(list, params, permit_abbrev, true, help_wanted, &err);
>> - if (!opts) {
>> - if (help_wanted) {
>> - assert(!err);
>> - } else {
>> - error_report_err(err);
>> - }
>> - }
>> - return opts;
>> + return qemu_opts_parse_list(list, params, permit_abbrev, NULL);
>> }
>>
>> static bool qemu_opts_from_qdict_entry(QemuOpts *opts,
>> --
>> 2.53.0
>>
>>
>
> With regards,
> Daniel
next prev parent reply other threads:[~2026-09-25 12:21 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 22:29 [RFC PATCH 00/14] qemu-options: Remove some complexity Fabiano Rosas
2026-09-18 22:29 ` [RFC PATCH 01/14] meson: Fix meson suites invocation from make check Fabiano Rosas
2026-09-25 12:14 ` Fabiano Rosas
2026-09-18 22:29 ` [RFC PATCH 02/14] qemu-options: Use g_autofree when calling get_opt_name_value() Fabiano Rosas
2026-09-25 10:05 ` Daniel P. Berrangé
2026-09-18 22:29 ` [RFC PATCH 03/14] qemu-options: Consolidate branches in opts_parse Fabiano Rosas
2026-09-25 10:07 ` Daniel P. Berrangé
2026-09-18 22:29 ` [RFC PATCH 04/14] qemu-options: Add qemu_opts_parse_list Fabiano Rosas
2026-09-25 10:14 ` Daniel P. Berrangé
2026-09-18 22:29 ` [RFC PATCH 05/14] qemu-options: Change qemu_parse_opts() to take the group name Fabiano Rosas
2026-09-25 10:11 ` Daniel P. Berrangé
2026-09-18 22:29 ` [RFC PATCH 06/14] qemu-options: Call qemu_opts_print_help() one level down Fabiano Rosas
2026-09-25 10:15 ` Daniel P. Berrangé
2026-09-18 22:29 ` [RFC PATCH 07/14] qemu-options: Consolidate qemu_opts_parse* functions Fabiano Rosas
2026-09-25 10:21 ` Daniel P. Berrangé
2026-09-25 12:21 ` Fabiano Rosas [this message]
2026-09-28 10:41 ` Daniel P. Berrangé
2026-09-28 14:52 ` Fabiano Rosas
2026-09-18 22:29 ` [RFC PATCH 08/14] qemu-options: Add qemu_opts_parse_list_noisily Fabiano Rosas
2026-09-25 10:25 ` Daniel P. Berrangé
2026-09-18 22:29 ` [RFC PATCH 09/14] qemu-options: Change qemu_opts_parse_noisily() to take the group Fabiano Rosas
2026-09-21 13:51 ` Stefan Hajnoczi
2026-09-25 10:27 ` Daniel P. Berrangé
2026-09-18 22:29 ` [RFC PATCH 10/14] qemu-options: Check for NULL list at qemu_opts_parse() Fabiano Rosas
2026-09-25 10:28 ` Daniel P. Berrangé
2026-09-18 22:29 ` [RFC PATCH 11/14] qemu-options: pass an Error into get_opt_name_value Fabiano Rosas
2026-09-25 10:35 ` Daniel P. Berrangé
2026-09-18 22:29 ` [RFC PATCH 12/14] qemu-options: merge warn and help flags Fabiano Rosas
2026-09-18 22:30 ` [RFC PATCH 13/14] qemu-options: Further simplify qemu_opts_parse_list() Fabiano Rosas
2026-09-18 22:30 ` [RFC PATCH 14/14] qemu-options: Remove opts_parse() Fabiano Rosas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87qzih8qtb.fsf@suse.de \
--to=farosas@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=michael.roth@amd.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.