All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Tettamanti <kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
Cc: kvm-devel-TtF/mJH4Jtrk1uMJSBkQmQ@public.gmane.org,
	Luca Tettamanti
	<kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 1/4] Rework alarm timer infrastrucure.
Date: Sat, 18 Aug 2007 01:11:50 +0200	[thread overview]
Message-ID: <20070817231405.883008474@gmail.com> (raw)
In-Reply-To: 20070817231149.544849769@gmail.com

[-- Attachment #1: clock-base --]
[-- Type: text/plain, Size: 10350 bytes --]

Make the alarm code modular, removing #ifdef from the generic code and
abstract a common interface for all the timer. The result is functionally
equivalent to the old code.

Signed-off-by: Luca Tettamanti <kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

---
 vl.c |  287 +++++++++++++++++++++++++++++++++++++++++++------------------------
 vl.h |    1 
 2 files changed, 185 insertions(+), 103 deletions(-)

Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c	2007-08-17 16:48:32.000000000 +0200
+++ qemu/vl.c	2007-08-18 00:40:25.000000000 +0200
@@ -781,18 +781,58 @@
     struct QEMUTimer *next;
 };
 
-QEMUClock *rt_clock;
-QEMUClock *vm_clock;
+struct qemu_alarm_timer {
+    char const *name;
+
+    int (*start)(struct qemu_alarm_timer *t);
+    void (*stop)(struct qemu_alarm_timer *t);
+    void *priv;
+};
+
+static struct qemu_alarm_timer *alarm_timer;
 
-static QEMUTimer *active_timers[2];
 #ifdef _WIN32
-static MMRESULT timerID;
-static HANDLE host_alarm = NULL;
-static unsigned int period = 1;
+
+struct qemu_alarm_win32 {
+    MMRESULT timerId;
+    HANDLE host_alarm;
+    unsigned int period;
+} alarm_win32_data = {0, NULL, -1};
+
+static int win32_start_timer(struct qemu_alarm_timer *t);
+static void win32_stop_timer(struct qemu_alarm_timer *t);
+
+#else
+
+static int unix_start_timer(struct qemu_alarm_timer *t);
+static void unix_stop_timer(struct qemu_alarm_timer *t);
+
+#ifdef __linux__
+
+static int rtc_start_timer(struct qemu_alarm_timer *t);
+static void rtc_stop_timer(struct qemu_alarm_timer *t);
+
+#endif
+
+#endif /* _WIN32 */
+
+static struct qemu_alarm_timer alarm_timers[] = {
+#ifdef __linux__
+    /* RTC - if available - is preferred */
+    {"rtc", rtc_start_timer, rtc_stop_timer, NULL},
+#endif
+#ifndef _WIN32
+    {"unix", unix_start_timer, unix_stop_timer, NULL},
 #else
-/* frequency of the times() clock tick */
-static int timer_freq;
+    {"win32", win32_start_timer, win32_stop_timer, &alarm_win32_data},
 #endif
+    {NULL, }
+};
+
+QEMUClock *rt_clock;
+QEMUClock *vm_clock;
+
+static QEMUTimer *active_timers[2];
 
 QEMUClock *qemu_new_clock(int type)
 {
@@ -1009,7 +1049,8 @@
         qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME],
                            qemu_get_clock(rt_clock))) {
 #ifdef _WIN32
-        SetEvent(host_alarm);
+        struct qemu_alarm_win32 *data = ((struct qemu_alarm_timer*)dwUser)->priv;
+        SetEvent(data->host_alarm);
 #endif
         CPUState *env = cpu_single_env;
         if (env) {
@@ -1030,10 +1071,27 @@
 
 #define RTC_FREQ 1024
 
-static int rtc_fd;
+static void enable_sigio_timer(int fd)
+{
+    struct sigaction act;
 
-static int start_rtc_timer(void)
+    /* timer signal */
+    sigfillset(&act.sa_mask);
+    act.sa_flags = 0;
+#if defined (TARGET_I386) && defined(USE_CODE_COPY)
+    act.sa_flags |= SA_ONSTACK;
+#endif
+    act.sa_handler = host_alarm_handler;
+
+    sigaction(SIGIO, &act, NULL);
+    fcntl(fd, F_SETFL, O_ASYNC);
+    fcntl(fd, F_SETOWN, getpid());
+}
+
+static int rtc_start_timer(struct qemu_alarm_timer *t)
 {
+    int rtc_fd;
+
     TFR(rtc_fd = open("/dev/rtc", O_RDONLY));
     if (rtc_fd < 0)
         return -1;
@@ -1048,117 +1106,142 @@
         close(rtc_fd);
         return -1;
     }
-    pit_min_timer_count = PIT_FREQ / RTC_FREQ;
+
+    enable_sigio_timer(rtc_fd);
+
+    t->priv = (void *)rtc_fd;
+
     return 0;
 }
 
-#else
-
-static int start_rtc_timer(void)
+static void rtc_stop_timer(struct qemu_alarm_timer *t)
 {
-    return -1;
+    int rtc_fd = (int)t->priv;
+
+    close(rtc_fd);
 }
 
 #endif /* !defined(__linux__) */
 
-#endif /* !defined(_WIN32) */
+static int unix_start_timer(struct qemu_alarm_timer *t)
+{
+    struct sigaction act;
+    struct itimerval itv;
+    int err;
+
+    /* timer signal */
+    sigfillset(&act.sa_mask);
+    act.sa_flags = 0;
+#if defined(TARGET_I386) && defined(USE_CODE_COPY)
+    act.sa_flags |= SA_ONSTACK;
+#endif
+    act.sa_handler = host_alarm_handler;
+
+    sigaction(SIGALRM, &act, NULL);
+
+    itv.it_interval.tv_sec = 0;
+    /* for i386 kernel 2.6 to get 1 ms */
+    itv.it_interval.tv_usec = 999;
+    itv.it_value.tv_sec = 0;
+    itv.it_value.tv_usec = 10 * 1000;
 
-static void init_timer_alarm(void)
+    err = setitimer(ITIMER_REAL, &itv, NULL);
+    if (err)
+        return -1;
+
+    return 0;
+}
+
+static void unix_stop_timer(struct qemu_alarm_timer *t)
 {
+    struct itimerval itv;
+
+    memset(&itv, 0, sizeof(itv));
+    setitimer(ITIMER_REAL, &itv, NULL);
+}
+
+#endif /* !defined(_WIN32) */
+
 #ifdef _WIN32
-    {
-        int count=0;
-        TIMECAPS tc;
 
-        ZeroMemory(&tc, sizeof(TIMECAPS));
-        timeGetDevCaps(&tc, sizeof(TIMECAPS));
-        if (period < tc.wPeriodMin)
-            period = tc.wPeriodMin;
-        timeBeginPeriod(period);
-        timerID = timeSetEvent(1,     // interval (ms)
-                               period,     // resolution
-                               host_alarm_handler, // function
-                               (DWORD)&count,  // user parameter
-                               TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
- 	if( !timerID ) {
-            perror("failed timer alarm");
-            exit(1);
- 	}
-        host_alarm = CreateEvent(NULL, FALSE, FALSE, NULL);
-        if (!host_alarm) {
-            perror("failed CreateEvent");
-            exit(1);
-        }
-        qemu_add_wait_object(host_alarm, NULL, NULL);
+static int win32_start_timer(struct qemu_alarm_timer *t)
+{
+    TIMECAPS tc;
+    struct qemu_alarm_win32 *data = t->priv;
+
+    data->host_alarm = CreateEvent(NULL, FALSE, FALSE, NULL);
+    if (!data->host_alarm) {
+        perror("Failed CreateEvent");
+        return -1
     }
-    pit_min_timer_count = ((uint64_t)10000 * PIT_FREQ) / 1000000;
-#else
-    {
-        struct sigaction act;
-        struct itimerval itv;
-        
-        /* get times() syscall frequency */
-        timer_freq = sysconf(_SC_CLK_TCK);
-        
-        /* timer signal */
-        sigfillset(&act.sa_mask);
-       act.sa_flags = 0;
-#if defined (TARGET_I386) && defined(USE_CODE_COPY)
-        act.sa_flags |= SA_ONSTACK;
-#endif
-        act.sa_handler = host_alarm_handler;
-        sigaction(SIGALRM, &act, NULL);
 
-        itv.it_interval.tv_sec = 0;
-        itv.it_interval.tv_usec = 999; /* for i386 kernel 2.6 to get 1 ms */
-        itv.it_value.tv_sec = 0;
-        itv.it_value.tv_usec = 10 * 1000;
-        setitimer(ITIMER_REAL, &itv, NULL);
-        /* we probe the tick duration of the kernel to inform the user if
-           the emulated kernel requested a too high timer frequency */
-        getitimer(ITIMER_REAL, &itv);
+    memset(&tc, 0, sizeof(tc));
+    timeGetDevCaps(&tc, sizeof(tc));
 
-#if defined(__linux__)
-        /* XXX: force /dev/rtc usage because even 2.6 kernels may not
-           have timers with 1 ms resolution. The correct solution will
-           be to use the POSIX real time timers available in recent
-           2.6 kernels */
-        if (itv.it_interval.tv_usec > 1000 || 1) {
-            /* try to use /dev/rtc to have a faster timer */
-            if (start_rtc_timer() < 0)
-                goto use_itimer;
-            /* disable itimer */
-            itv.it_interval.tv_sec = 0;
-            itv.it_interval.tv_usec = 0;
-            itv.it_value.tv_sec = 0;
-            itv.it_value.tv_usec = 0;
-            setitimer(ITIMER_REAL, &itv, NULL);
-
-            /* use the RTC */
-            sigaction(SIGIO, &act, NULL);
-            fcntl(rtc_fd, F_SETFL, O_ASYNC);
-            fcntl(rtc_fd, F_SETOWN, getpid());
-        } else 
-#endif /* defined(__linux__) */
-        {
-        use_itimer:
-            pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * 
-                                   PIT_FREQ) / 1000000;
-        }
+    if (data->period < tc.wPeriodMin)
+        data->period = tc.wPeriodMin;
+
+    timeBeginPeriod(data->period);
+
+    data->timerId = timeSetEvent(1,         // interval (ms)
+                        data->period,       // resolution
+                        host_alarm_handler, // function
+                        (DWORD)t,           // parameter
+                        TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
+
+    if (!data->timerId) {
+        perror("Failed to initialize win32 alarm timer");
+
+        timeEndPeriod(data->period);
+        CloseHandle(data->host_alarm);
+        return -1;
     }
-#endif
+
+    qemu_add_wait_object(data->host_alarm, NULL, NULL);
+
+    return 0;
 }
 
-void quit_timers(void)
+static void win32_stop_timer(struct qemu_alarm_timer *t)
 {
-#ifdef _WIN32
-    timeKillEvent(timerID);
-    timeEndPeriod(period);
-    if (host_alarm) {
-        CloseHandle(host_alarm);
-        host_alarm = NULL;
+    struct qemu_alarm_win32 *data = t->priv;
+
+    timeKillEvent(data->timerId);
+    timeEndPeriod(data->period);
+
+    CloseHandle(data->host_alarm);
+}
+
+#endif /* _WIN32 */
+
+static void init_timer_alarm(void)
+{
+    struct qemu_alarm_timer *t;
+    int i, err = -1;
+
+    for (i = 0; alarm_timers[i].name; i++) {
+        t = &alarm_timers[i];
+
+        printf("trying %s...\n", t->name);
+
+        err = t->start(t);
+        if (!err)
+            break;
     }
-#endif
+
+    if (err) {
+        fprintf(stderr, "Unable to find any suitable alarm timer.\n");
+        fprintf(stderr, "Terminating\n");
+        exit(1);
+    }
+
+    alarm_timer = t;
+}
+
+void quit_timers(void)
+{
+    alarm_timer->stop(alarm_timer);
+    alarm_timer = NULL;
 }
 
 /***********************************************************/
Index: qemu/vl.h
===================================================================
--- qemu.orig/vl.h	2007-08-17 17:03:26.000000000 +0200
+++ qemu/vl.h	2007-08-17 17:03:37.000000000 +0200
@@ -447,7 +447,6 @@
 int qemu_timer_pending(QEMUTimer *ts);
 
 extern int64_t ticks_per_sec;
-extern int pit_min_timer_count;
 
 int64_t cpu_get_ticks(void);
 void cpu_enable_ticks(void);

-- 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

WARNING: multiple messages have this Message-ID (diff)
From: Luca Tettamanti <kronos.it@gmail.com>
To: qemu-devel@nongnu.org
Cc: kvm-devel@lists.sf.net, Luca Tettamanti <kronos.it@gmail.com>
Subject: [Qemu-devel] [PATCH 1/4] Rework alarm timer infrastrucure.
Date: Sat, 18 Aug 2007 01:11:50 +0200	[thread overview]
Message-ID: <20070817231405.883008474@gmail.com> (raw)
In-Reply-To: 20070817231149.544849769@gmail.com

[-- Attachment #1: clock-base --]
[-- Type: text/plain, Size: 10003 bytes --]

Make the alarm code modular, removing #ifdef from the generic code and
abstract a common interface for all the timer. The result is functionally
equivalent to the old code.

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>

---
 vl.c |  287 +++++++++++++++++++++++++++++++++++++++++++------------------------
 vl.h |    1 
 2 files changed, 185 insertions(+), 103 deletions(-)

Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c	2007-08-17 16:48:32.000000000 +0200
+++ qemu/vl.c	2007-08-18 00:40:25.000000000 +0200
@@ -781,18 +781,58 @@
     struct QEMUTimer *next;
 };
 
-QEMUClock *rt_clock;
-QEMUClock *vm_clock;
+struct qemu_alarm_timer {
+    char const *name;
+
+    int (*start)(struct qemu_alarm_timer *t);
+    void (*stop)(struct qemu_alarm_timer *t);
+    void *priv;
+};
+
+static struct qemu_alarm_timer *alarm_timer;
 
-static QEMUTimer *active_timers[2];
 #ifdef _WIN32
-static MMRESULT timerID;
-static HANDLE host_alarm = NULL;
-static unsigned int period = 1;
+
+struct qemu_alarm_win32 {
+    MMRESULT timerId;
+    HANDLE host_alarm;
+    unsigned int period;
+} alarm_win32_data = {0, NULL, -1};
+
+static int win32_start_timer(struct qemu_alarm_timer *t);
+static void win32_stop_timer(struct qemu_alarm_timer *t);
+
+#else
+
+static int unix_start_timer(struct qemu_alarm_timer *t);
+static void unix_stop_timer(struct qemu_alarm_timer *t);
+
+#ifdef __linux__
+
+static int rtc_start_timer(struct qemu_alarm_timer *t);
+static void rtc_stop_timer(struct qemu_alarm_timer *t);
+
+#endif
+
+#endif /* _WIN32 */
+
+static struct qemu_alarm_timer alarm_timers[] = {
+#ifdef __linux__
+    /* RTC - if available - is preferred */
+    {"rtc", rtc_start_timer, rtc_stop_timer, NULL},
+#endif
+#ifndef _WIN32
+    {"unix", unix_start_timer, unix_stop_timer, NULL},
 #else
-/* frequency of the times() clock tick */
-static int timer_freq;
+    {"win32", win32_start_timer, win32_stop_timer, &alarm_win32_data},
 #endif
+    {NULL, }
+};
+
+QEMUClock *rt_clock;
+QEMUClock *vm_clock;
+
+static QEMUTimer *active_timers[2];
 
 QEMUClock *qemu_new_clock(int type)
 {
@@ -1009,7 +1049,8 @@
         qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME],
                            qemu_get_clock(rt_clock))) {
 #ifdef _WIN32
-        SetEvent(host_alarm);
+        struct qemu_alarm_win32 *data = ((struct qemu_alarm_timer*)dwUser)->priv;
+        SetEvent(data->host_alarm);
 #endif
         CPUState *env = cpu_single_env;
         if (env) {
@@ -1030,10 +1071,27 @@
 
 #define RTC_FREQ 1024
 
-static int rtc_fd;
+static void enable_sigio_timer(int fd)
+{
+    struct sigaction act;
 
-static int start_rtc_timer(void)
+    /* timer signal */
+    sigfillset(&act.sa_mask);
+    act.sa_flags = 0;
+#if defined (TARGET_I386) && defined(USE_CODE_COPY)
+    act.sa_flags |= SA_ONSTACK;
+#endif
+    act.sa_handler = host_alarm_handler;
+
+    sigaction(SIGIO, &act, NULL);
+    fcntl(fd, F_SETFL, O_ASYNC);
+    fcntl(fd, F_SETOWN, getpid());
+}
+
+static int rtc_start_timer(struct qemu_alarm_timer *t)
 {
+    int rtc_fd;
+
     TFR(rtc_fd = open("/dev/rtc", O_RDONLY));
     if (rtc_fd < 0)
         return -1;
@@ -1048,117 +1106,142 @@
         close(rtc_fd);
         return -1;
     }
-    pit_min_timer_count = PIT_FREQ / RTC_FREQ;
+
+    enable_sigio_timer(rtc_fd);
+
+    t->priv = (void *)rtc_fd;
+
     return 0;
 }
 
-#else
-
-static int start_rtc_timer(void)
+static void rtc_stop_timer(struct qemu_alarm_timer *t)
 {
-    return -1;
+    int rtc_fd = (int)t->priv;
+
+    close(rtc_fd);
 }
 
 #endif /* !defined(__linux__) */
 
-#endif /* !defined(_WIN32) */
+static int unix_start_timer(struct qemu_alarm_timer *t)
+{
+    struct sigaction act;
+    struct itimerval itv;
+    int err;
+
+    /* timer signal */
+    sigfillset(&act.sa_mask);
+    act.sa_flags = 0;
+#if defined(TARGET_I386) && defined(USE_CODE_COPY)
+    act.sa_flags |= SA_ONSTACK;
+#endif
+    act.sa_handler = host_alarm_handler;
+
+    sigaction(SIGALRM, &act, NULL);
+
+    itv.it_interval.tv_sec = 0;
+    /* for i386 kernel 2.6 to get 1 ms */
+    itv.it_interval.tv_usec = 999;
+    itv.it_value.tv_sec = 0;
+    itv.it_value.tv_usec = 10 * 1000;
 
-static void init_timer_alarm(void)
+    err = setitimer(ITIMER_REAL, &itv, NULL);
+    if (err)
+        return -1;
+
+    return 0;
+}
+
+static void unix_stop_timer(struct qemu_alarm_timer *t)
 {
+    struct itimerval itv;
+
+    memset(&itv, 0, sizeof(itv));
+    setitimer(ITIMER_REAL, &itv, NULL);
+}
+
+#endif /* !defined(_WIN32) */
+
 #ifdef _WIN32
-    {
-        int count=0;
-        TIMECAPS tc;
 
-        ZeroMemory(&tc, sizeof(TIMECAPS));
-        timeGetDevCaps(&tc, sizeof(TIMECAPS));
-        if (period < tc.wPeriodMin)
-            period = tc.wPeriodMin;
-        timeBeginPeriod(period);
-        timerID = timeSetEvent(1,     // interval (ms)
-                               period,     // resolution
-                               host_alarm_handler, // function
-                               (DWORD)&count,  // user parameter
-                               TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
- 	if( !timerID ) {
-            perror("failed timer alarm");
-            exit(1);
- 	}
-        host_alarm = CreateEvent(NULL, FALSE, FALSE, NULL);
-        if (!host_alarm) {
-            perror("failed CreateEvent");
-            exit(1);
-        }
-        qemu_add_wait_object(host_alarm, NULL, NULL);
+static int win32_start_timer(struct qemu_alarm_timer *t)
+{
+    TIMECAPS tc;
+    struct qemu_alarm_win32 *data = t->priv;
+
+    data->host_alarm = CreateEvent(NULL, FALSE, FALSE, NULL);
+    if (!data->host_alarm) {
+        perror("Failed CreateEvent");
+        return -1
     }
-    pit_min_timer_count = ((uint64_t)10000 * PIT_FREQ) / 1000000;
-#else
-    {
-        struct sigaction act;
-        struct itimerval itv;
-        
-        /* get times() syscall frequency */
-        timer_freq = sysconf(_SC_CLK_TCK);
-        
-        /* timer signal */
-        sigfillset(&act.sa_mask);
-       act.sa_flags = 0;
-#if defined (TARGET_I386) && defined(USE_CODE_COPY)
-        act.sa_flags |= SA_ONSTACK;
-#endif
-        act.sa_handler = host_alarm_handler;
-        sigaction(SIGALRM, &act, NULL);
 
-        itv.it_interval.tv_sec = 0;
-        itv.it_interval.tv_usec = 999; /* for i386 kernel 2.6 to get 1 ms */
-        itv.it_value.tv_sec = 0;
-        itv.it_value.tv_usec = 10 * 1000;
-        setitimer(ITIMER_REAL, &itv, NULL);
-        /* we probe the tick duration of the kernel to inform the user if
-           the emulated kernel requested a too high timer frequency */
-        getitimer(ITIMER_REAL, &itv);
+    memset(&tc, 0, sizeof(tc));
+    timeGetDevCaps(&tc, sizeof(tc));
 
-#if defined(__linux__)
-        /* XXX: force /dev/rtc usage because even 2.6 kernels may not
-           have timers with 1 ms resolution. The correct solution will
-           be to use the POSIX real time timers available in recent
-           2.6 kernels */
-        if (itv.it_interval.tv_usec > 1000 || 1) {
-            /* try to use /dev/rtc to have a faster timer */
-            if (start_rtc_timer() < 0)
-                goto use_itimer;
-            /* disable itimer */
-            itv.it_interval.tv_sec = 0;
-            itv.it_interval.tv_usec = 0;
-            itv.it_value.tv_sec = 0;
-            itv.it_value.tv_usec = 0;
-            setitimer(ITIMER_REAL, &itv, NULL);
-
-            /* use the RTC */
-            sigaction(SIGIO, &act, NULL);
-            fcntl(rtc_fd, F_SETFL, O_ASYNC);
-            fcntl(rtc_fd, F_SETOWN, getpid());
-        } else 
-#endif /* defined(__linux__) */
-        {
-        use_itimer:
-            pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * 
-                                   PIT_FREQ) / 1000000;
-        }
+    if (data->period < tc.wPeriodMin)
+        data->period = tc.wPeriodMin;
+
+    timeBeginPeriod(data->period);
+
+    data->timerId = timeSetEvent(1,         // interval (ms)
+                        data->period,       // resolution
+                        host_alarm_handler, // function
+                        (DWORD)t,           // parameter
+                        TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
+
+    if (!data->timerId) {
+        perror("Failed to initialize win32 alarm timer");
+
+        timeEndPeriod(data->period);
+        CloseHandle(data->host_alarm);
+        return -1;
     }
-#endif
+
+    qemu_add_wait_object(data->host_alarm, NULL, NULL);
+
+    return 0;
 }
 
-void quit_timers(void)
+static void win32_stop_timer(struct qemu_alarm_timer *t)
 {
-#ifdef _WIN32
-    timeKillEvent(timerID);
-    timeEndPeriod(period);
-    if (host_alarm) {
-        CloseHandle(host_alarm);
-        host_alarm = NULL;
+    struct qemu_alarm_win32 *data = t->priv;
+
+    timeKillEvent(data->timerId);
+    timeEndPeriod(data->period);
+
+    CloseHandle(data->host_alarm);
+}
+
+#endif /* _WIN32 */
+
+static void init_timer_alarm(void)
+{
+    struct qemu_alarm_timer *t;
+    int i, err = -1;
+
+    for (i = 0; alarm_timers[i].name; i++) {
+        t = &alarm_timers[i];
+
+        printf("trying %s...\n", t->name);
+
+        err = t->start(t);
+        if (!err)
+            break;
     }
-#endif
+
+    if (err) {
+        fprintf(stderr, "Unable to find any suitable alarm timer.\n");
+        fprintf(stderr, "Terminating\n");
+        exit(1);
+    }
+
+    alarm_timer = t;
+}
+
+void quit_timers(void)
+{
+    alarm_timer->stop(alarm_timer);
+    alarm_timer = NULL;
 }
 
 /***********************************************************/
Index: qemu/vl.h
===================================================================
--- qemu.orig/vl.h	2007-08-17 17:03:26.000000000 +0200
+++ qemu/vl.h	2007-08-17 17:03:37.000000000 +0200
@@ -447,7 +447,6 @@
 int qemu_timer_pending(QEMUTimer *ts);
 
 extern int64_t ticks_per_sec;
-extern int pit_min_timer_count;
 
 int64_t cpu_get_ticks(void);
 void cpu_enable_ticks(void);

-- 

  reply	other threads:[~2007-08-17 23:11 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-17 23:11 [PATCH 0/4] Rework alarm timer infrastrucure - take 2 Luca Tettamanti
2007-08-17 23:11 ` [Qemu-devel] " Luca Tettamanti
2007-08-17 23:11 ` Luca Tettamanti [this message]
2007-08-17 23:11   ` [Qemu-devel] [PATCH 1/4] Rework alarm timer infrastrucure Luca Tettamanti
2007-08-17 23:11 ` [PATCH 2/4] Add -clock option Luca Tettamanti
2007-08-17 23:11   ` [Qemu-devel] " Luca Tettamanti
2007-08-17 23:11 ` [PATCH 3/4] Add support for HPET periodic timer Luca Tettamanti
2007-08-17 23:11   ` [Qemu-devel] " Luca Tettamanti
     [not found]   ` <20070817231406.493008599-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-21 19:24     ` Matthew Kent
2007-08-21 19:24       ` Matthew Kent
2007-08-21 19:40       ` Luca
2007-08-21 19:40         ` Luca
     [not found]         ` <68676e00708211240k7237bf21k131257dd28063d26-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-08-21 20:15           ` Matthew Kent
2007-08-21 20:15             ` Matthew Kent
2007-08-22  6:48             ` Dan Kenigsberg
2007-08-22  6:48               ` [kvm-devel] " Dan Kenigsberg
     [not found]               ` <20070822064851.GA16295-RO/WWmT55CHJJbofclyLPCHBx9XpghdU@public.gmane.org>
2007-08-22  7:03                 ` Avi Kivity
2007-08-22  7:03                   ` [kvm-devel] " Avi Kivity
     [not found]                   ` <46CBDFC4.5060207-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-22 12:34                     ` Andi Kleen
2007-08-22 12:34                       ` [kvm-devel] " Andi Kleen
     [not found]                       ` <20070822123424.GK2642-KvMlXPVkKihbpigZmTR7Iw@public.gmane.org>
2007-08-22 21:11                         ` Dan Kenigsberg
2007-08-22 21:11                           ` [kvm-devel] " Dan Kenigsberg
     [not found]                           ` <20070822211150.GA22093-RO/WWmT55CHJJbofclyLPCHBx9XpghdU@public.gmane.org>
2007-08-22 22:09                             ` Andi Kleen
2007-08-22 22:09                               ` [kvm-devel] " Andi Kleen
     [not found]                               ` <20070822220947.GK8058-KvMlXPVkKihbpigZmTR7Iw@public.gmane.org>
2007-08-23  7:02                                 ` Dan Kenigsberg
2007-08-23  7:02                                   ` [kvm-devel] " Dan Kenigsberg
     [not found]                                   ` <20070823070230.GA24942-RO/WWmT55CHJJbofclyLPCHBx9XpghdU@public.gmane.org>
2007-08-24 20:18                                     ` Luca
2007-08-24 20:18                                       ` [kvm-devel] " Luca
2007-08-25  8:24                                       ` Dan Kenigsberg
2007-09-03  8:40         ` GUERRAZ Francois
2007-08-17 23:11 ` [PATCH 4/4] Add support for dynamic ticks Luca Tettamanti
2007-08-17 23:11   ` [Qemu-devel] " Luca Tettamanti
     [not found] ` <20070817231149.544849769-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-17 23:48   ` [Qemu-devel] [PATCH 0/4] Rework alarm timer infrastrucure - take 2 Christian MICHON
2007-08-17 23:48     ` Christian MICHON
     [not found]     ` <46d6db660708171648m3a798685q6514261bc097bc62-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-08-18  0:10       ` Luca
2007-08-18  0:10         ` [kvm-devel] " Luca
2007-08-18 15:17   ` Anthony Liguori
2007-08-18 15:17     ` [Qemu-devel] Re: [kvm-devel] " Anthony Liguori
2007-08-18 16:53     ` [PATCH 0/4] Rework alarm timer infrastrucure - take2 Dor Laor
2007-08-18 16:53     ` [Qemu-devel] RE: [kvm-devel] " Dor Laor
     [not found]       ` <64F9B87B6B770947A9F8391472E032160D4645F0-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org>
2007-08-18 22:02         ` Luca Tettamanti
2007-08-18 22:02           ` [Qemu-devel] Re: [kvm-devel] " Luca Tettamanti
     [not found]           ` <20070818220252.GA19526-sTXFmx6KbOnUXq0IF5SVAZ4oGUkBHcCu@public.gmane.org>
2007-08-18 23:58             ` Anthony Liguori
2007-08-18 23:58               ` [Qemu-devel] Re: [kvm-devel] " Anthony Liguori
2007-08-19  7:36               ` [PATCH 0/4] Rework alarm timer infrastrucure -take2 Dor Laor
2007-08-19  7:36                 ` [Qemu-devel] RE: [kvm-devel] " Dor Laor
2007-08-19  8:24               ` [PATCH 0/4] Rework alarm timer infrastrucure - take2 Avi Kivity
2007-08-19  8:24                 ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
     [not found]                 ` <46C7FE32.4050309-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-19 13:10                   ` [Qemu-devel] " Jamie Lokier
2007-08-19 13:10                     ` [Qemu-devel] Re: [kvm-devel] " Jamie Lokier
     [not found]                     ` <20070819131042.GA22798-tp2ajI7sM85Y6zH9YvfY1x2eb7JE58TQ@public.gmane.org>
2007-08-19 13:48                       ` [Qemu-devel] " Avi Kivity
2007-08-19 13:48                         ` [kvm-devel] " Avi Kivity
     [not found]                         ` <46C84A16.7040305-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-19 13:57                           ` Paul Brook
2007-08-19 13:57                             ` [kvm-devel] " Paul Brook
     [not found]                             ` <200708191457.21237.paul-qD8j1LwMmJjtCj0u4l0SBw@public.gmane.org>
2007-08-19 14:07                               ` Avi Kivity
2007-08-19 14:07                                 ` [kvm-devel] " Avi Kivity
     [not found]                                 ` <46C84E95.7070802-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-19 14:27                                   ` Dor Laor
2007-08-19 14:27                                     ` [kvm-devel] " Dor Laor
2007-08-20  9:25                                   ` Avi Kivity
2007-08-20  9:25                                     ` [kvm-devel] " Avi Kivity
2007-08-19 17:15                               ` Jamie Lokier
2007-08-19 17:15                                 ` [kvm-devel] " Jamie Lokier
     [not found]                                 ` <20070819171545.GB16928-tp2ajI7sM85Y6zH9YvfY1x2eb7JE58TQ@public.gmane.org>
2007-08-19 19:29                                   ` [Qemu-devel] Re: [PATCH 0/4] Rework alarmtimer " Dor Laor
2007-08-19 19:29                                     ` [kvm-devel] " Dor Laor
2007-08-19 19:30                                   ` [Qemu-devel] Re: [PATCH 0/4] Rework alarm timer " Avi Kivity
2007-08-19 19:30                                     ` [kvm-devel] " Avi Kivity
2007-08-19 16:52             ` Luca
2007-08-19 16:52               ` [Qemu-devel] Re: [kvm-devel] " Luca
     [not found]               ` <68676e00708190952g7d4751c2g87a6ff71dd278f71-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-08-19 19:31                 ` Avi Kivity
2007-08-19 19:31                   ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
     [not found]                   ` <46C89A8E.7040609-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-20 21:20                     ` Luca Tettamanti
2007-08-20 21:20                       ` [Qemu-devel] Re: [kvm-devel] " Luca Tettamanti
     [not found]                       ` <20070820212058.GA6713-sTXFmx6KbOnUXq0IF5SVAZ4oGUkBHcCu@public.gmane.org>
2007-08-20 21:55                         ` [Qemu-devel] " malc
2007-08-20 21:55                           ` [Qemu-devel] Re: [kvm-devel] " malc
     [not found]                           ` <Pine.LNX.4.64.0708210140540.16421-KsBd/I2zj1m2ZGm1qqSgDg@public.gmane.org>
2007-08-20 22:49                             ` [Qemu-devel] " Luca
2007-08-20 22:49                               ` [kvm-devel] " Luca
2007-08-21 12:09                         ` Avi Kivity
2007-08-21 12:09                           ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
     [not found]                           ` <46CAD607.2080504-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-21 19:38                             ` Luca Tettamanti
2007-08-21 19:38                               ` [Qemu-devel] Re: [kvm-devel] " Luca Tettamanti
     [not found]                               ` <20070821193834.GB13544-sTXFmx6KbOnUXq0IF5SVAZ4oGUkBHcCu@public.gmane.org>
2007-08-21 19:44                                 ` malc
2007-08-21 19:44                                   ` [Qemu-devel] Re: [kvm-devel] " malc
2007-08-22  5:02                                 ` Avi Kivity
2007-08-22  5:02                                   ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
     [not found]                                   ` <46CBC34F.6060601-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-22 16:12                                     ` Luca Tettamanti
2007-08-22 16:12                                       ` [Qemu-devel] Re: [kvm-devel] " Luca Tettamanti
     [not found]                                       ` <20070822161211.GA30147-sTXFmx6KbOnUXq0IF5SVAZ4oGUkBHcCu@public.gmane.org>
2007-08-22 16:21                                         ` Avi Kivity
2007-08-22 16:21                                           ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
     [not found]                                           ` <46CC6285.3090904-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-22 16:38                                             ` Luca
2007-08-22 16:38                                               ` [Qemu-devel] Re: [kvm-devel] " Luca
     [not found]                                               ` <68676e00708220938y57c07edas705fc8360aefcb78-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-08-22 16:45                                                 ` Avi Kivity
2007-08-22 16:45                                                   ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
     [not found]                                                   ` <46CC680C.1030307-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-22 17:23                                                     ` Luca
2007-08-22 17:23                                                       ` [Qemu-devel] Re: [kvm-devel] " Luca
     [not found]                                                       ` <68676e00708221023m352c2de3y3b19188dbb9ef49e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-08-22 17:39                                                         ` Luca
2007-08-22 17:39                                                           ` [Qemu-devel] Re: [kvm-devel] " Luca
2007-08-22 19:21                                                         ` Luca
2007-08-22 19:21                                                           ` [Qemu-devel] Re: [kvm-devel] " Luca
     [not found]                                                           ` <68676e00708221221n6f8fcd67m9d15f7fea663ec71-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-08-22 21:35                                                             ` Dor Laor
2007-08-22 21:35                                                               ` [Qemu-devel] RE: [kvm-devel] " Dor Laor
     [not found]                                                               ` <64F9B87B6B770947A9F8391472E032160D5042F3-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org>
2007-08-22 22:07                                                                 ` Luca
2007-08-22 22:07                                                                   ` [Qemu-devel] Re: [kvm-devel] " Luca
2007-08-22 20:42                                                 ` Dan Kenigsberg
2007-08-22 20:42                                                   ` [Qemu-devel] Re: [kvm-devel] " Dan Kenigsberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070817231405.883008474@gmail.com \
    --to=kronos.it-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=kvm-devel-TtF/mJH4Jtrk1uMJSBkQmQ@public.gmane.org \
    --cc=qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.