Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > aadbe78a25743146bb784eee19f007c5 > files > 488

kvm-83-164.el5_5.9.src.rpm

From 9ba4f7bd96e495f884033ddaa3b29e09574165d0 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Thu, 21 Jan 2010 14:03:06 -0200
Subject: [PATCH 08/10] qcow2: Allow updating no refcounts

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1264082588-10273-9-git-send-email-kwolf@redhat.com>
Patchwork-id: 6517
O-Subject: [RHEL-5.5 KVM PATCH 08/10] qcow2: Allow updating no refcounts
Bugzilla: 537077
RH-Acked-by: Christoph Hellwig <chellwig@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>

Bugzilla: 537077
Upstream status: Submitted

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>
---
 qemu/block-qcow2.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/block-qcow2.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c
index 4dc2886..b974de3 100644
--- a/qemu/block-qcow2.c
+++ b/qemu/block-qcow2.c
@@ -2794,8 +2794,12 @@ static int update_refcount(BlockDriverState *bs,
     printf("update_refcount: offset=%lld size=%lld 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;
-- 
1.6.3.rc4.29.g8146