]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qcow2: Allow updating no refcounts
authorKevin Wolf <kwolf@redhat.com>
Wed, 20 Jan 2010 14:03:05 +0000 (15:03 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 27 Jan 2010 13:52:32 +0000 (07:52 -0600)
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)

block/qcow2-refcount.c

index a28acc00f2ec7624d062cb00fb5dc2aa1454361f..08e67361f10ebce4c96d1a40be3b529f0c242ff5 100644 (file)
@@ -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;