From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Alberto Garcia <berto@igalia.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH v9 05/10] qcow2: Split upgrade/downgrade paths for amend
Date: Mon, 27 Jul 2015 17:51:35 +0200 [thread overview]
Message-ID: <1438012300-25164-6-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1438012300-25164-1-git-send-email-mreitz@redhat.com>
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 <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
---
block/qcow2.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index a7f50db..fe91974 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2759,20 +2759,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;
}
}
@@ -2787,7 +2780,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;
@@ -2823,6 +2816,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;
}
--
2.4.6
next prev parent reply other threads:[~2015-07-27 16:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 15:51 [Qemu-devel] [PATCH v9 00/10] qcow2: Support refcount order amendment Max Reitz
2015-07-27 15:51 ` [Qemu-devel] [PATCH v9 01/10] progress: Allow regressing progress Max Reitz
2015-07-27 15:51 ` [Qemu-devel] [PATCH v9 02/10] block: Add opaque value to the amend CB Max Reitz
2015-08-06 14:45 ` Alberto Garcia
2015-07-27 15:51 ` [Qemu-devel] [PATCH v9 03/10] qcow2: Use error_report() in qcow2_amend_options() Max Reitz
2015-07-27 15:51 ` [Qemu-devel] [PATCH v9 04/10] qcow2: Use abort() instead of assert(false) Max Reitz
2015-07-27 15:51 ` Max Reitz [this message]
2015-07-27 15:51 ` [Qemu-devel] [PATCH v9 06/10] qcow2: Use intermediate helper CB for amend Max Reitz
2015-07-27 15:51 ` [Qemu-devel] [PATCH v9 07/10] qcow2: Add function for refcount order amendment Max Reitz
2015-07-27 15:51 ` [Qemu-devel] [PATCH v9 08/10] qcow2: Invoke refcount order amendment function Max Reitz
2015-07-27 15:59 ` Eric Blake
2015-08-06 15:10 ` Alberto Garcia
2015-08-07 3:34 ` Eric Blake
2015-07-27 15:51 ` [Qemu-devel] [PATCH v9 09/10] qcow2: Point to amend function in check Max Reitz
2015-07-27 15:51 ` [Qemu-devel] [PATCH v9 10/10] iotests: Extend test 112 for qemu-img amend Max Reitz
2015-12-08 15:48 ` [Qemu-devel] [PATCH v9 00/10] qcow2: Support refcount order amendment Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438012300-25164-6-git-send-email-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).