mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-11 16:00:50 -07:00
qtest: add clock management
This patch combines qtest and -icount together to turn the vm_clock into a source that can be fully managed by the client. To this end new commands clock_step and clock_set are added. Hooking them with libqtest is left as an exercise to the reader. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
2028834574
commit
8156be5610
5 changed files with 69 additions and 1 deletions
20
cpus.c
20
cpus.c
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "qemu-thread.h"
|
||||
#include "cpus.h"
|
||||
#include "qtest.h"
|
||||
#include "main-loop.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
|
|
@ -238,6 +239,20 @@ static void icount_warp_rt(void *opaque)
|
|||
vm_clock_warp_start = -1;
|
||||
}
|
||||
|
||||
void qtest_clock_warp(int64_t dest)
|
||||
{
|
||||
int64_t clock = qemu_get_clock_ns(vm_clock);
|
||||
assert(qtest_enabled());
|
||||
while (clock < dest) {
|
||||
int64_t deadline = qemu_clock_deadline(vm_clock);
|
||||
int64_t warp = MIN(dest - clock, deadline);
|
||||
qemu_icount_bias += warp;
|
||||
qemu_run_timers(vm_clock);
|
||||
clock = qemu_get_clock_ns(vm_clock);
|
||||
}
|
||||
qemu_notify_event();
|
||||
}
|
||||
|
||||
void qemu_clock_warp(QEMUClock *clock)
|
||||
{
|
||||
int64_t deadline;
|
||||
|
|
@ -264,6 +279,11 @@ void qemu_clock_warp(QEMUClock *clock)
|
|||
return;
|
||||
}
|
||||
|
||||
if (qtest_enabled()) {
|
||||
/* When testing, qtest commands advance icount. */
|
||||
return;
|
||||
}
|
||||
|
||||
vm_clock_warp_start = qemu_get_clock_ns(rt_clock);
|
||||
deadline = qemu_clock_deadline(vm_clock);
|
||||
if (deadline > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue