summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-08-31 10:04:18 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-08-31 10:04:18 -0500
commitcdedd9d867f2e955e022f07808b10a4a5d383841 (patch)
tree8f27b6ac02b9eb565d477cb7144ea280e01b4135 /block
parentb834b5081d6266cc0789454905f3b7d622d4d096 (diff)
parent774a8850d708aeb6dd6de493c28b374098c1a4c3 (diff)
downloadqemu-cdedd9d867f2e955e022f07808b10a4a5d383841.zip
Merge remote-tracking branch 'kwolf/for-anthony' into staging
* kwolf/for-anthony: qemu-iotests: add backing file smaller than image test case stream: complete early if end of backing file is reached qed: refuse unaligned zero writes with a backing file
Diffstat (limited to 'block')
-rw-r--r--block/qed.c11
-rw-r--r--block/stream.c6
2 files changed, 17 insertions, 0 deletions
diff --git a/block/qed.c b/block/qed.c
index a02dbfd72d..21cb239870 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1363,10 +1363,21 @@ static int coroutine_fn bdrv_qed_co_write_zeroes(BlockDriverState *bs,
int nb_sectors)
{
BlockDriverAIOCB *blockacb;
+ BDRVQEDState *s = bs->opaque;
QEDWriteZeroesCB cb = { .done = false };
QEMUIOVector qiov;
struct iovec iov;
+ /* Refuse if there are untouched backing file sectors */
+ if (bs->backing_hd) {
+ if (qed_offset_into_cluster(s, sector_num * BDRV_SECTOR_SIZE) != 0) {
+ return -ENOTSUP;
+ }
+ if (qed_offset_into_cluster(s, nb_sectors * BDRV_SECTOR_SIZE) != 0) {
+ return -ENOTSUP;
+ }
+ }
+
/* Zero writes start without an I/O buffer. If a buffer becomes necessary
* then it will be allocated during request processing.
*/
diff --git a/block/stream.c b/block/stream.c
index 37c46525d2..c4f87dd5b6 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -122,6 +122,12 @@ wait:
* known-unallocated area [sector_num, sector_num+n). */
ret = bdrv_co_is_allocated_above(bs->backing_hd, base,
sector_num, n, &n);
+
+ /* Finish early if end of backing file has been reached */
+ if (ret == 0 && n == 0) {
+ n = end - sector_num;
+ }
+
copy = (ret == 1);
}
trace_stream_one_iteration(s, sector_num, n, ret);