diff mbox

[4/5] main-loop: add qemu_get_aio_context()

Message ID 1362584735-30911-5-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi March 6, 2013, 3:45 p.m. UTC
It is very useful to get the main loop AioContext, which is a static
variable in main-loop.c.

I'm not sure whether qemu_get_aio_context() will be necessary in the
future once devices focus on using their own AioContext instead of the
main loop AioContext, but for now it allows us to refactor code to
support multiple AioContext while actually passing the main loop
AioContext.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 include/qemu/main-loop.h | 5 +++++
 main-loop.c              | 5 +++++
 2 files changed, 10 insertions(+)

Comments

Paolo Bonzini March 6, 2013, 5:26 p.m. UTC | #1
Il 06/03/2013 16:45, Stefan Hajnoczi ha scritto:
> It is very useful to get the main loop AioContext, which is a static
> variable in main-loop.c.
> 
> I'm not sure whether qemu_get_aio_context() will be necessary in the
> future once devices focus on using their own AioContext instead of the
> main loop AioContext, but for now it allows us to refactor code to
> support multiple AioContext while actually passing the main loop
> AioContext.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  include/qemu/main-loop.h | 5 +++++
>  main-loop.c              | 5 +++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
> index 0995288..6f0200a 100644
> --- a/include/qemu/main-loop.h
> +++ b/include/qemu/main-loop.h
> @@ -82,6 +82,11 @@ int qemu_init_main_loop(void);
>  int main_loop_wait(int nonblocking);
>  
>  /**
> + * qemu_get_aio_context: Return the main loop's AioContext
> + */
> +AioContext *qemu_get_aio_context(void);
> +
> +/**
>   * qemu_notify_event: Force processing of pending events.
>   *
>   * Similar to signaling a condition variable, qemu_notify_event forces
> diff --git a/main-loop.c b/main-loop.c
> index 8c9b58c..eb80ff3 100644
> --- a/main-loop.c
> +++ b/main-loop.c
> @@ -109,6 +109,11 @@ static int qemu_signal_init(void)
>  
>  static AioContext *qemu_aio_context;
>  
> +AioContext *qemu_get_aio_context(void)
> +{
> +    return qemu_aio_context;
> +}
> +
>  void qemu_notify_event(void)
>  {
>      if (!qemu_aio_context) {
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
diff mbox

Patch

diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
index 0995288..6f0200a 100644
--- a/include/qemu/main-loop.h
+++ b/include/qemu/main-loop.h
@@ -82,6 +82,11 @@  int qemu_init_main_loop(void);
 int main_loop_wait(int nonblocking);
 
 /**
+ * qemu_get_aio_context: Return the main loop's AioContext
+ */
+AioContext *qemu_get_aio_context(void);
+
+/**
  * qemu_notify_event: Force processing of pending events.
  *
  * Similar to signaling a condition variable, qemu_notify_event forces
diff --git a/main-loop.c b/main-loop.c
index 8c9b58c..eb80ff3 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -109,6 +109,11 @@  static int qemu_signal_init(void)
 
 static AioContext *qemu_aio_context;
 
+AioContext *qemu_get_aio_context(void)
+{
+    return qemu_aio_context;
+}
+
 void qemu_notify_event(void)
 {
     if (!qemu_aio_context) {