From patchwork Thu Jul 25 22:16:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Bligh X-Patchwork-Id: 261975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8CC322C00E1 for ; Fri, 26 Jul 2013 08:23:00 +1000 (EST) Received: from localhost ([::1]:49096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2Trk-0007x4-SP for incoming@patchwork.ozlabs.org; Thu, 25 Jul 2013 18:18:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2Tr3-0007oR-0U for qemu-devel@nongnu.org; Thu, 25 Jul 2013 18:17:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2Tr1-0006SR-3G for qemu-devel@nongnu.org; Thu, 25 Jul 2013 18:17:48 -0400 Received: from mail.avalus.com ([2001:41c8:10:1dd::10]:52758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2Tr0-0006Qq-Tk for qemu-devel@nongnu.org; Thu, 25 Jul 2013 18:17:47 -0400 Received: by mail.avalus.com (Postfix) with ESMTPSA id 473AAC561AC; Thu, 25 Jul 2013 23:17:46 +0100 (BST) From: Alex Bligh To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2013 23:16:42 +0100 Message-Id: <1374790608-7518-7-git-send-email-alex@alex.org.uk> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374790608-7518-1-git-send-email-alex@alex.org.uk> References: <20130725093713.GG21033@stefanha-thinkpad.redhat.com> <1374790608-7518-1-git-send-email-alex@alex.org.uk> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:41c8:10:1dd::10 Cc: Kevin Wolf , Anthony Liguori , Alex Bligh , Stefan Hajnoczi , Paolo Bonzini , rth@twiddle.net Subject: [Qemu-devel] [RFC] [PATCHv3 06/12] aio / timers: Add an AioContext pointer to QEMUClock X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add an AioContext pointer to QEMUClock so it knows what to notify on a timer change. Signed-off-by: Alex Bligh --- async.c | 1 + include/qemu/timer.h | 3 +++ qemu-timer.c | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/async.c b/async.c index 0d41431..2968c68 100644 --- a/async.c +++ b/async.c @@ -217,6 +217,7 @@ AioContext *aio_context_new(void) (EventNotifierHandler *) event_notifier_test_and_clear, NULL); ctx->clock = qemu_new_clock(QEMU_CLOCK_REALTIME); + qemu_clock_set_ctx(ctx->clock, ctx); return ctx; } diff --git a/include/qemu/timer.h b/include/qemu/timer.h index a1f2ac8..29817ab 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -16,6 +16,7 @@ #define QEMU_CLOCK_HOST 2 typedef struct QEMUClock QEMUClock; +typedef struct AioContext AioContext; typedef void QEMUTimerCB(void *opaque); /* The real time clock should be used only for stuff which does not @@ -38,6 +39,8 @@ extern QEMUClock *host_clock; QEMUClock *qemu_new_clock(int type); void qemu_free_clock(QEMUClock *clock); +AioContext *qemu_clock_get_ctx(QEMUClock *clock); +void qemu_clock_set_ctx(QEMUClock *clock, AioContext * ctx); int64_t qemu_get_clock_ns(QEMUClock *clock); int64_t qemu_clock_has_timers(QEMUClock *clock); int64_t qemu_clock_expired(QEMUClock *clock); diff --git a/qemu-timer.c b/qemu-timer.c index 714bc92..6efd1b4 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -29,6 +29,7 @@ #include "hw/hw.h" #include "qemu/timer.h" +#include "block/aio.h" #ifdef CONFIG_POSIX #include #endif @@ -50,6 +51,7 @@ struct QEMUClock { QEMUTimer *active_timers; + AioContext *ctx; NotifierList reset_notifiers; int64_t last; @@ -252,6 +254,16 @@ void qemu_free_clock(QEMUClock *clock) g_free(clock); } +AioContext *qemu_clock_get_ctx(QEMUClock *clock) +{ + return clock->ctx; +} + +void qemu_clock_set_ctx(QEMUClock *clock, AioContext * ctx) +{ + clock->ctx = ctx; +} + void qemu_clock_enable(QEMUClock *clock, bool enabled) { bool old = clock->enabled;