From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Alex Bligh Date: Thu, 25 Jul 2013 23:16:42 +0100 Message-Id: <1374790608-7518-7-git-send-email-alex@alex.org.uk> 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> Subject: [Qemu-devel] [RFC] [PATCHv3 06/12] aio / timers: Add an AioContext pointer to QEMUClock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori , Alex Bligh , Stefan Hajnoczi , Paolo Bonzini , rth@twiddle.net 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; -- 1.7.9.5