[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH/RFC 2/4] Add -clock option.
From: |
Luca Tettamanti |
Subject: |
[Qemu-devel] [PATCH/RFC 2/4] Add -clock option. |
Date: |
Thu, 16 Aug 2007 22:41:15 +0200 |
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 <address@hidden>
---
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
[Qemu-devel] Re: [kvm-devel] [PATCH/RFC 0/4] Rework alarm timer infrastrucure., Avi Kivity, 2007/08/17