From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org, armbru@redhat.com
Subject: Re: [PATCH] block: Error out on image creation with conflicting size options
Date: Tue, 26 Nov 2019 20:58:45 +0100 [thread overview]
Message-ID: <871rtuo1e2.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <a42f2815-479c-e74a-3199-8a96c7a145f1@redhat.com> (Eric Blake's message of "Tue, 26 Nov 2019 10:39:14 -0600")
Eric Blake <eblake@redhat.com> writes:
> On 11/26/19 10:26 AM, Kevin Wolf wrote:
>
>>> Actually, your patch fails to diagnose:
>>>
>>> $ qemu-img create -o size=1m,size=2m -f qcow2 x.qcow2
>>> Formatting 'x.qcow2', fmt=qcow2 size=2097152 cluster_size=65536
>>> lazy_refcounts=off refcount_bits=16
>>>
>>> so you may want to enhance this patch to also catch the case of -o size used
>>> more than once.
Please don't. Let me explain.
>> Hm... Isn't this something that QemuOpts should already catch? Or do we
>> have callers that actually expect the same option specified multiple
>> times?
>
> QemuOpts is horrible. It allows duplication, and leaves it up to the
> client what to do about it. Some clients use the duplication to
> collect multiple arguments (such as specifying more than one cpu),
> some callers treat duplication by honoring only the FIRST option
> specified (and ignoring later uses - I find this ugly), and yet other
> callers treat duplication by honoring only the LAST option specified.
QemuOpts has always permitted multiple keys, last one wins.
key=1,key=2,key=3 means key=3. Permits things like overriding settings
read from a configuration file on the command line.
The straightforward way to use QemuOpts lets the last one win:
qemu_opt_set() & friends insert at the end of the tail queue,
qemu_opt_find() searches backwards for a match.
Its storing of duplicates may have been just an implementation artifact
initially, but then some "clever" uses were invented. These work by
iterating over all QemuOpts parameters with qemu_opt_foreach(), or over
all parameters of a certain name with qemu_opt_iter_init() and
qemu_opt_iter_next().
>>
>> Somehow I'm almost sure that Markus will know an example...
>
> Probably of all three (ab)uses of QemuOpt duplication.
What the iterating ones all do is anybody's guess.
A common use is collecting all values. This presses key repetition into
list service: key=1,key=2,key=3 is interpreted like key: [1, 2, 3].
Abusing iteration to honor the first one instead of the last one would
be disgusting. I'm not aware of such a user, but I'm also not betting
my own money on absence of such abuse.
Needless to say, the peculiarities of QemuOpts are all ABI by now.
Doesn't mean we cannot change them, only that changes need to be
deliberate and careful.
>> But anyway, I figure the same problem exists for almost all options.
It's a feature, not a problem :)
prev parent reply other threads:[~2019-11-26 19:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-26 15:48 [PATCH] block: Error out on image creation with conflicting size options Kevin Wolf
2019-11-26 15:54 ` Eric Blake
2019-11-26 15:56 ` Eric Blake
2019-11-26 16:26 ` Kevin Wolf
2019-11-26 16:39 ` Eric Blake
2019-11-26 19:58 ` Markus Armbruster [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=871rtuo1e2.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--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.