From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsIDU-0000uM-Gh for qemu-devel@nongnu.org; Tue, 12 May 2015 17:59:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YsIDT-0003ww-6a for qemu-devel@nongnu.org; Tue, 12 May 2015 17:59:56 -0400 Message-ID: <555277D3.5080507@redhat.com> Date: Tue, 12 May 2015 15:59:47 -0600 From: Eric Blake MIME-Version: 1.0 References: <1431105726-3682-1-git-send-email-kwolf@redhat.com> <1431105726-3682-22-git-send-email-kwolf@redhat.com> In-Reply-To: <1431105726-3682-22-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5l0EGeS69TFM83NDCwGXBusdn2cnHsvUi" Subject: Re: [Qemu-devel] [PATCH 21/34] block: Consider all block layer options in append_open_options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5l0EGeS69TFM83NDCwGXBusdn2cnHsvUi Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 26 ++++++++++++++++++-------- > 1 file changed, 18 insertions(+), 8 deletions(-) >=20 > =20 > for (entry =3D qdict_first(bs->options); entry; > entry =3D 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 =3D true; > + /* Only take options for this level */ > + if (strchr(qdict_entry_key(entry), '.')) { > + continue; > } > + > + /* And exclude all non-driver-specific options */ > + for (desc =3D 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"= =2E 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 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --5l0EGeS69TFM83NDCwGXBusdn2cnHsvUi Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVUnfUAAoJEKeha0olJ0NqZcIH/ilTQRsChAUhDcfbgBgcpl8F Q5qVhuYtbTkRhcC6oqKbS9A8eCUyUgnOAo5xjZa3aDMubmAWpodEnI0IFae2ewdy daTPJHs7e+LzNbSTu62Elp/W0CNft2BUpJwyBwNwjLn7DmKLaZbFv9wl8/Lhk6Uv MlNa4ffE1zxQh8CCyV2dcXc0xvxxpz4/xsBqs4W2OxymDxoD2hze8RkEmlwsuyv9 VwsQVoRzrs5G3lblLzehGV57AIo2HQU+j/4PL5UKZaj5hKhu8hNrvKMMvVobZBHG LJzTTvBLaiI4s7HWtbhbolf14yjXZMPYT0xVHhznyrBqGOSottXLcycCIMMpGTE= =RVDZ -----END PGP SIGNATURE----- --5l0EGeS69TFM83NDCwGXBusdn2cnHsvUi--