aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-cluster.c
diff options
context:
space:
mode:
authorStefan Weil <weil@mail.berlios.de>2009-10-26 16:11:16 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-11-09 08:43:01 -0600
commitd191d12d5f479422e16ed1d12b0222547b29036a (patch)
treedafeb368cfc86e2a8b7d69100a5d167fc363febd /block/qcow2-cluster.c
parentb4558d7481aefc865b0b52bf9b285ebcf2e8b59f (diff)
qcow2: Allow qcow2 disk images with size zero
Images with disk size 0 may be used for VM snapshots, but not to save normal block data. It is possible to create such images using qemu-img, but opening them later fails. So even "qemu-img info image.qcow2" is not possible for an image created with "qemu-img create -f qcow2 image.qcow2 0". This is fixed here. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block/qcow2-cluster.c')
-rw-r--r--block/qcow2-cluster.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index e444e53e13..f88118cdc5 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -39,6 +39,9 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
new_l1_size = s->l1_size;
if (min_size <= new_l1_size)
return 0;
+ if (new_l1_size == 0) {
+ new_l1_size = 1;
+ }
while (min_size > new_l1_size) {
new_l1_size = (new_l1_size * 3 + 1) / 2;
}