[tip:tools/kvm] kvm tools, qcow: Fix copy-on-write image corruption

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  4839bcd6b04a1b628f0f00d535ddca2ee872e9fa
Gitweb:     http://git.kernel.org/tip/4839bcd6b04a1b628f0f00d535ddca2ee872e9fa
Author:     Pekka Enberg <penberg@xxxxxxxxxx>
AuthorDate: Wed, 20 Jul 2011 16:28:31 +0300
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Wed, 20 Jul 2011 16:28:31 +0300

kvm tools, qcow: Fix copy-on-write image corruption

We don't handle refcount table properly so make sure we only write to clusters
that have the "copied" flag set.

Cc: Kevin Wolf <kwolf@xxxxxxxxxx>
Cc: Sasha Levin <levinsasha928@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/disk/qcow.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/disk/qcow.c b/tools/kvm/disk/qcow.c
index bf0ac33..bffd4b6 100644
--- a/tools/kvm/disk/qcow.c
+++ b/tools/kvm/disk/qcow.c
@@ -429,7 +429,11 @@ static ssize_t qcow_write_cluster(struct qcow *q, u64 offset, void *buf, u32 src
 
 	l2t_off = be64_to_cpu(table->l1_table[l1t_idx]);
 	if (l2t_off & QCOW_OFLAG_COMPRESSED) {
-		pr_warning("compressed sectors are not supported");
+		pr_warning("compressed clusters are not supported");
+		goto error;
+	}
+	if (!(l2t_off & QCOW_OFLAG_COPIED)) {
+		pr_warning("copy-on-write clusters are not supported");
 		goto error;
 	}
 
@@ -472,7 +476,11 @@ static ssize_t qcow_write_cluster(struct qcow *q, u64 offset, void *buf, u32 src
 
 	clust_start	= be64_to_cpu(l2t->table[l2t_idx]);
 	if (clust_start & QCOW_OFLAG_COMPRESSED) {
-		pr_warning("compressed sectors are not supported");
+		pr_warning("compressed clusters are not supported");
+		goto error;
+	}
+	if (!(clust_start & QCOW_OFLAG_COPIED)) {
+		pr_warning("copy-on-write clusters are not supported");
 		goto error;
 	}
 
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux