From: Luca Tettamanti <kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: Dan Kenigsberg <dank-atKUWr5tajBWk0Htik3J/w@public.gmane.org>,
Luca Tettamanti
<kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
Subject: [PATCH/RFC 2/4] Add -clock option.
Date: Thu, 16 Aug 2007 22:41:15 +0200 [thread overview]
Message-ID: <11872968773155-git-send-email-kronos.it@gmail.com> (raw)
In-Reply-To: <11872968771257-git-send-email-kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Allow user to override the list of available alarm timers and their
priority. The format of the options is -clock clk1,clk2,...
Signed-off-by: Luca Tettamanti <kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
qemu/vl.c | 90 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 72 insertions(+), 18 deletions(-)
diff --git a/qemu/vl.c b/qemu/vl.c
index 33443ca..f0b4896 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -793,6 +793,71 @@ static struct qemu_alarm_timer alarm_timers[] = {
{NULL, }
};
+static void show_available_alarms()
+{
+ int i;
+
+ printf("Available alarm timers, in order of precedence:\n");
+ for (i = 0; alarm_timers[i].name; i++)
+ printf("%s\n", alarm_timers[i].name);
+}
+
+static void configure_alarms(char const *opt)
+{
+ int i;
+ int cur = 0;
+ int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;
+ char *arg;
+ char *name;
+
+ if (!strcmp(opt, "help")) {
+ show_available_alarms();
+ exit(0);
+ }
+
+ arg = strdup(opt);
+
+ /* Reorder the array */
+ name = strtok(arg, ",");
+ while (name) {
+ struct qemu_alarm_timer tmp;
+
+ for (i = 0; i < count; i++) {
+ if (!strcmp(alarm_timers[i].name, name))
+ break;
+ }
+
+ if (i == count) {
+ fprintf(stderr, "Unknown clock %s\n", name);
+ goto next;
+ }
+
+ if (i < cur)
+ /* Ignore */
+ goto next;
+
+ /* Swap */
+ tmp = alarm_timers[i];
+ alarm_timers[i] = alarm_timers[cur];
+ alarm_timers[cur] = tmp;
+
+ cur++;
+next:
+ name = strtok(NULL, ",");
+ }
+
+ free(arg);
+
+ if (cur) {
+ /* Disable remaining timers */
+ for (i = cur; i < count; i++)
+ alarm_timers[i].name = NULL;
+ }
+
+ /* debug */
+ show_available_alarms();
+}
+
QEMUClock *rt_clock;
QEMUClock *vm_clock;
@@ -1035,8 +1100,6 @@ static void host_alarm_handler(int host_signum)
#define RTC_FREQ 1024
-static int use_rtc = 1;
-
static void enable_sigio_timer(int fd)
{
struct sigaction act;
@@ -1058,9 +1121,6 @@ static int rtc_start_timer(struct qemu_alarm_timer *t)
{
int rtc_fd;
- if (!use_rtc)
- return -1;
-
rtc_fd = open("/dev/rtc", O_RDONLY);
if (rtc_fd < 0)
return -1;
@@ -6566,9 +6626,8 @@ void help(void)
"-daemonize daemonize QEMU after initializing\n"
#endif
"-tdf inject timer interrupts that got lost\n"
-#if defined(__linux__)
- "-no-rtc don't use /dev/rtc for timer alarm (do use gettimeofday)\n"
-#endif
+ "-clock force the use of the given methods for timer alarm.\n"
+ " To see what timers are available use -clock help\n"
"-option-rom rom load a file, rom, into the option ROM space\n"
"\n"
"During emulation, the following keys are useful:\n"
@@ -6658,9 +6717,7 @@ enum {
QEMU_OPTION_semihosting,
QEMU_OPTION_incoming,
QEMU_OPTION_tdf,
-#if defined(__linux__)
- QEMU_OPTION_no_rtc,
-#endif
+ QEMU_OPTION_clock,
QEMU_OPTION_cpu_vendor,
};
@@ -6755,9 +6812,7 @@ const QEMUOption qemu_options[] = {
{ "semihosting", 0, QEMU_OPTION_semihosting },
#endif
{ "tdf", 0, QEMU_OPTION_tdf }, /* enable time drift fix */
-#if defined(__linux__)
- { "no-rtc", 0, QEMU_OPTION_no_rtc },
-#endif
+ { "clock", HAS_ARG, QEMU_OPTION_clock },
{ "cpu-vendor", HAS_ARG, QEMU_OPTION_cpu_vendor },
{ NULL },
};
@@ -7477,11 +7532,10 @@ int main(int argc, char **argv)
break;
case QEMU_OPTION_tdf:
time_drift_fix = 1;
-#if defined(__linux__)
- case QEMU_OPTION_no_rtc:
- use_rtc = 0;
break;
-#endif
+ case QEMU_OPTION_clock:
+ configure_alarms(optarg);
+ break;
case QEMU_OPTION_cpu_vendor:
cpu_vendor_string = optarg;
break;
--
1.5.2.4
-------------------------------------------------------------------------
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: kvm-devel@lists.sourceforge.net
Cc: Dan Kenigsberg <dank@qumranet.com>,
Luca Tettamanti <kronos.it@gmail.com>,
qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH/RFC 2/4] Add -clock option.
Date: Thu, 16 Aug 2007 22:41:15 +0200 [thread overview]
Message-ID: <11872968773155-git-send-email-kronos.it@gmail.com> (raw)
In-Reply-To: <11872968771257-git-send-email-kronos.it@gmail.com>
Allow user to override the list of available alarm timers and their
priority. The format of the options is -clock clk1,clk2,...
Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
---
qemu/vl.c | 90 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 72 insertions(+), 18 deletions(-)
diff --git a/qemu/vl.c b/qemu/vl.c
index 33443ca..f0b4896 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -793,6 +793,71 @@ static struct qemu_alarm_timer alarm_timers[] = {
{NULL, }
};
+static void show_available_alarms()
+{
+ int i;
+
+ printf("Available alarm timers, in order of precedence:\n");
+ for (i = 0; alarm_timers[i].name; i++)
+ printf("%s\n", alarm_timers[i].name);
+}
+
+static void configure_alarms(char const *opt)
+{
+ int i;
+ int cur = 0;
+ int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;
+ char *arg;
+ char *name;
+
+ if (!strcmp(opt, "help")) {
+ show_available_alarms();
+ exit(0);
+ }
+
+ arg = strdup(opt);
+
+ /* Reorder the array */
+ name = strtok(arg, ",");
+ while (name) {
+ struct qemu_alarm_timer tmp;
+
+ for (i = 0; i < count; i++) {
+ if (!strcmp(alarm_timers[i].name, name))
+ break;
+ }
+
+ if (i == count) {
+ fprintf(stderr, "Unknown clock %s\n", name);
+ goto next;
+ }
+
+ if (i < cur)
+ /* Ignore */
+ goto next;
+
+ /* Swap */
+ tmp = alarm_timers[i];
+ alarm_timers[i] = alarm_timers[cur];
+ alarm_timers[cur] = tmp;
+
+ cur++;
+next:
+ name = strtok(NULL, ",");
+ }
+
+ free(arg);
+
+ if (cur) {
+ /* Disable remaining timers */
+ for (i = cur; i < count; i++)
+ alarm_timers[i].name = NULL;
+ }
+
+ /* debug */
+ show_available_alarms();
+}
+
QEMUClock *rt_clock;
QEMUClock *vm_clock;
@@ -1035,8 +1100,6 @@ static void host_alarm_handler(int host_signum)
#define RTC_FREQ 1024
-static int use_rtc = 1;
-
static void enable_sigio_timer(int fd)
{
struct sigaction act;
@@ -1058,9 +1121,6 @@ static int rtc_start_timer(struct qemu_alarm_timer *t)
{
int rtc_fd;
- if (!use_rtc)
- return -1;
-
rtc_fd = open("/dev/rtc", O_RDONLY);
if (rtc_fd < 0)
return -1;
@@ -6566,9 +6626,8 @@ void help(void)
"-daemonize daemonize QEMU after initializing\n"
#endif
"-tdf inject timer interrupts that got lost\n"
-#if defined(__linux__)
- "-no-rtc don't use /dev/rtc for timer alarm (do use gettimeofday)\n"
-#endif
+ "-clock force the use of the given methods for timer alarm.\n"
+ " To see what timers are available use -clock help\n"
"-option-rom rom load a file, rom, into the option ROM space\n"
"\n"
"During emulation, the following keys are useful:\n"
@@ -6658,9 +6717,7 @@ enum {
QEMU_OPTION_semihosting,
QEMU_OPTION_incoming,
QEMU_OPTION_tdf,
-#if defined(__linux__)
- QEMU_OPTION_no_rtc,
-#endif
+ QEMU_OPTION_clock,
QEMU_OPTION_cpu_vendor,
};
@@ -6755,9 +6812,7 @@ const QEMUOption qemu_options[] = {
{ "semihosting", 0, QEMU_OPTION_semihosting },
#endif
{ "tdf", 0, QEMU_OPTION_tdf }, /* enable time drift fix */
-#if defined(__linux__)
- { "no-rtc", 0, QEMU_OPTION_no_rtc },
-#endif
+ { "clock", HAS_ARG, QEMU_OPTION_clock },
{ "cpu-vendor", HAS_ARG, QEMU_OPTION_cpu_vendor },
{ NULL },
};
@@ -7477,11 +7532,10 @@ int main(int argc, char **argv)
break;
case QEMU_OPTION_tdf:
time_drift_fix = 1;
-#if defined(__linux__)
- case QEMU_OPTION_no_rtc:
- use_rtc = 0;
break;
-#endif
+ case QEMU_OPTION_clock:
+ configure_alarms(optarg);
+ break;
case QEMU_OPTION_cpu_vendor:
cpu_vendor_string = optarg;
break;
--
1.5.2.4
next prev parent reply other threads:[~2007-08-16 20:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-16 20:41 [PATCH/RFC 0/4] Rework alarm timer infrastrucure Luca Tettamanti
2007-08-16 20:41 ` [Qemu-devel] " Luca Tettamanti
[not found] ` <11872968773449-git-send-email-kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-16 20:41 ` [PATCH/RFC 1/4] " Luca Tettamanti
2007-08-16 20:41 ` [Qemu-devel] " Luca Tettamanti
[not found] ` <11872968771257-git-send-email-kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-16 20:41 ` Luca Tettamanti [this message]
2007-08-16 20:41 ` [Qemu-devel] [PATCH/RFC 2/4] Add -clock option Luca Tettamanti
[not found] ` <11872968773155-git-send-email-kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-16 20:41 ` [PATCH/RFC 3/4] Add support for HPET periodic timer Luca Tettamanti
2007-08-16 20:41 ` [Qemu-devel] " Luca Tettamanti
[not found] ` <11872968773524-git-send-email-kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-16 20:41 ` [PATCH/RFC 4/4] Add support for dynamic ticks Luca Tettamanti
2007-08-16 20:41 ` [Qemu-devel] " Luca Tettamanti
[not found] ` <1187296877557-git-send-email-kronos.it-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-17 7:16 ` Matthew Kent
2007-08-17 7:16 ` [Qemu-devel] Re: [kvm-devel] " Matthew Kent
[not found] ` <42755.207.81.93.54.1187334969.squirrel-N19E6/cp6YFSV923RJcDwA@public.gmane.org>
2007-08-19 8:08 ` Avi Kivity
2007-08-19 8:08 ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
2007-08-17 12:44 ` [PATCH/RFC 0/4] Rework alarm timer infrastrucure Avi Kivity
2007-08-17 12:44 ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
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=11872968773155-git-send-email-kronos.it@gmail.com \
--to=kronos.it-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=dank-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@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.