[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 29/48] qcow2: Split upgrade/downgrade paths for amend
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 29/48] qcow2: Split upgrade/downgrade paths for amend |
Date: |
Fri, 18 Dec 2015 16:07:35 +0100 |
From: Max Reitz <address@hidden>
If the image version should be upgraded, that is the first we should do;
if it should be downgraded, that is the last we should do. So split the
version change block into an upgrade part at the start and a downgrade
part at the end.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 381b4f7..07a4f0b 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3006,20 +3006,13 @@ static int qcow2_amend_options(BlockDriverState *bs,
QemuOpts *opts,
desc++;
}
- if (new_version != old_version) {
- if (new_version > old_version) {
- /* Upgrade */
- s->qcow_version = new_version;
- ret = qcow2_update_header(bs);
- if (ret < 0) {
- s->qcow_version = old_version;
- return ret;
- }
- } else {
- ret = qcow2_downgrade(bs, new_version, status_cb, cb_opaque);
- if (ret < 0) {
- return ret;
- }
+ /* Upgrade first (some features may require compat=1.1) */
+ if (new_version > old_version) {
+ s->qcow_version = new_version;
+ ret = qcow2_update_header(bs);
+ if (ret < 0) {
+ s->qcow_version = old_version;
+ return ret;
}
}
@@ -3034,7 +3027,7 @@ static int qcow2_amend_options(BlockDriverState *bs,
QemuOpts *opts,
if (s->use_lazy_refcounts != lazy_refcounts) {
if (lazy_refcounts) {
- if (s->qcow_version < 3) {
+ if (new_version < 3) {
error_report("Lazy refcounts only supported with compatibility
"
"level 1.1 and above (use compat=1.1 or
greater)");
return -EINVAL;
@@ -3070,6 +3063,14 @@ 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);
+ if (ret < 0) {
+ return ret;
+ }
+ }
+
return 0;
}
--
1.8.3.1
- [Qemu-devel] [PULL 20/48] block: Move cache options into options QDict, (continued)
- [Qemu-devel] [PULL 20/48] block: Move cache options into options QDict, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 03/48] iotests: 124: don't reopen qcow2, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 46/48] block/qapi: explicitly warn if !has_full_backing_filename, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 37/48] block: Remove prototype of bdrv_swap from header, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 09/48] block: Exclude nested options only for children in append_open_options(), Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 24/48] qemu-iotests: Test reopen with node-name/driver options, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 39/48] block: use drained section around bdrv_snapshot_delete, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 38/48] iotests: Update comments for bdrv_swap() in 094, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 40/48] block: fix bdrv_ioctl called from coroutine, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 31/48] qcow2: Add function for refcount order amendment, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 29/48] qcow2: Split upgrade/downgrade paths for amend,
Kevin Wolf <=
- [Qemu-devel] [PULL 30/48] qcow2: Use intermediate helper CB for amend, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 41/48] qemu-iotests: refine common.config, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 23/48] qemu-iotests: Test cache mode option inheritance, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 32/48] qcow2: Invoke refcount order amendment function, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 42/48] qemu-iotests: s390x: fix test 051, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 02/48] iotests: 124: move incremental failure test, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 01/48] iotests: 124: Split into two test classes, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 47/48] qemu-img: abort when full_backing_filename not present, Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 28/48] qcow2: Use abort() instead of assert(false), Kevin Wolf, 2015/12/18
- [Qemu-devel] [PULL 21/48] blkdebug: Enable reopen, Kevin Wolf, 2015/12/18