From mboxrd@z Thu Jan 1 00:00:00 1970 From: Luca Tettamanti Subject: [PATCH 2/4] Add -clock option. Date: Sat, 18 Aug 2007 01:11:51 +0200 Message-ID: <20070817231406.125747382@gmail.com> References: <20070817231149.544849769@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-TtF/mJH4Jtrk1uMJSBkQmQ@public.gmane.org, Luca Tettamanti To: qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org Return-path: Content-Disposition: inline; filename=clock-select List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.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 --- vl.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) Index: qemu/vl.c =================================================================== --- qemu.orig/vl.c 2007-08-17 17:31:09.000000000 +0200 +++ qemu/vl.c 2007-08-18 00:40:22.000000000 +0200 @@ -829,6 +829,71 @@ {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; @@ -6791,6 +6856,8 @@ #ifdef TARGET_SPARC "-prom-env variable=value set OpenBIOS nvram variables\n" #endif + "-clock force the use of the given methods for timer alarm.\n" + " To see what timers are available use -clock help\n" "\n" "During emulation, the following keys are useful:\n" "ctrl-alt-f toggle full screen\n" @@ -6888,6 +6955,7 @@ QEMU_OPTION_name, QEMU_OPTION_prom_env, QEMU_OPTION_old_param, + QEMU_OPTION_clock, }; typedef struct QEMUOption { @@ -6992,6 +7060,7 @@ #if defined(TARGET_ARM) { "old-param", 0, QEMU_OPTION_old_param }, #endif + { "clock", HAS_ARG, QEMU_OPTION_clock }, { NULL }, }; @@ -7771,6 +7840,9 @@ case QEMU_OPTION_old_param: old_param = 1; #endif + case QEMU_OPTION_clock: + configure_alarms(optarg); + break; } } } -- ------------------------------------------------------------------------- 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/