mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
block: explicitly acquire aiocontext in callbacks that need it
This covers both file descriptor callbacks and polling callbacks, since they execute related code. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 20170213135235.12274-14-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
2f47da5f7f
commit
9d45665448
11 changed files with 68 additions and 55 deletions
|
@ -41,7 +41,7 @@ struct QEMUWin32AIOState {
|
|||
HANDLE hIOCP;
|
||||
EventNotifier e;
|
||||
int count;
|
||||
bool is_aio_context_attached;
|
||||
AioContext *aio_ctx;
|
||||
};
|
||||
|
||||
typedef struct QEMUWin32AIOCB {
|
||||
|
@ -88,7 +88,9 @@ static void win32_aio_process_completion(QEMUWin32AIOState *s,
|
|||
}
|
||||
|
||||
|
||||
aio_context_acquire(s->aio_ctx);
|
||||
waiocb->common.cb(waiocb->common.opaque, ret);
|
||||
aio_context_release(s->aio_ctx);
|
||||
qemu_aio_unref(waiocb);
|
||||
}
|
||||
|
||||
|
@ -176,13 +178,13 @@ void win32_aio_detach_aio_context(QEMUWin32AIOState *aio,
|
|||
AioContext *old_context)
|
||||
{
|
||||
aio_set_event_notifier(old_context, &aio->e, false, NULL, NULL);
|
||||
aio->is_aio_context_attached = false;
|
||||
aio->aio_ctx = NULL;
|
||||
}
|
||||
|
||||
void win32_aio_attach_aio_context(QEMUWin32AIOState *aio,
|
||||
AioContext *new_context)
|
||||
{
|
||||
aio->is_aio_context_attached = true;
|
||||
aio->aio_ctx = new_context;
|
||||
aio_set_event_notifier(new_context, &aio->e, false,
|
||||
win32_aio_completion_cb, NULL);
|
||||
}
|
||||
|
@ -212,7 +214,7 @@ out_free_state:
|
|||
|
||||
void win32_aio_cleanup(QEMUWin32AIOState *aio)
|
||||
{
|
||||
assert(!aio->is_aio_context_attached);
|
||||
assert(!aio->aio_ctx);
|
||||
CloseHandle(aio->hIOCP);
|
||||
event_notifier_cleanup(&aio->e);
|
||||
g_free(aio);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue