diff options
author | Kevin Wolf <kwolf@redhat.com> | 2010-01-20 15:03:05 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-01-26 14:59:19 -0600 |
commit | 7322afe7eaa7211285a38ccfb754a0a52911e394 (patch) | |
tree | 697c315d93d5616f26ba977b7cef9a28759635a9 /block/qcow2-refcount.c | |
parent | qcow2: Improve error handling in update_refcount (diff) | |
download | qemu-kvm-7322afe7eaa7211285a38ccfb754a0a52911e394.tar.gz qemu-kvm-7322afe7eaa7211285a38ccfb754a0a52911e394.tar.bz2 qemu-kvm-7322afe7eaa7211285a38ccfb754a0a52911e394.zip |
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>
Diffstat (limited to 'block/qcow2-refcount.c')
-rw-r--r-- | block/qcow2-refcount.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index a84620ffe..da7d3f240 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; |