aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2011-10-20 13:16:24 +0200
committerKevin Wolf <kwolf@redhat.com>2011-10-21 17:34:14 +0200
commit8b94ff85737062876c03e7506abb500521c749b9 (patch)
tree5bb67bd0896bb49a064e041c30cf61d2d4ce0a40 /block/qcow2.c
parente183ef75cc28d31addbb937a4680090495786944 (diff)
block: change flush to co_flush
Since coroutine operation is now mandatory, convert all bdrv_flush implementations to coroutines. For qcow2, this means taking the lock. Other implementations are simpler and just forward bdrv_flush to the underlying protocol, so they can avoid the lock. The bdrv_flush callback is then unused and can be eliminated. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qcow2.c')
-rw-r--r--block/qcow2.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index 91f4f04dd7..6ef38bf1b1 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1099,24 +1099,24 @@ fail:
return ret;
}
-static BlockDriverAIOCB *qcow2_aio_flush(BlockDriverState *bs,
- BlockDriverCompletionFunc *cb,
- void *opaque)
+static int qcow2_co_flush(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
int ret;
+ qemu_co_mutex_lock(&s->lock);
ret = qcow2_cache_flush(bs, s->l2_table_cache);
if (ret < 0) {
- return NULL;
+ return ret;
}
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
- return NULL;
+ return ret;
}
+ qemu_co_mutex_unlock(&s->lock);
- return bdrv_aio_flush(bs->file, cb, opaque);
+ return bdrv_co_flush(bs->file);
}
static int64_t qcow2_vm_state_offset(BDRVQcowState *s)
@@ -1237,7 +1237,7 @@ static BlockDriver bdrv_qcow2 = {
.bdrv_co_readv = qcow2_co_readv,
.bdrv_co_writev = qcow2_co_writev,
- .bdrv_aio_flush = qcow2_aio_flush,
+ .bdrv_co_flush = qcow2_co_flush,
.bdrv_discard = qcow2_discard,
.bdrv_truncate = qcow2_truncate,