[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/23] qcow2: Fix error handling during metadata pre
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 01/23] qcow2: Fix error handling during metadata preallocation |
Date: |
Fri, 2 Jul 2010 18:38:10 +0200 |
People were wondering why qemu-img check failed after they tried to preallocate
a large qcow2 file and ran out of disk space.
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index d29e6b6..9ee34b6 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -805,14 +805,14 @@ static int preallocate(BlockDriverState *bs)
while (nb_sectors) {
num = MIN(nb_sectors, INT_MAX >> 9);
ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &meta);
-
if (ret < 0) {
- return -1;
+ return ret;
}
- if (qcow2_alloc_cluster_link_l2(bs, &meta) < 0) {
+ ret = qcow2_alloc_cluster_link_l2(bs, &meta);
+ if (ret < 0) {
qcow2_free_any_clusters(bs, meta.cluster_offset, meta.nb_clusters);
- return -1;
+ return ret;
}
/* There are no dependent requests, but we need to remove our request
@@ -833,7 +833,10 @@ static int preallocate(BlockDriverState *bs)
if (meta.cluster_offset != 0) {
uint8_t buf[512];
memset(buf, 0, 512);
- bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1);
+ ret = bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf,
1);
+ if (ret < 0) {
+ return ret;
+ }
}
return 0;
@@ -1030,7 +1033,7 @@ exit:
BlockDriver *drv = bdrv_find_format("qcow2");
bs = bdrv_new("");
bdrv_open(bs, filename, BDRV_O_CACHE_WB | BDRV_O_RDWR, drv);
- preallocate(bs);
+ ret = preallocate(bs);
bdrv_close(bs);
}
--
1.6.6.1
- [Qemu-devel] [PULL 00/23] Block patches, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 01/23] qcow2: Fix error handling during metadata preallocation,
Kevin Wolf <=
- [Qemu-devel] [PATCH 02/23] block: allow filenames with colons again for host devices, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 03/23] scsi: scsi_bus_legacy_handle_cmdline() can fail, fix callers, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 06/23] Don't reset bs->is_temporary in bdrv_open_common, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 10/23] blockdev: drive_get_by_id() is no longer used, remove, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 11/23] block: Catch attempt to attach multiple devices to a blockdev, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 19/23] ide: Make PIIX and ISA IDE init functions return the qdev, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 20/23] pc: Fix CMOS info for drives defined with -device, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 22/23] block: Fix early failure in multiwrite, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 23/23] block: Handle multiwrite errors only when all requests have completed, Kevin Wolf, 2010/07/02
- [Qemu-devel] [PATCH 21/23] qemu-img: avoid calling exit(1) to release resources properly, Kevin Wolf, 2010/07/02