[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH 21/34] block: Consider all block la
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH 21/34] block: Consider all block layer options in append_open_options |
Date: |
Tue, 12 May 2015 15:59:47 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
On 05/08/2015 11:21 AM, Kevin Wolf wrote:
> The code already special-cased "node-name", which is currently the only
> option passed in the QDict that isn't driver-specific. Generalise the
> code to take all general block layer options into consideration.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block.c | 26 ++++++++++++++++++--------
> 1 file changed, 18 insertions(+), 8 deletions(-)
>
>
> for (entry = qdict_first(bs->options); entry;
> entry = qdict_next(bs->options, entry))
> {
> - /* Only take options for this level and exclude all
> non-driver-specific
> - * options */
> - if (!strchr(qdict_entry_key(entry), '.') &&
> - strcmp(qdict_entry_key(entry), "node-name"))
> - {
> - qobject_incref(qdict_entry_value(entry));
> - qdict_put_obj(d, qdict_entry_key(entry),
> qdict_entry_value(entry));
> - found_any = true;
> + /* Only take options for this level */
> + if (strchr(qdict_entry_key(entry), '.')) {
> + continue;
> }
> +
> + /* And exclude all non-driver-specific options */
> + for (desc = bdrv_runtime_opts.desc; desc->name; desc++) {
> + if (!strcmp(qdict_entry_key(entry), desc->name)) {
> + break;
> + }
> + }
> + if (desc->name) {
> + continue;
If only C had Java's "continue label" notation, which makes it cleaner
to jump out of nested loops :) At least you didn't do a backwards "goto".
Looks like it will be O(n^2), but since our set of recognized option
names is still rather small, I don't think the performance hit will
reach a point where scaling matters. If it does, we could switch to
binary search for O(n log n) or hash table lookups for O(n) amortized
cost, at the cost of code complexity, at a future date.
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-block] [Qemu-devel] [PATCH 20/34] qcow2: Support updating driver-specific options in reopen, (continued)
- [Qemu-block] [PATCH 19/34] qcow2: Make qcow2_update_options() suitable for transactions, Kevin Wolf, 2015/05/08
- [Qemu-block] [PATCH 17/34] qcow2: Leave s unchanged on qcow2_update_options() failure, Kevin Wolf, 2015/05/08
- [Qemu-block] [PATCH 21/34] block: Consider all block layer options in append_open_options, Kevin Wolf, 2015/05/08
- [Qemu-block] [PATCH 22/34] block: Exclude nested options only for children in append_open_options(), Kevin Wolf, 2015/05/08
- [Qemu-block] [PATCH 23/34] block: Pass driver-specific options to .bdrv_refresh_filename(), Kevin Wolf, 2015/05/08
- [Qemu-block] [PATCH 25/34] block: Allow specifying child options in reopen, Kevin Wolf, 2015/05/08
- [Qemu-block] [PATCH 26/34] block: reopen: Document option precedence and refactor accordingly, Kevin Wolf, 2015/05/08