aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-refcount.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2010-01-20 15:04:01 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-26 14:59:19 -0600
commit5d757b563d59142ca81e1073a8e8396750a0ad1a (patch)
treec4527c89f5ea8b45901c45daaca72450a454a7c8 /block/qcow2-refcount.c
parentdb3a964fb6d66bd50faca76968479bb62ed25330 (diff)
downloadqemu-5d757b563d59142ca81e1073a8e8396750a0ad1a.zip
qemu-5d757b563d59142ca81e1073a8e8396750a0ad1a.tar.gz
qemu-5d757b563d59142ca81e1073a8e8396750a0ad1a.tar.bz2
qcow2: Don't ignore qcow2_alloc_clusters return value
Now that qcow2_alloc_clusters can return error codes, we must handle them in the callers of qcow2_alloc_clusters. 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.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index b12299d..2fdc26b 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -435,6 +435,9 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
assert(size > 0 && size <= s->cluster_size);
if (s->free_byte_offset == 0) {
s->free_byte_offset = qcow2_alloc_clusters(bs, s->cluster_size);
+ if (s->free_byte_offset < 0) {
+ return s->free_byte_offset;
+ }
}
redo:
free_in_cluster = s->cluster_size -
@@ -450,6 +453,9 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
update_cluster_refcount(bs, offset >> s->cluster_bits, 1);
} else {
offset = qcow2_alloc_clusters(bs, s->cluster_size);
+ if (offset < 0) {
+ return offset;
+ }
cluster_offset = s->free_byte_offset & ~(s->cluster_size - 1);
if ((cluster_offset + s->cluster_size) == offset) {
/* we are lucky: contiguous data */