From patchwork Tue Oct 4 14:51:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 117634 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A7C0FB6F6F for ; Wed, 5 Oct 2011 01:51:53 +1100 (EST) Received: from localhost ([::1]:44344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RB6LW-0007fD-Dn for incoming@patchwork.ozlabs.org; Tue, 04 Oct 2011 10:51:50 -0400 Received: from eggs.gnu.org ([140.186.70.92]:41054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RB6LM-0007eP-7O for qemu-devel@nongnu.org; Tue, 04 Oct 2011 10:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RB6LH-0003nT-BT for qemu-devel@nongnu.org; Tue, 04 Oct 2011 10:51:40 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:37924) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RB6LH-0003mn-8e for qemu-devel@nongnu.org; Tue, 04 Oct 2011 10:51:35 -0400 X-IronPort-AV: E=Sophos;i="4.68,485,1312171200"; d="scan'208";a="165647585" Received: from ftlpmailmx02.citrite.net ([10.13.107.66]) by FTLPIPO02.CITRIX.COM with ESMTP/TLS/RC4-MD5; 04 Oct 2011 10:51:34 -0400 Received: from smtp01.ad.xensource.com (10.219.128.104) by smtprelay.citrix.com (10.13.107.66) with Microsoft SMTP Server id 8.3.137.0; Tue, 4 Oct 2011 10:51:34 -0400 Received: from perard.uk.xensource.com (dhcp-3-28.uk.xensource.com [10.80.3.28] (may be forged)) by smtp01.ad.xensource.com (8.13.1/8.13.1) with ESMTP id p94EpSs3017018; Tue, 4 Oct 2011 07:51:32 -0700 From: Anthony PERARD To: QEMU-devel Date: Tue, 4 Oct 2011 15:51:13 +0100 Message-ID: <1317739882-4809-3-git-send-email-anthony.perard@citrix.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1317739882-4809-1-git-send-email-anthony.perard@citrix.com> References: <1317739882-4809-1-git-send-email-anthony.perard@citrix.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Cc: Anthony PERARD , Alex Williamson , Xen Devel , Stefano Stabellini Subject: [Qemu-devel] [PATCH RFC V1 02/11] qemu-timer: Introduce qemu_run_one_timer 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 Used by the Xen PCI Passthrough code to run the timer about the power state transition. Signed-off-by: Anthony PERARD --- qemu-timer.c | 15 +++++++++++++++ qemu-timer.h | 3 +++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 46dd483..15e659b 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -1163,3 +1163,18 @@ int qemu_calculate_timeout(void) return 1000; } +/* run the specified timer */ +void qemu_run_one_timer(QEMUTimer *ts) +{ + uint64_t current_time; + + /* remove timer from the list before calling the callback */ + qemu_del_timer(ts); + + while ((current_time = qemu_get_clock_ms(rt_clock)) < ts->expire_time) + /* sleep until the expire time */ + usleep((ts->expire_time - current_time) * 1000); + + /* run the callback */ + ts->cb(ts->opaque); +} diff --git a/qemu-timer.h b/qemu-timer.h index 0a43469..b7b907b 100644 --- a/qemu-timer.h +++ b/qemu-timer.h @@ -338,4 +338,7 @@ extern int64_t tlb_flush_time; extern int64_t dev_time; #endif +/* run the specified timer */ +void qemu_run_one_timer(QEMUTimer *ts); + #endif