summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2010-01-20 15:03:05 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-27 07:52:32 -0600
commitafa328b1b25a624517d0c7c461571c49c6ffcf63 (patch)
tree08e9425226cedb22bb2c0b448ac9dc2043b3099f
parent868dab5dc2aeccfd025c3c4712c0124877a704c3 (diff)
downloadqemu-afa328b1b25a624517d0c7c461571c49c6ffcf63.tar.gz
qcow2: Allow updating no refcounts
There's absolutely no problem with updating the refcounts of 0 clusters. At least snapshot code is doing this and would fail once the result of update_refcount isn't ignored any more. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit 7322afe7eaa7211285a38ccfb754a0a52911e394)
-rw-r--r--block/qcow2-refcount.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index a28acc00f2..08e67361f1 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -284,8 +284,12 @@ static int update_refcount(BlockDriverState *bs,
printf("update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n",
offset, length, addend);
#endif
- if (length <= 0)
+ if (length < 0) {
return -EINVAL;
+ } else if (length == 0) {
+ return 0;
+ }
+
start = offset & ~(s->cluster_size - 1);
last = (offset + length - 1) & ~(s->cluster_size - 1);
for(cluster_offset = start; cluster_offset <= last;