From patchwork Wed Jan 20 14:03:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2,08/10] qcow2: Allow updating no refcounts Date: Wed, 20 Jan 2010 04:03:05 -0000 From: Kevin Wolf X-Patchwork-Id: 43292 Message-Id: <1263996186-6623-9-git-send-email-kwolf@redhat.com> To: qemu-devel@nongnu.org Cc: Kevin Wolf 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 --- 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 a84620f..da7d3f2 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;