From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V8ulM-0005Xy-SN for qemu-devel@nongnu.org; Mon, 12 Aug 2013 12:14:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V8ulG-0003OK-M8 for qemu-devel@nongnu.org; Mon, 12 Aug 2013 12:14:32 -0400 Received: from goliath.siemens.de ([192.35.17.28]:21801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V8ulG-0003NQ-Bl for qemu-devel@nongnu.org; Mon, 12 Aug 2013 12:14:26 -0400 Message-ID: <520909D0.3040203@siemens.com> Date: Mon, 12 Aug 2013 18:14:08 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1376239405-4084-1-git-send-email-alex@alex.org.uk> <1376239405-4084-9-git-send-email-alex@alex.org.uk> In-Reply-To: <1376239405-4084-9-git-send-email-alex@alex.org.uk> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC] [PATCHv10 08/31] aio / timers: Split QEMUClock into QEMUClock and QEMUTimerList List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: Kevin Wolf , Anthony Liguori , qemu-devel@nongnu.org, liu ping fan , Stefan Hajnoczi , Paolo Bonzini , MORITA Kazutaka , rth@twiddle.net On 2013-08-11 18:43, Alex Bligh wrote: > Split QEMUClock into QEMUClock and QEMUTimerList so that we can > have more than one QEMUTimerList associated with the same clock. > > Introduce a main_loop_timerlist concept and make existing > qemu_clock_* calls that actually should operate on a QEMUTimerList > call the relevant QEMUTimerList implementations, using the clock's > default timerlist. This vastly reduces the invasiveness of this > change and means the API stays constant for existing users. > > Introduce a list of QEMUTimerLists associated with each clock > so that reenabling the clock can cause all the notifiers > to be called. Note the code to do the notifications is added > in a later patch. > > Switch QEMUClockType to an enum. Remove global variables vm_clock, > host_clock and rt_clock and add compatibility defines. Do not > fix qemu_next_alarm_deadline as it's going to be deleted. > > Add qemu_clock_use_for_deadline to indicate whether a particular > clock should be used for deadline calculations. When use_icount > is true, vm_clock should not be used for deadline calculations > as it does not contain a nanosecond count. Instead, icount > timeouts come from the execution thread doing aio_notify or > qemu_notify as appropriate. This function is used in the next > patch. > > Signed-off-by: Alex Bligh > --- > include/qemu/timer.h | 347 ++++++++++++++++++++++++++++++++++++++++++++++---- > qemu-timer.c | 207 ++++++++++++++++++++++-------- > 2 files changed, 475 insertions(+), 79 deletions(-) > > diff --git a/include/qemu/timer.h b/include/qemu/timer.h > index fcb6a42..a217a81 100644 > --- a/include/qemu/timer.h > +++ b/include/qemu/timer.h > @@ -11,34 +11,84 @@ > #define SCALE_US 1000 > #define SCALE_NS 1 > > -#define QEMU_CLOCK_REALTIME 0 > -#define QEMU_CLOCK_VIRTUAL 1 > -#define QEMU_CLOCK_HOST 2 > +/** > + * QEMUClockType: > + * > + * The following clock types are available: > + * > + * @QEMU_CLOCK_REALTIME: Real time clock > + * > + * The real time clock should be used only for stuff which does not > + * change the virtual machine state, as it is run even if the virtual > + * machine is stopped. The real time clock has a frequency of 1000 > + * Hz. > + * > + * Formerly rt_clock > + * > + * @QEMU_CLOCK_VIRTUAL: virtual clock > + * > + * The virtual clock is only run during the emulation. It is stopped > + * when the virtual machine is stopped. Virtual timers use a high > + * precision clock, usually cpu cycles (use ticks_per_sec). > + * > + * Formerly vm_clock > + * > + * @QEMU_CLOCK_HOST: host clock > + * > + * The host clock should be use for device models that emulate accurate > + * real time sources. It will continue to run when the virtual machine > + * is suspended, and it will reflect system time changes the host may > + * undergo (e.g. due to NTP). The host clock has the same precision as > + * the virtual clock. > + * > + * Formerly host_clock > + */ > + > +typedef enum { > + QEMU_CLOCK_REALTIME = 0, > + QEMU_CLOCK_VIRTUAL = 1, > + QEMU_CLOCK_HOST = 2, > + QEMU_CLOCK_MAX > +} QEMUClockType; > > typedef struct QEMUClock QEMUClock; > +typedef struct QEMUTimerList QEMUTimerList; > typedef void QEMUTimerCB(void *opaque); > > -/* The real time clock should be used only for stuff which does not > - change the virtual machine state, as it is run even if the virtual > - machine is stopped. The real time clock has a frequency of 1000 > - Hz. */ > -extern QEMUClock *rt_clock; > +typedef struct QEMUTimer { > + int64_t expire_time; /* in nanoseconds */ > + QEMUTimerList *timer_list; > + QEMUTimerCB *cb; > + void *opaque; > + QEMUTimer *next; > + int scale; > +} QEMUTimer; The typedef part is a duplication of what we already have in qemu/typedefs.h and breaks the build for me. Just declare the struct here. Jan -- Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux