From da24dd52f2ed750c51f2051362e43b72b86c93cb Mon Sep 17 00:00:00 2001 From: Kevin Wolf <kwolf@redhat.com> Date: Wed, 2 Dec 2009 16:28:57 -0200 Subject: [PATCH 2/2] qcow/qcow2: Add bdrv_aio_flush RH-Author: Kevin Wolf <kwolf@redhat.com> Message-id: <1259771337-27242-1-git-send-email-kwolf@redhat.com> Patchwork-id: 3839 O-Subject: [RHEL-5.5 KVM PATCH] qcow/qcow2: Add bdrv_aio_flush Bugzilla: 542923 RH-Acked-by: Avi Kivity <avi@redhat.com> RH-Acked-by: Andrea Arcangeli <aarcange@redhat.com> RH-Acked-by: Juan Quintela <quintela@redhat.com> Bugzilla: 542923 Upstream status: Not needed Unlike upstream our version of qemu doesn't know the concept of AIOPools. Instead, exactly one pool exists for each block driver. Also, drivers implementing AIO functions have control blocks different from the generic AIO emulation. In consequence this means that block drivers are expected to implement either no AIO functionality at all or to implement all of the AIO functions. If only a subset is implemented, the AIO emulation tries to use, for example, qcow2 control blocks and interprets them as its own structure. Therefore it reads garbage (a sector number in a field where it expected a pointer to a Bottom Half) and segfaults eventually. This patch adds the missing bdrv_aio_flush operation to qcow and qcow2. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- qemu/block-qcow.c | 9 +++++++++ qemu/block-qcow2.c | 9 +++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- qemu/block-qcow.c | 9 +++++++++ qemu/block-qcow2.c | 9 +++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/qemu/block-qcow.c b/qemu/block-qcow.c index ab10e91..ebf9ecb 100644 --- a/qemu/block-qcow.c +++ b/qemu/block-qcow.c @@ -889,6 +889,14 @@ static void qcow_flush(BlockDriverState *bs) bdrv_flush(s->hd); } +static BlockDriverAIOCB *qcow_aio_flush(BlockDriverState *bs, + BlockDriverCompletionFunc *cb, void *opaque) +{ + BDRVQcowState *s = bs->opaque; + + return bdrv_aio_flush(s->hd, cb, opaque); +} + static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { BDRVQcowState *s = bs->opaque; @@ -912,6 +920,7 @@ BlockDriver bdrv_qcow = { .bdrv_aio_read = qcow_aio_read, .bdrv_aio_write = qcow_aio_write, + .bdrv_aio_flush = qcow_aio_flush, .bdrv_aio_cancel = qcow_aio_cancel, .aiocb_size = sizeof(QCowAIOCB), .bdrv_write_compressed = qcow_write_compressed, diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c index dc37832..45d53bf 100644 --- a/qemu/block-qcow2.c +++ b/qemu/block-qcow2.c @@ -1848,6 +1848,14 @@ static void qcow_flush(BlockDriverState *bs) bdrv_flush(s->hd); } +static BlockDriverAIOCB *qcow2_aio_flush(BlockDriverState *bs, + BlockDriverCompletionFunc *cb, void *opaque) +{ + BDRVQcowState *s = bs->opaque; + + return bdrv_aio_flush(s->hd, cb, opaque); +} + static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { BDRVQcowState *s = bs->opaque; @@ -3011,6 +3019,7 @@ BlockDriver bdrv_qcow2 = { .bdrv_aio_read = qcow_aio_read, .bdrv_aio_write = qcow_aio_write, + .bdrv_aio_flush = qcow2_aio_flush, .bdrv_aio_cancel = qcow_aio_cancel, .aiocb_size = sizeof(QCowAIOCB), .bdrv_write_compressed = qcow_write_compressed, -- 1.6.3.rc4.29.g8146