From: Laszlo Ersek <lersek@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: kwolf@redhat.com, akong@redhat.com, stefanha@redhat.com,
armbru@redhat.com, mjt@tls.msk.ru, qemu-devel@nongnu.org,
mreitz@redhat.com, aliguori@amazon.com, pbonzini@redhat.com,
lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] QemuOpts: introduce qemu_find_opts_singleton
Date: Mon, 10 Feb 2014 18:00:39 +0100 [thread overview]
Message-ID: <52F905B7.5030207@redhat.com> (raw)
In-Reply-To: <1391674564-3783-2-git-send-email-imammedo@redhat.com>
comments below
On 02/06/14 09:16, Igor Mammedov wrote:
> From: Paolo Bonzini <pbonzini@redhat.com>
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> include/qemu/config-file.h | 2 ++
> util/qemu-config.c | 14 ++++++++++++++
> vl.c | 11 +----------
> 3 files changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h
> index dbd97c4..d4ba20e 100644
> --- a/include/qemu/config-file.h
> +++ b/include/qemu/config-file.h
> @@ -8,6 +8,8 @@
>
> QemuOptsList *qemu_find_opts(const char *group);
> QemuOptsList *qemu_find_opts_err(const char *group, Error **errp);
> +QemuOpts *qemu_find_opts_singleton(const char *group);
> +
> void qemu_add_opts(QemuOptsList *list);
> void qemu_add_drive_opts(QemuOptsList *list);
> int qemu_set_option(const char *str);
> diff --git a/util/qemu-config.c b/util/qemu-config.c
> index 9298f55..9dfacbc 100644
> --- a/util/qemu-config.c
> +++ b/util/qemu-config.c
> @@ -39,6 +39,20 @@ QemuOptsList *qemu_find_opts(const char *group)
> return ret;
> }
>
> +QemuOpts *qemu_find_opts_singleton(const char *group)
> +{
> + QemuOptsList *list;
> + QemuOpts *opts;
> +
> + list = qemu_find_opts(group);
> + assert(list);
> + opts = qemu_opts_find(list, NULL);
> + if (!opts) {
> + opts = qemu_opts_create(list, NULL, 0, &error_abort);
> + }
> + return opts;
> +}
First of all, the commit message body is empty, and the subject line
doesn't really say much, plus there are no comments, so I have no clue
what we're trying to implement here *in general*.
For example, if you look into qemu_opts_create(), you'll see that when
(id==NULL), then you don't actually need the
qemu_opts_find(list, NULL)
call, because qemu_opts_create() calls that itself anyway. Of course,
this behavior *also* depends on merge_lists being "true", but in case of
"machine", that *is* a given.
Hence a specification for the function would help deciding if we can
take merge_lists for granted, or if we want something more general. In
the former case, the code above is unnecessarily pessimistic.
(Basically the qemu_find_opts_singleton() should be a *very* thin
wrapper around qemu_opts_create(), because the latter already has this
"O_CREAT without O_EXCL" semantics.)
> +
> static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
> {
> CommandLineParameterInfoList *param_list = NULL, *entry;
> diff --git a/vl.c b/vl.c
> index 383be1b..7f2595c 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -539,16 +539,7 @@ static QemuOptsList qemu_msg_opts = {
> */
> QemuOpts *qemu_get_machine_opts(void)
> {
> - QemuOptsList *list;
> - QemuOpts *opts;
> -
> - list = qemu_find_opts("machine");
> - assert(list);
> - opts = qemu_opts_find(list, NULL);
> - if (!opts) {
> - opts = qemu_opts_create(list, NULL, 0, &error_abort);
> - }
> - return opts;
> + return qemu_find_opts_singleton("machine");
> }
>
> const char *qemu_get_vm_name(void)
>
I also kinda hate that "error_abort" -- while used in several
option-specific parser functions (balloon_parse, virtcon_parse,
QEMU_OPTION_virtfs, QEMU_OPTION_virtfs_synth) -- now makes it into a
generic-looking options function. qemu_find_opts_singleton() should take
an errp.
Anyway I don't care enough to insist on a respin.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
next prev parent reply other threads:[~2014-02-10 17:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 8:16 [Qemu-devel] [PATCH 0/2] convert -m to QemuOpts Igor Mammedov
2014-02-06 8:16 ` [Qemu-devel] [PATCH 1/2] QemuOpts: introduce qemu_find_opts_singleton Igor Mammedov
2014-02-10 17:00 ` Laszlo Ersek [this message]
2014-02-11 11:52 ` Igor Mammedov
2014-02-06 8:16 ` [Qemu-devel] [PATCH 2/2] vl: convert -m to QemuOpts Igor Mammedov
2014-02-10 17:38 ` Laszlo Ersek
2014-02-13 12:47 ` Igor Mammedov
2014-02-26 13:29 ` Paolo Bonzini
2014-02-26 13:42 ` Laszlo Ersek
2014-02-26 13:45 ` Paolo Bonzini
2014-02-26 13:50 ` Igor Mammedov
2014-02-26 14:00 ` Paolo Bonzini
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=52F905B7.5030207@redhat.com \
--to=lersek@redhat.com \
--cc=akong@redhat.com \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=imammedo@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).