[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 18/22] qcow2: Use intermediate helper CB for
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v3 18/22] qcow2: Use intermediate helper CB for amend |
Date: |
Fri, 28 Nov 2014 14:13:51 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
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 = opts->list->desc;
> + Qcow2AmendHelperCBInfo helper_cb_info;
>
> while (desc && desc->name) {
> if (!qemu_opt_find(opts, desc->name)) {
> @@ -2731,6 +2801,12 @@ static int qcow2_amend_options(BlockDriverState *bs,
> QemuOpts *opts,
> desc++;
> }
>
> + helper_cb_info = (Qcow2AmendHelperCBInfo){
> + .original_status_cb = status_cb,
> + .original_cb_opaque = cb_opaque,
> + .total_operations = (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=1.1) */
> if (new_version > old_version) {
> s->qcow_version = new_version;
> @@ -2789,7 +2865,9 @@ static int qcow2_amend_options(BlockDriverState *bs,
> QemuOpts *opts,
>
> /* Downgrade last (so unsupported features can be removed before) */
> if (new_version < old_version) {
> - ret = qcow2_downgrade(bs, new_version, status_cb, cb_opaque);
> + helper_cb_info.current_operation = QCOW2_DOWNGRADING;
...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.
pgpsX0k4CDoqi.pgp
Description: PGP signature
- Re: [Qemu-devel] [PATCH v3 13/22] progress: Allow regressing progress, (continued)
- [Qemu-devel] [PATCH v3 16/22] qcow2: Use abort() instead of assert(false), Max Reitz, 2014/11/20
- [Qemu-devel] [PATCH v3 15/22] qcow2: Use error_report() in qcow2_amend_options(), Max Reitz, 2014/11/20
- [Qemu-devel] [PATCH v3 14/22] block: Add opaque value to the amend CB, Max Reitz, 2014/11/20
- [Qemu-devel] [PATCH v3 17/22] qcow2: Split upgrade/downgrade paths for amend, Max Reitz, 2014/11/20
- [Qemu-devel] [PATCH v3 18/22] qcow2: Use intermediate helper CB for amend, Max Reitz, 2014/11/20
- Re: [Qemu-devel] [PATCH v3 18/22] qcow2: Use intermediate helper CB for amend,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH v3 19/22] qcow2: Add function for refcount order amendment, Max Reitz, 2014/11/20
- [Qemu-devel] [PATCH v3 20/22] qcow2: Invoke refcount order amendment function, Max Reitz, 2014/11/20
- [Qemu-devel] [PATCH v3 22/22] iotests: Add test for different refcount widths, Max Reitz, 2014/11/20
- [Qemu-devel] [PATCH v3 21/22] qcow2: Point to amend function in check, Max Reitz, 2014/11/20