diff mbox

[v2,for-2.6,2/5] event-notifier: Add "is_external" parameter

Message ID 1461322564-17440-3-git-send-email-famz@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fam Zheng April 22, 2016, 10:56 a.m. UTC
All callers pass "false" keeping the old semantics. The windows
implementation doesn't distinguish the flag yet. On posix, it is passed
down to the underlying aio context.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 hw/usb/ccid-card-emulated.c   |  2 +-
 hw/virtio/virtio.c            |  8 ++++----
 include/qemu/event_notifier.h |  4 +++-
 stubs/set-fd-handler.c        | 10 ++++++++++
 target-i386/hyperv.c          |  6 +++---
 util/event_notifier-posix.c   |  4 +++-
 util/event_notifier-win32.c   |  1 +
 7 files changed, 25 insertions(+), 10 deletions(-)

Comments

Michael S. Tsirkin April 22, 2016, 1:44 p.m. UTC | #1
On Fri, Apr 22, 2016 at 06:56:01PM +0800, Fam Zheng wrote:
> All callers pass "false" keeping the old semantics. The windows
> implementation doesn't distinguish the flag yet. On posix, it is passed
> down to the underlying aio context.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/usb/ccid-card-emulated.c   |  2 +-
>  hw/virtio/virtio.c            |  8 ++++----
>  include/qemu/event_notifier.h |  4 +++-
>  stubs/set-fd-handler.c        | 10 ++++++++++
>  target-i386/hyperv.c          |  6 +++---
>  util/event_notifier-posix.c   |  4 +++-
>  util/event_notifier-win32.c   |  1 +
>  7 files changed, 25 insertions(+), 10 deletions(-)
> 
> diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
> index 9ddd5ad..3213f9f 100644
> --- a/hw/usb/ccid-card-emulated.c
> +++ b/hw/usb/ccid-card-emulated.c
> @@ -407,7 +407,7 @@ static int init_event_notifier(EmulatedState *card)
>          DPRINTF(card, 2, "event notifier creation failed\n");
>          return -1;
>      }
> -    event_notifier_set_handler(&card->notifier, card_event_handler);
> +    event_notifier_set_handler(&card->notifier, false, card_event_handler);
>      return 0;
>  }
>  
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index f745c4a..fffa09f 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -1775,10 +1775,10 @@ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
>                                                  bool with_irqfd)
>  {
>      if (assign && !with_irqfd) {
> -        event_notifier_set_handler(&vq->guest_notifier,
> +        event_notifier_set_handler(&vq->guest_notifier, false,
>                                     virtio_queue_guest_notifier_read);
>      } else {
> -        event_notifier_set_handler(&vq->guest_notifier, NULL);
> +        event_notifier_set_handler(&vq->guest_notifier, false, NULL);
>      }
>      if (!assign) {
>          /* Test and clear notifier before closing it,
> @@ -1829,10 +1829,10 @@ void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
>                                                 bool set_handler)
>  {
>      if (assign && set_handler) {
> -        event_notifier_set_handler(&vq->host_notifier,
> +        event_notifier_set_handler(&vq->host_notifier, false,
>                                     virtio_queue_host_notifier_read);
>      } else {
> -        event_notifier_set_handler(&vq->host_notifier, NULL);
> +        event_notifier_set_handler(&vq->host_notifier, false, NULL);
>      }
>      if (!assign) {
>          /* Test and clear notifier before after disabling event,
> diff --git a/include/qemu/event_notifier.h b/include/qemu/event_notifier.h
> index a8f2854..e326990 100644
> --- a/include/qemu/event_notifier.h
> +++ b/include/qemu/event_notifier.h
> @@ -34,7 +34,9 @@ int event_notifier_init(EventNotifier *, int active);
>  void event_notifier_cleanup(EventNotifier *);
>  int event_notifier_set(EventNotifier *);
>  int event_notifier_test_and_clear(EventNotifier *);
> -int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *);
> +int event_notifier_set_handler(EventNotifier *,
> +                               bool is_external,
> +                               EventNotifierHandler *);
>  
>  #ifdef CONFIG_POSIX
>  void event_notifier_init_fd(EventNotifier *, int fd);
> diff --git a/stubs/set-fd-handler.c b/stubs/set-fd-handler.c
> index 26965de..06a5da4 100644
> --- a/stubs/set-fd-handler.c
> +++ b/stubs/set-fd-handler.c
> @@ -9,3 +9,13 @@ void qemu_set_fd_handler(int fd,
>  {
>      abort();
>  }
> +
> +void aio_set_fd_handler(AioContext *ctx,
> +                        int fd,
> +                        bool is_external,
> +                        IOHandler *io_read,
> +                        IOHandler *io_write,
> +                        void *opaque)
> +{
> +    abort();
> +}
> diff --git a/target-i386/hyperv.c b/target-i386/hyperv.c
> index c4d6a9b..39a230f 100644
> --- a/target-i386/hyperv.c
> +++ b/target-i386/hyperv.c
> @@ -88,7 +88,7 @@ HvSintRoute *kvm_hv_sint_route_create(uint32_t vcpu_id, uint32_t sint,
>          goto err_sint_set_notifier;
>      }
>  
> -    event_notifier_set_handler(&sint_route->sint_ack_notifier,
> +    event_notifier_set_handler(&sint_route->sint_ack_notifier, false,
>                                 kvm_hv_sint_ack_handler);
>  
>      gsi = kvm_irqchip_add_hv_sint_route(kvm_state, vcpu_id, sint);
> @@ -112,7 +112,7 @@ HvSintRoute *kvm_hv_sint_route_create(uint32_t vcpu_id, uint32_t sint,
>  err_irqfd:
>      kvm_irqchip_release_virq(kvm_state, gsi);
>  err_gsi:
> -    event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL);
> +    event_notifier_set_handler(&sint_route->sint_ack_notifier, false, NULL);
>      event_notifier_cleanup(&sint_route->sint_ack_notifier);
>  err_sint_set_notifier:
>      event_notifier_cleanup(&sint_route->sint_set_notifier);
> @@ -128,7 +128,7 @@ void kvm_hv_sint_route_destroy(HvSintRoute *sint_route)
>                                            &sint_route->sint_set_notifier,
>                                            sint_route->gsi);
>      kvm_irqchip_release_virq(kvm_state, sint_route->gsi);
> -    event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL);
> +    event_notifier_set_handler(&sint_route->sint_ack_notifier, false, NULL);
>      event_notifier_cleanup(&sint_route->sint_ack_notifier);
>      event_notifier_cleanup(&sint_route->sint_set_notifier);
>      g_free(sint_route);
> diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
> index e150301..c1f0d79 100644
> --- a/util/event_notifier-posix.c
> +++ b/util/event_notifier-posix.c
> @@ -91,9 +91,11 @@ int event_notifier_get_fd(const EventNotifier *e)
>  }
>  
>  int event_notifier_set_handler(EventNotifier *e,
> +                               bool is_external,
>                                 EventNotifierHandler *handler)
>  {
> -    qemu_set_fd_handler(e->rfd, (IOHandler *)handler, NULL, e);
> +    aio_set_fd_handler(iohandler_get_aio_context(), e->rfd, is_external,
> +                       (IOHandler *)handler, NULL, e);
>      return 0;
>  }
>  
> diff --git a/util/event_notifier-win32.c b/util/event_notifier-win32.c
> index 14b4f7d..de87df0 100644
> --- a/util/event_notifier-win32.c
> +++ b/util/event_notifier-win32.c
> @@ -33,6 +33,7 @@ HANDLE event_notifier_get_handle(EventNotifier *e)
>  }
>  
>  int event_notifier_set_handler(EventNotifier *e,
> +                               bool is_external,
>                                 EventNotifierHandler *handler)
>  {
>      if (handler) {
> -- 
> 2.8.0
diff mbox

Patch

diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 9ddd5ad..3213f9f 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -407,7 +407,7 @@  static int init_event_notifier(EmulatedState *card)
         DPRINTF(card, 2, "event notifier creation failed\n");
         return -1;
     }
-    event_notifier_set_handler(&card->notifier, card_event_handler);
+    event_notifier_set_handler(&card->notifier, false, card_event_handler);
     return 0;
 }
 
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index f745c4a..fffa09f 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1775,10 +1775,10 @@  void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
                                                 bool with_irqfd)
 {
     if (assign && !with_irqfd) {
-        event_notifier_set_handler(&vq->guest_notifier,
+        event_notifier_set_handler(&vq->guest_notifier, false,
                                    virtio_queue_guest_notifier_read);
     } else {
-        event_notifier_set_handler(&vq->guest_notifier, NULL);
+        event_notifier_set_handler(&vq->guest_notifier, false, NULL);
     }
     if (!assign) {
         /* Test and clear notifier before closing it,
@@ -1829,10 +1829,10 @@  void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
                                                bool set_handler)
 {
     if (assign && set_handler) {
-        event_notifier_set_handler(&vq->host_notifier,
+        event_notifier_set_handler(&vq->host_notifier, false,
                                    virtio_queue_host_notifier_read);
     } else {
-        event_notifier_set_handler(&vq->host_notifier, NULL);
+        event_notifier_set_handler(&vq->host_notifier, false, NULL);
     }
     if (!assign) {
         /* Test and clear notifier before after disabling event,
diff --git a/include/qemu/event_notifier.h b/include/qemu/event_notifier.h
index a8f2854..e326990 100644
--- a/include/qemu/event_notifier.h
+++ b/include/qemu/event_notifier.h
@@ -34,7 +34,9 @@  int event_notifier_init(EventNotifier *, int active);
 void event_notifier_cleanup(EventNotifier *);
 int event_notifier_set(EventNotifier *);
 int event_notifier_test_and_clear(EventNotifier *);
-int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *);
+int event_notifier_set_handler(EventNotifier *,
+                               bool is_external,
+                               EventNotifierHandler *);
 
 #ifdef CONFIG_POSIX
 void event_notifier_init_fd(EventNotifier *, int fd);
diff --git a/stubs/set-fd-handler.c b/stubs/set-fd-handler.c
index 26965de..06a5da4 100644
--- a/stubs/set-fd-handler.c
+++ b/stubs/set-fd-handler.c
@@ -9,3 +9,13 @@  void qemu_set_fd_handler(int fd,
 {
     abort();
 }
+
+void aio_set_fd_handler(AioContext *ctx,
+                        int fd,
+                        bool is_external,
+                        IOHandler *io_read,
+                        IOHandler *io_write,
+                        void *opaque)
+{
+    abort();
+}
diff --git a/target-i386/hyperv.c b/target-i386/hyperv.c
index c4d6a9b..39a230f 100644
--- a/target-i386/hyperv.c
+++ b/target-i386/hyperv.c
@@ -88,7 +88,7 @@  HvSintRoute *kvm_hv_sint_route_create(uint32_t vcpu_id, uint32_t sint,
         goto err_sint_set_notifier;
     }
 
-    event_notifier_set_handler(&sint_route->sint_ack_notifier,
+    event_notifier_set_handler(&sint_route->sint_ack_notifier, false,
                                kvm_hv_sint_ack_handler);
 
     gsi = kvm_irqchip_add_hv_sint_route(kvm_state, vcpu_id, sint);
@@ -112,7 +112,7 @@  HvSintRoute *kvm_hv_sint_route_create(uint32_t vcpu_id, uint32_t sint,
 err_irqfd:
     kvm_irqchip_release_virq(kvm_state, gsi);
 err_gsi:
-    event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL);
+    event_notifier_set_handler(&sint_route->sint_ack_notifier, false, NULL);
     event_notifier_cleanup(&sint_route->sint_ack_notifier);
 err_sint_set_notifier:
     event_notifier_cleanup(&sint_route->sint_set_notifier);
@@ -128,7 +128,7 @@  void kvm_hv_sint_route_destroy(HvSintRoute *sint_route)
                                           &sint_route->sint_set_notifier,
                                           sint_route->gsi);
     kvm_irqchip_release_virq(kvm_state, sint_route->gsi);
-    event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL);
+    event_notifier_set_handler(&sint_route->sint_ack_notifier, false, NULL);
     event_notifier_cleanup(&sint_route->sint_ack_notifier);
     event_notifier_cleanup(&sint_route->sint_set_notifier);
     g_free(sint_route);
diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index e150301..c1f0d79 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -91,9 +91,11 @@  int event_notifier_get_fd(const EventNotifier *e)
 }
 
 int event_notifier_set_handler(EventNotifier *e,
+                               bool is_external,
                                EventNotifierHandler *handler)
 {
-    qemu_set_fd_handler(e->rfd, (IOHandler *)handler, NULL, e);
+    aio_set_fd_handler(iohandler_get_aio_context(), e->rfd, is_external,
+                       (IOHandler *)handler, NULL, e);
     return 0;
 }
 
diff --git a/util/event_notifier-win32.c b/util/event_notifier-win32.c
index 14b4f7d..de87df0 100644
--- a/util/event_notifier-win32.c
+++ b/util/event_notifier-win32.c
@@ -33,6 +33,7 @@  HANDLE event_notifier_get_handle(EventNotifier *e)
 }
 
 int event_notifier_set_handler(EventNotifier *e,
+                               bool is_external,
                                EventNotifierHandler *handler)
 {
     if (handler) {