[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/17] block: expect errors from bdrv_co_is_allocate
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 06/17] block: expect errors from bdrv_co_is_allocated |
Date: |
Wed, 3 Jul 2013 16:34:20 +0200 |
Some bdrv_is_allocated callers do not expect errors, but the fallback
in qcow2.c might make other callers trip on assertion failures or
infinite loops.
Fix the callers to always look for errors.
Cc: address@hidden
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/qcow2.c | 4 +---
block/stream.c | 2 +-
qemu-img.c | 4 ++++
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 0eceefe..e2b4202 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -648,13 +648,11 @@ static int coroutine_fn
qcow2_co_is_allocated(BlockDriverState *bs,
int ret;
*pnum = nb_sectors;
- /* FIXME We can get errors here, but the bdrv_co_is_allocated interface
- * can't pass them on today */
qemu_co_mutex_lock(&s->lock);
ret = qcow2_get_cluster_offset(bs, sector_num << 9, pnum, &cluster_offset);
qemu_co_mutex_unlock(&s->lock);
if (ret < 0) {
- *pnum = 0;
+ return ret;
}
return (cluster_offset != 0) || (ret == QCOW2_CLUSTER_ZERO);
diff --git a/block/stream.c b/block/stream.c
index 802acae..28b702d 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -120,7 +120,7 @@ wait:
if (ret == 1) {
/* Allocated in the top, no need to copy. */
copy = false;
- } else {
+ } else if (ret >= 0) {
/* Copy if allocated in the intermediate images. Limit to the
* known-unallocated area [sector_num, sector_num+n). */
ret = bdrv_is_allocated_above(bs->backing_hd, base,
diff --git a/qemu-img.c b/qemu-img.c
index f8c97d3..857e2ca 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2073,6 +2073,10 @@ static int img_rebase(int argc, char **argv)
/* If the cluster is allocated, we don't need to take action */
ret = bdrv_is_allocated(bs, sector, n, &n);
+ if (ret < 0) {
+ error_report("error while reading from file");
+ goto out;
+ }
if (ret) {
continue;
}
--
1.8.2.1
- Re: [Qemu-devel] [PATCH 01/17] cow: make reads go at a decent speed, (continued)
- [Qemu-devel] [PATCH 02/17] cow: make writes go at a less indecent speed, Paolo Bonzini, 2013/07/03
- [Qemu-devel] [PATCH 03/17] cow: do not call bdrv_co_is_allocated, Paolo Bonzini, 2013/07/03
- [Qemu-devel] [PATCH 04/17] block: make bdrv_co_is_allocated static, Paolo Bonzini, 2013/07/03
- [Qemu-devel] [PATCH 05/17] block: remove bdrv_is_allocated_above/bdrv_co_is_allocated_above distinction, Paolo Bonzini, 2013/07/03
- [Qemu-devel] [PATCH 07/17] qemu-img: always probe the input image for allocated sectors, Paolo Bonzini, 2013/07/03
- [Qemu-devel] [PATCH 06/17] block: expect errors from bdrv_co_is_allocated,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 08/17] block: make bdrv_has_zero_init return false for copy-on-write-images, Paolo Bonzini, 2013/07/03
- [Qemu-devel] [PATCH 09/17] block: introduce bdrv_get_block_status API, Paolo Bonzini, 2013/07/03
- [Qemu-devel] [PATCH 10/17] block: define get_block_status return value, Paolo Bonzini, 2013/07/03
[Qemu-devel] [PATCH 12/17] qemu-img: add a "map" subcommand, Paolo Bonzini, 2013/07/03