From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuMJ5-0002OR-WE for qemu-devel@nongnu.org; Fri, 28 Nov 2014 09:14:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XuMIz-000592-SH for qemu-devel@nongnu.org; Fri, 28 Nov 2014 09:13:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuMIz-00058x-BK for qemu-devel@nongnu.org; Fri, 28 Nov 2014 09:13:53 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sASEDqKu031616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 28 Nov 2014 09:13:52 -0500 Date: Fri, 28 Nov 2014 14:13:51 +0000 From: Stefan Hajnoczi Message-ID: <20141128141351.GS13631@stefanha-thinkpad.redhat.com> References: <1416503198-17031-1-git-send-email-mreitz@redhat.com> <1416503198-17031-19-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="H88uUF932U8Oj0a6" Content-Disposition: inline In-Reply-To: <1416503198-17031-19-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 18/22] qcow2: Use intermediate helper CB for amend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org --H88uUF932U8Oj0a6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 20, 2014 at 06:06:34PM +0100, Max Reitz wrote: > @@ -2674,6 +2743,7 @@ static int qcow2_amend_options(BlockDriverState *bs= , QemuOpts *opts, > bool encrypt; > int ret; > QemuOptDesc *desc =3D opts->list->desc; > + Qcow2AmendHelperCBInfo helper_cb_info; > =20 > while (desc && desc->name) { > if (!qemu_opt_find(opts, desc->name)) { > @@ -2731,6 +2801,12 @@ static int qcow2_amend_options(BlockDriverState *b= s, QemuOpts *opts, > desc++; > } > =20 > + helper_cb_info =3D (Qcow2AmendHelperCBInfo){ > + .original_status_cb =3D status_cb, > + .original_cb_opaque =3D cb_opaque, > + .total_operations =3D (new_version < old_version) If you respin, another way of writing this is without total_operations here (so it initializes to 0)... > + }; > + > /* Upgrade first (some features may require compat=3D1.1) */ > if (new_version > old_version) { > s->qcow_version =3D new_version; > @@ -2789,7 +2865,9 @@ static int qcow2_amend_options(BlockDriverState *bs= , QemuOpts *opts, > =20 > /* Downgrade last (so unsupported features can be removed before) */ > if (new_version < old_version) { > - ret =3D qcow2_downgrade(bs, new_version, status_cb, cb_opaque); > + helper_cb_info.current_operation =3D QCOW2_DOWNGRADING; =2E..and then helper_cb_info.total_operations++ here. That way the new_version < old_version check is not duplicated into the helper_cb_info initializer. The code is clearer because we assign current_operation and total_operations at the same time. Just a style suggestion, feel free to ignore if you don't like it. --H88uUF932U8Oj0a6 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUeIMfAAoJEJykq7OBq3PIkWQH/jNwxVx5bEjYw6S0ms+XZI+J FGjHgUiz9RhCYDoeYJ8Rv+2kcGpa9i2cUUhQzDv6pAyw7aQ4uP/NQhOq1nOrsEX/ 5mSUFfHLrE3A9LtPWFFFrYBtasTRTAwIHhTxy6jruLcGx7Qzt+/Erf5WaYI2/o05 IPgBGyo0xNVewLjiMOQqOBT9cRhTHjpoZc1WYAsaFC3FkHHjMZ08BwMq4skGBKTx BZ/LUEt1LUqYp0DSZ6e5+I7oIBTWg+wl1k6Y8gqxGIKaQVY3urWGQ3Bcxkyn/p/p UHsl4YQZAihFN0r7m59GTGikBDae0W/hkyeOW6dN7futOMtfZhD0o+730+PHSvQ= =zrkZ -----END PGP SIGNATURE----- --H88uUF932U8Oj0a6--