From patchwork Thu Jul 5 15:16:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1161261 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 234253FE4F for ; Thu, 5 Jul 2012 15:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933198Ab2GEPRX (ORCPT ); Thu, 5 Jul 2012 11:17:23 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:52063 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933155Ab2GEPRW (ORCPT ); Thu, 5 Jul 2012 11:17:22 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so12925038pbb.19 for ; Thu, 05 Jul 2012 08:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=g/D5ctnBSiaokEyIsj9BGs91yjz2OYLM0dJ5NB8pii4=; b=NONeYJPtGqxU46XNTu1QEINSJJLewRI/PeAh60+SZ04CYMJRGnr0Wp5ZvKzMHvz6/K K/HxjkPx8BnSKEPD7MxQTDCE+AAYW2HfZB989whZrtH7lmjcr1jkVBvIY5DpDMYYiG81 puLeB6MBo1mGpCCPnI9F9DyPz0Ie4Aa13JibAL97957J5HnLYfCLoZA8DORnUx5dLtCq 4U2VezdDO5BRB1cos1eFZds2WlXocSpUDwhFnxIGhnB4/VtrlV0UCyHaufw3LqNZUMLM XcxPDQlu1/C8KUkMapJdjqLLubexl+zm7Nb90O1Xw7ifC24pureXFQtIJkq5XEX7+BvB nZOQ== Received: by 10.68.190.40 with SMTP id gn8mr29180600pbc.118.1341501442239; Thu, 05 Jul 2012 08:17:22 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-189-113.ip51.fastwebnet.it. [93.34.189.113]) by mx.google.com with ESMTPS id jv6sm19931888pbc.40.2012.07.05.08.17.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 08:17:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org, anthony.perard@citrix.com, jan.kiszka@siemens.com, mst@redhat.com, stefano.stabellini@eu.citrix.com Subject: [PATCH uq/master 7/9] event_notifier: add event_notifier_set_handler Date: Thu, 5 Jul 2012 17:16:28 +0200 Message-Id: <1341501390-797-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.2 In-Reply-To: <1341501390-797-1-git-send-email-pbonzini@redhat.com> References: <1341501390-797-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Win32 event notifiers are not file descriptors, so they will not be able to use qemu_set_fd_handler. But even if for now we only have a POSIX version of EventNotifier, we can add a specific function that wraps the call. The wrapper passes the EventNotifier as the opaque value so that it will be used with container_of. Signed-off-by: Paolo Bonzini --- event_notifier.c | 7 +++++++ event_notifier.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/event_notifier.c b/event_notifier.c index 99c376c..2c207e1 100644 --- a/event_notifier.c +++ b/event_notifier.c @@ -12,6 +12,7 @@ #include "qemu-common.h" #include "event_notifier.h" +#include "qemu-char.h" #ifdef CONFIG_EVENTFD #include @@ -45,6 +46,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 30c12dd..e5888ed 100644 --- a/event_notifier.h +++ b/event_notifier.h @@ -19,11 +19,14 @@ struct EventNotifier { int fd; }; +typedef void EventNotifierHandler(EventNotifier *); + void event_notifier_init_fd(EventNotifier *, int fd); 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