From patchwork Thu Jul 5 15:16:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1161201 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A0E51DFFCC for ; Thu, 5 Jul 2012 15:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932937Ab2GEPQ6 (ORCPT ); Thu, 5 Jul 2012 11:16:58 -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 S932530Ab2GEPQ4 (ORCPT ); Thu, 5 Jul 2012 11:16:56 -0400 Received: by pbbrp8 with SMTP id rp8so12925038pbb.19 for ; Thu, 05 Jul 2012 08:16:55 -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=ElHxu0CS1+G7ZxhGjVQIS8k/v58HANgZ9PLBESGf1JQ=; b=G/yrL/TbGRGvLmdYbEdtoMYpwzDVwGFHO/D1eGVLDE65N+5cb1+9jIWPclzQsX/XDr HjchbcaNN509Y4YYym5JfCXs8GsD9dILYUvcmAOm8b+uGrXyXSIS4u9XgT7SnDiXsRzi OzJ1luDqzvDo+ShdvYVFudENWhFCAyKPT8Hd6Ok4jBHWpgejFFEy8quzY1DhWP0tdeUT IBsCT2SZTylDPHs4tfJdzrWyi10bD+3CuzpTvsp3LPvxtHVzOtHJTKJMMX8SnUjVdxhm 1q5KRuINPSPG/plc+OeLzoYT00i3myn7ns9GVQR0lMq64cus2s4wgXTQjBldaXduyg47 I/1Q== Received: by 10.68.232.197 with SMTP id tq5mr28551293pbc.53.1341501415702; Thu, 05 Jul 2012 08:16:55 -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.16.51 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 08:16:54 -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 1/9] event_notifier: add event_notifier_set Date: Thu, 5 Jul 2012 17:16:22 +0200 Message-Id: <1341501390-797-2-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 EventNotifier right now cannot be used as an inter-thread communication primitive. It only works if something else (the kernel) sets the eventfd. Add a primitive to signal an EventNotifier that another thread is waiting on. Signed-off-by: Paolo Bonzini --- event_notifier.c | 7 +++++++ event_notifier.h | 1 + 2 files changed, 8 insertions(+) diff --git a/event_notifier.c b/event_notifier.c index 0b82981..2b210f4 100644 --- a/event_notifier.c +++ b/event_notifier.c @@ -38,6 +38,13 @@ int event_notifier_get_fd(EventNotifier *e) return e->fd; } +int event_notifier_set(EventNotifier *e) +{ + uint64_t value = 1; + int r = write(e->fd, &value, sizeof(value)); + return r == sizeof(value); +} + int event_notifier_test_and_clear(EventNotifier *e) { uint64_t value; diff --git a/event_notifier.h b/event_notifier.h index 886222c..efca852 100644 --- a/event_notifier.h +++ b/event_notifier.h @@ -22,6 +22,7 @@ struct 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_test(EventNotifier *);