qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH v2 1/4] block: Fake a bdrv_aio_pwrite


From: Kevin Wolf
Subject: [Qemu-devel] [RFC PATCH v2 1/4] block: Fake a bdrv_aio_pwrite
Date: Fri, 5 Nov 2010 19:38:24 +0100

Don't read this patch, it will be thrown away :-)
---
 block.c |   30 ++++++++++++++++++++++++++++++
 block.h |    2 ++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/block.c b/block.c
index 985d0b7..f75da13 100644
--- a/block.c
+++ b/block.c
@@ -2053,6 +2053,36 @@ BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, 
int64_t sector_num,
     return ret;
 }
 
+struct pread_acb {
+    QEMUBH *bh;
+    BlockDriverCompletionFunc *cb;
+    void *opaque;
+    int ret;
+};
+
+static void bdrv_aio_pwrite_cb(void *opaque)
+{
+    struct pread_acb *x = opaque;
+
+    x->cb(x->opaque, x->ret);
+    qemu_bh_delete(x->bh);
+    free(x);
+}
+
+/* TODO Yes, this is a really bad fake implementation */
+BlockDriverAIOCB *bdrv_aio_pwrite(BlockDriverState *bs, int64_t offset, void* 
buf,
+    size_t bytes, BlockDriverCompletionFunc *cb, void *opaque)
+{
+    struct pread_acb *x = qemu_malloc(sizeof(*x));
+    x->bh = qemu_bh_new(bdrv_aio_pwrite_cb, x);
+    x->cb = cb;
+    x->opaque = opaque;
+    x->ret = bdrv_pwrite(bs, offset, buf, bytes);
+    qemu_bh_schedule(x->bh);
+
+    return (BlockDriverAIOCB*) 42;
+}
+
 
 typedef struct MultiwriteCB {
     int error;
diff --git a/block.h b/block.h
index a4facf2..5798cdb 100644
--- a/block.h
+++ b/block.h
@@ -116,6 +116,8 @@ BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, 
int64_t sector_num,
 BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
                                   QEMUIOVector *iov, int nb_sectors,
                                   BlockDriverCompletionFunc *cb, void *opaque);
+BlockDriverAIOCB *bdrv_aio_pwrite(BlockDriverState *bs, int64_t offset, void* 
buf,
+    size_t bytes, BlockDriverCompletionFunc *cb, void *opaque);
 BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs,
                                 BlockDriverCompletionFunc *cb, void *opaque);
 void bdrv_aio_cancel(BlockDriverAIOCB *acb);
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]