mirror of https://github.com/xqemu/xqemu.git
introduce and use qemu_clock_enable
By adding the possibility to turn on/off a clock, yet another incestuous relationship between timers and CPUs can be disentangled. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
8c04ba55f9
commit
972abbe03b
14
vl.c
14
vl.c
|
@ -578,6 +578,7 @@ void cpu_disable_ticks(void)
|
||||||
|
|
||||||
struct QEMUClock {
|
struct QEMUClock {
|
||||||
int type;
|
int type;
|
||||||
|
int enabled;
|
||||||
/* XXX: add frequency */
|
/* XXX: add frequency */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -812,9 +813,15 @@ static QEMUClock *qemu_new_clock(int type)
|
||||||
QEMUClock *clock;
|
QEMUClock *clock;
|
||||||
clock = qemu_mallocz(sizeof(QEMUClock));
|
clock = qemu_mallocz(sizeof(QEMUClock));
|
||||||
clock->type = type;
|
clock->type = type;
|
||||||
|
clock->enabled = 1;
|
||||||
return clock;
|
return clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void qemu_clock_enable(QEMUClock *clock, int enabled)
|
||||||
|
{
|
||||||
|
clock->enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque)
|
QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque)
|
||||||
{
|
{
|
||||||
QEMUTimer *ts;
|
QEMUTimer *ts;
|
||||||
|
@ -908,6 +915,9 @@ static void qemu_run_timers(QEMUClock *clock)
|
||||||
QEMUTimer **ptimer_head, *ts;
|
QEMUTimer **ptimer_head, *ts;
|
||||||
int64_t current_time;
|
int64_t current_time;
|
||||||
|
|
||||||
|
if (!clock->enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
current_time = qemu_get_clock (clock);
|
current_time = qemu_get_clock (clock);
|
||||||
ptimer_head = &active_timers[clock->type];
|
ptimer_head = &active_timers[clock->type];
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
@ -1017,7 +1027,6 @@ static void qemu_run_all_timers(void)
|
||||||
|
|
||||||
/* vm time timers */
|
/* vm time timers */
|
||||||
if (vm_running) {
|
if (vm_running) {
|
||||||
if (!cur_cpu || likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER)))
|
|
||||||
qemu_run_timers(vm_clock);
|
qemu_run_timers(vm_clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3969,6 +3978,9 @@ static void tcg_cpu_exec(void)
|
||||||
for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
|
for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
|
||||||
CPUState *env = cur_cpu = next_cpu;
|
CPUState *env = cur_cpu = next_cpu;
|
||||||
|
|
||||||
|
qemu_clock_enable(vm_clock,
|
||||||
|
(cur_cpu->singlestep_enabled & SSTEP_NOTIMER) == 0);
|
||||||
|
|
||||||
if (alarm_timer->pending)
|
if (alarm_timer->pending)
|
||||||
break;
|
break;
|
||||||
if (cpu_can_run(env))
|
if (cpu_can_run(env))
|
||||||
|
|
Loading…
Reference in New Issue