AioContext: introduce aio_prepare

This will be used to implement socket polling on Windows.
On Windows, select() and g_poll() are completely different;
sockets are polled with select() before calling g_poll,
and the g_poll must be nonblocking if select() says a
socket is ready.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Paolo Bonzini 2014-07-09 11:53:08 +02:00 committed by Stefan Hajnoczi
parent 0a9dd1664a
commit a3462c6561
4 changed files with 23 additions and 1 deletions

View File

@ -100,6 +100,11 @@ void aio_set_event_notifier(AioContext *ctx,
(IOHandler *)io_read, NULL, notifier); (IOHandler *)io_read, NULL, notifier);
} }
bool aio_prepare(AioContext *ctx)
{
return false;
}
bool aio_pending(AioContext *ctx) bool aio_pending(AioContext *ctx)
{ {
AioHandler *node; AioHandler *node;

View File

@ -76,6 +76,11 @@ void aio_set_event_notifier(AioContext *ctx,
aio_notify(ctx); aio_notify(ctx);
} }
bool aio_prepare(AioContext *ctx)
{
return false;
}
bool aio_pending(AioContext *ctx) bool aio_pending(AioContext *ctx)
{ {
AioHandler *node; AioHandler *node;

View File

@ -188,6 +188,11 @@ aio_ctx_prepare(GSource *source, gint *timeout)
/* We assume there is no timeout already supplied */ /* We assume there is no timeout already supplied */
*timeout = qemu_timeout_ns_to_ms(aio_compute_timeout(ctx)); *timeout = qemu_timeout_ns_to_ms(aio_compute_timeout(ctx));
if (aio_prepare(ctx)) {
*timeout = 0;
}
return *timeout == 0; return *timeout == 0;
} }

View File

@ -205,7 +205,14 @@ void qemu_bh_cancel(QEMUBH *bh);
void qemu_bh_delete(QEMUBH *bh); void qemu_bh_delete(QEMUBH *bh);
/* Return whether there are any pending callbacks from the GSource /* Return whether there are any pending callbacks from the GSource
* attached to the AioContext. * attached to the AioContext, before g_poll is invoked.
*
* This is used internally in the implementation of the GSource.
*/
bool aio_prepare(AioContext *ctx);
/* Return whether there are any pending callbacks from the GSource
* attached to the AioContext, after g_poll is invoked.
* *
* This is used internally in the implementation of the GSource. * This is used internally in the implementation of the GSource.
*/ */