From patchwork Wed May 26 14:09:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 53630 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 07EAEB7D12 for ; Thu, 27 May 2010 01:06:48 +1000 (EST) Received: from localhost ([127.0.0.1]:60623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHIBv-0006Av-U3 for incoming@patchwork.ozlabs.org; Wed, 26 May 2010 11:06:44 -0400 Received: from [140.186.70.92] (port=45505 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHHN8-0003N8-6g for qemu-devel@nongnu.org; Wed, 26 May 2010 10:14:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHHIz-00047H-O9 for qemu-devel@nongnu.org; Wed, 26 May 2010 10:10:00 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:38260) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHHIz-00046k-Jt for qemu-devel@nongnu.org; Wed, 26 May 2010 10:09:57 -0400 Received: by mail-wy0-f173.google.com with SMTP id 28so1007524wyf.4 for ; Wed, 26 May 2010 07:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :message-id:x-mailer:in-reply-to:references; bh=aacOIXDGpoNKQpqH3ggtgBEMCVJRaiv3BAzzMBdqp/A=; b=aGVa0i/BtK6FCRlV7oO8IMEwRHlTPwqgzAUvE9Vvg1kGvTqe2I4v1Ovgu+tkH0D64q U1vmyzRr3jIfAeVRgCspDw6Tp0BQERK6PpykpR2Ctta7xpdvALOmVIciC+y/mFHVbcBM /wG8O6ab/c57xloeuVjUYbLLel/SsN6TXMrDU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; b=RSX+P6Uf2SQxV07OS9wE6m9CtJuS9Va1WtMjOHSohr5jFVK/0JeCwoL7WwbWntMK5u i26CrePIIdmGbQgTVNq6Q5ypT/92nJDHz0v9OcR7+97x0Hp64d3AUMikW5g6WUitb3Bh 5+58xYgtnc/lVMxruF0vX42MR++A2FGRt2PMA= Received: by 10.227.128.71 with SMTP id j7mr8529741wbs.160.1274882994924; Wed, 26 May 2010 07:09:54 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com [209.132.186.34]) by mx.google.com with ESMTPS id u32sm318964wbc.11.2010.05.26.07.09.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 26 May 2010 07:09:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 26 May 2010 16:09:35 +0200 Message-Id: <1274882978-9875-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1274882978-9875-1-git-send-email-pbonzini@redhat.com> References: <1274882978-9875-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 5/8] add and use event_notifier_set_handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- event_notifier.c | 7 +++++++ event_notifier.h | 3 +++ hw/virtio-pci.c | 9 +++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/event_notifier.c b/event_notifier.c index 0f7b8da..066adb9 100644 --- a/event_notifier.c +++ b/event_notifier.c @@ -11,6 +11,7 @@ */ #include "event_notifier.h" +#include "qemu-char.h" #ifdef CONFIG_EVENTFD #include #endif @@ -38,6 +39,12 @@ int event_notifier_get_fd(EventNotifier *e) return e->fd; } +int event_notifier_set_handler(EventNotifier *e, + EventNotifierHandler *handler) +{ + return qemu_set_fd_handler(e->fd, (IOHandler *)handler, NULL, e); +} + int event_notifier_set(EventNotifier *e) { uint64_t value = 1; diff --git a/event_notifier.h b/event_notifier.h index 714d690..f6ec9ef 100644 --- a/event_notifier.h +++ b/event_notifier.h @@ -7,10 +7,13 @@ struct EventNotifier { int fd; }; +typedef void EventNotifierHandler(EventNotifier *); + int event_notifier_init(EventNotifier *, int active); void event_notifier_cleanup(EventNotifier *); int event_notifier_get_fd(EventNotifier *); int event_notifier_set(EventNotifier *); int event_notifier_test_and_clear(EventNotifier *); +int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *); #endif diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 988c75c..a7ebc83 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -419,9 +419,8 @@ static unsigned virtio_pci_get_features(void *opaque) return proxy->host_features; } -static void virtio_pci_guest_notifier_read(void *opaque) +static void virtio_pci_guest_notifier_read(EventNotifier *n) { - EventNotifier *n = opaque; VirtQueue *vq = virtqueue_from_guest_notifier(n); if (event_notifier_test_and_clear(n)) { virtio_irq(vq); @@ -439,11 +438,9 @@ static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign) if (r < 0) { return r; } - qemu_set_fd_handler(event_notifier_get_fd(notifier), - virtio_pci_guest_notifier_read, NULL, notifier); + event_notifier_set_handler(notifier, virtio_pci_guest_notifier_read); } else { - qemu_set_fd_handler(event_notifier_get_fd(notifier), - NULL, NULL, NULL); + event_notifier_set_handler(notifier, NULL); event_notifier_cleanup(notifier); }