diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2014-05-08 16:34:50 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-06-04 09:56:12 +0200 |
commit | 85ebd381fdae2d551cd6a0ffff47ab08734edf12 (patch) | |
tree | 046ca8f1cc3b05cf1c25015690c07610479930a6 /block/raw-win32.c | |
parent | 99cc598924d9686e497fa9ddd7889d6be27f3084 (diff) |
block/raw-win32: implement .bdrv_detach/attach_aio_context()
Drop the assumption that we're using the main AioContext for raw-win32.
Convert the aio-win32 code to support detach/attach and replace
qemu_aio_wait() with aio_poll().
The .bdrv_detach/attach_aio_context() interfaces move the aio-win32
event notifier from the old to the new AioContext.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/raw-win32.c')
-rw-r--r-- | block/raw-win32.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/block/raw-win32.c b/block/raw-win32.c index cf1e9cec4c..324e8187f5 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -200,6 +200,25 @@ static int set_sparse(int fd) NULL, 0, NULL, 0, &returned, NULL); } +static void raw_detach_aio_context(BlockDriverState *bs) +{ + BDRVRawState *s = bs->opaque; + + if (s->aio) { + win32_aio_detach_aio_context(s->aio, bdrv_get_aio_context(bs)); + } +} + +static void raw_attach_aio_context(BlockDriverState *bs, + AioContext *new_context) +{ + BDRVRawState *s = bs->opaque; + + if (s->aio) { + win32_aio_attach_aio_context(s->aio, new_context); + } +} + static void raw_probe_alignment(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; @@ -339,6 +358,8 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, error_setg_errno(errp, -ret, "Could not enable AIO"); goto fail; } + + win32_aio_attach_aio_context(s->aio, bdrv_get_aio_context(bs)); } raw_probe_alignment(bs); @@ -388,6 +409,7 @@ static void raw_close(BlockDriverState *bs) BDRVRawState *s = bs->opaque; if (s->aio) { + win32_aio_detach_aio_context(s->aio, bdrv_get_aio_context(bs)); win32_aio_cleanup(s->aio); s->aio = NULL; } @@ -687,6 +709,9 @@ static BlockDriver bdrv_host_device = { .bdrv_aio_writev = raw_aio_writev, .bdrv_aio_flush = raw_aio_flush, + .bdrv_detach_aio_context = raw_detach_aio_context, + .bdrv_attach_aio_context = raw_attach_aio_context, + .bdrv_getlength = raw_getlength, .has_variable_length = true, |