From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] block: Catch simultaneous usage of options and their aliases
Date: Thu, 18 Sep 2014 16:34:00 +0200 [thread overview]
Message-ID: <20140918143400.GA28152@noname.redhat.com> (raw)
In-Reply-To: <87y4thm3a4.fsf@blackfin.pond.sub.org>
Am 18.09.2014 um 16:06 hat Markus Armbruster geschrieben:
> Eric Blake <eblake@redhat.com> writes:
>
> > On 09/18/2014 03:57 AM, Kevin Wolf wrote:
> >> While thinking about precedence of conflicting block device options from
> >> different sources, I noticed that you can specify both an option and its
> >> legacy alias at the same time (e.g. readonly=on,read-only=off). Rather
> >> than specifying the order of precedence, we should simply forbid such
> >> combinations.
> >>
> >> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> >> ---
> >> blockdev.c | 46 +++++++++++++++++++++++++++++++---------------
> >> tests/qemu-iotests/051 | 23 +++++++++++++++++++++++
> >> tests/qemu-iotests/051.out | 45 +++++++++++++++++++++++++++++++++++++++++++++
> >> 3 files changed, 99 insertions(+), 15 deletions(-)
> >
> > Reviewed-by: Eric Blake <eblake@redhat.com>
> >
> >>
> >> -static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to)
> >> +static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
> >> + Error **errp)
> >> {
> >> const char *value;
> >>
> >> + if (*errp) {
> >> + return;
> >> + }
> >
> > Not the most typical usage, so it might be worth a comment that this
> > function can be called with errp already set. But since it's static,
> > it's not too hard to figure out as-is.
>
> The problem with this usage is it doesn't combine well with the common
> usage. That's why I purged it from the code back in May:
Oh. I didn't know that it was gone there.
> But this code is annoyingly repetitive even before the patch! Here's
> what I'd do:
>
> static struct {
> const char *from, *to;
> } rename[] = {
> { "iops", "throttling.iops-total" },
> { "iops_rd", "throttling.iops-read" },
> { "iops_wr", "throttling.iops-write" },
> { "bps", "throttling.bps-total" },
> { "bps_rd", "throttling.bps-read" },
> { "bps_wr", "throttling.bps-write" },
> { "iops_max", "throttling.iops-total-max" },
> { "iops_rd_max", "throttling.iops-read-max" },
> { "iops_wr_max", "throttling.iops-write-max" },
> { "bps_max", "throttling.bps-total-max" },
> { "bps_rd_max", "throttling.bps-read-max" },
> { "bps_wr_max", "throttling.bps-write-max" },
> { "iops_size", "throttling.iops-size" },
> { "readonly", "read-only" },
> };
> Error *local_err = NULL;
> int i;
>
> for (i = 0; i < ARRAY_SIZE(rename); i++) {
> qemu_opt_rename(all_opts, rename[i].from, rename[i].to,
> &local_err);
> if (local_err) {
> error_report("%s", error_get_pretty(local_err));
> error_free(local_err);
> return NULL;
> }
> }
Okay, fair enough.
Kevin
prev parent reply other threads:[~2014-09-18 15:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 9:57 [Qemu-devel] [PATCH] block: Catch simultaneous usage of options and their aliases Kevin Wolf
2014-09-18 12:30 ` Eric Blake
2014-09-18 14:06 ` Markus Armbruster
2014-09-18 14:34 ` Kevin Wolf [this message]
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=20140918143400.GA28152@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@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).