From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [RFC PATCH v2 1/4] block: Fake a bdrv_aio_pwrite
Date: Fri, 5 Nov 2010 19:38:24 +0100 [thread overview]
Message-ID: <1288982307-30559-2-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1288982307-30559-1-git-send-email-kwolf@redhat.com>
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
next prev parent reply other threads:[~2010-11-05 18:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-05 18:38 [Qemu-devel] [RFC PATCH v2 0/4] block-queue: Delay and batch metadata writes Kevin Wolf
2010-11-05 18:38 ` Kevin Wolf [this message]
2010-11-05 18:38 ` [Qemu-devel] [RFC PATCH v2 2/4] Add block-queue Kevin Wolf
2010-11-17 12:43 ` Stefan Hajnoczi
2010-11-17 13:41 ` Kevin Wolf
2010-11-17 16:23 ` Stefan Hajnoczi
2010-11-18 9:46 ` Kevin Wolf
2010-11-17 16:24 ` Stefan Hajnoczi
2010-11-05 18:38 ` [Qemu-devel] [RFC PATCH v2 3/4] Test cases for block-queue Kevin Wolf
2010-11-05 18:38 ` [Qemu-devel] [RFC PATCH v2 4/4] qcow2: Use block-queue Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1288982307-30559-2-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).