summaryrefslogtreecommitdiff
path: root/dma-helpers.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-05-25 12:37:32 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-05-27 09:46:03 -0500
commitc16b5a2ca0b186de618654a576bdad9cdd2d1ab2 (patch)
tree8c793602c179ad2d5adbce65bc6583340a12cd92 /dma-helpers.c
parentad53089b0d0b4bc0731d978e5713365e1a91ba74 (diff)
downloadqemu-c16b5a2ca0b186de618654a576bdad9cdd2d1ab2.tar.gz
qemu-c16b5a2ca0b186de618654a576bdad9cdd2d1ab2.tar.bz2
qemu-c16b5a2ca0b186de618654a576bdad9cdd2d1ab2.zip
fully split aio_pool from BlockDriver
Now that we have a separate aio pool structure we can remove those aio pool details from BlockDriver. Every driver supporting AIO now needs to declare a static AIOPool with the aiocb size and the cancellation method. This cleans up the current code considerably and will make it cleaner and more obvious to support two different aio implementations behind a single BlockDriver. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'dma-helpers.c')
-rw-r--r--dma-helpers.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/dma-helpers.c b/dma-helpers.c
index f9eb2240b2..712ed897f3 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -10,8 +10,6 @@
#include "dma.h"
#include "block_int.h"
-static AIOPool dma_aio_pool;
-
void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint)
{
qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry));
@@ -132,12 +130,26 @@ static void dma_bdrv_cb(void *opaque, int ret)
}
}
+static void dma_aio_cancel(BlockDriverAIOCB *acb)
+{
+ DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common);
+
+ if (dbs->acb) {
+ bdrv_aio_cancel(dbs->acb);
+ }
+}
+
+static AIOPool dma_aio_pool = {
+ .aiocb_size = sizeof(DMAAIOCB),
+ .cancel = dma_aio_cancel,
+};
+
static BlockDriverAIOCB *dma_bdrv_io(
BlockDriverState *bs, QEMUSGList *sg, uint64_t sector_num,
BlockDriverCompletionFunc *cb, void *opaque,
int is_write)
{
- DMAAIOCB *dbs = qemu_aio_get_pool(&dma_aio_pool, bs, cb, opaque);
+ DMAAIOCB *dbs = qemu_aio_get(&dma_aio_pool, bs, cb, opaque);
dbs->acb = NULL;
dbs->bs = bs;
@@ -170,17 +182,3 @@ BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs,
{
return dma_bdrv_io(bs, sg, sector, cb, opaque, 1);
}
-
-static void dma_aio_cancel(BlockDriverAIOCB *acb)
-{
- DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common);
-
- if (dbs->acb) {
- bdrv_aio_cancel(dbs->acb);
- }
-}
-
-void dma_helper_init(void)
-{
- aio_pool_init(&dma_aio_pool, sizeof(DMAAIOCB), dma_aio_cancel);
-}