From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWTFQ-0007ss-65 for qemu-devel@nongnu.org; Tue, 23 Sep 2014 12:47:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWTFL-0001AA-8J for qemu-devel@nongnu.org; Tue, 23 Sep 2014 12:47:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23068) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWTFL-00018p-0x for qemu-devel@nongnu.org; Tue, 23 Sep 2014 12:47:23 -0400 Message-ID: <5421A412.2080505@redhat.com> Date: Tue, 23 Sep 2014 10:47:14 -0600 From: Eric Blake MIME-Version: 1.0 References: <1411477988-10678-1-git-send-email-junmuzi@gmail.com> In-Reply-To: <1411477988-10678-1-git-send-email-junmuzi@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PkXQh5g1tjaLoaHcNJEIdb2gKdJjlrbMI" Subject: Re: [Qemu-devel] [PATCH] Modify qemu_opt_rename to realize renaming all items in opts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jun Li , qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, juli@redhat.com, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PkXQh5g1tjaLoaHcNJEIdb2gKdJjlrbMI Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/23/2014 07:13 AM, Jun Li wrote: > Add realization of rename all items in opts for qemu_opt_rename. > e.g: > When add bps twice in command line, need to rename all bps to > throttling.bps-total. >=20 > Signed-off-by: Jun Li > --- > This patch solved following bug: > Bug 1145586 - qemu-kvm will give strange hint when add bps twice for a = drive > ref:https://bugzilla.redhat.com/show_bug.cgi?id=3D1145586 Including that bug link in the commit message might be nice for someone visiting this patch a year from now. > --- > blockdev.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) >=20 > diff --git a/blockdev.c b/blockdev.c > index b361fbb..7c39a06 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -536,10 +536,15 @@ static void qemu_opt_rename(QemuOpts *opts, const= char *from, const char *to) > { > const char *value; > =20 > - value =3D qemu_opt_get(opts, from); > - if (value) { > - qemu_opt_set(opts, to, value); > - qemu_opt_unset(opts, from); > + /* rename all items */ > + while (1) { > + value =3D qemu_opt_get(opts, from); Can't this just be written as: while ((value =3D qemu_opt_get(opts, from))) { > + if (value) { > + qemu_opt_set(opts, to, value); > + qemu_opt_unset(opts, from); > + } else { > + break; > + } and lose the if/else and break? But that's style, not functional, so: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --PkXQh5g1tjaLoaHcNJEIdb2gKdJjlrbMI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUIaQSAAoJEKeha0olJ0NqmeQH/1llLrunZc+Jngb9aJYa4cMC vokXrWgzGAbBQHpuj178wMA9/hW0tC/ad+avtBUbM60XW9Y+2mTui1+MOUfirSP9 CYa+UkRtG4W3erm2qff4ULpBs/UjT7/y+Vsfjy7XHLpvKmAU+ggXNrQrBikgCEOX K8YNz5Fqxv1+mGvyr1SO0348FgZGD3fyjZw5eSQ8mYuiyl8m6fvE8KUWmMTYh3Ef FX4F/49W+ya+76U0mC91dms8zGqPsE4B30cPnnEC50SWxO1nOVTOlTLA5jRUCgbm U1TNGQeoMnXWWMdrQ2m8oYpirI8/ivEynMDBCssreqrJWc9OFHn9V2Frkvk2xo8= =GttB -----END PGP SIGNATURE----- --PkXQh5g1tjaLoaHcNJEIdb2gKdJjlrbMI--