I'm trying to understand QEMU clocks. There are several reference clocks available. The most important are:
QEMU_CLOCK_REALTIME
that is actually a wrapper for a host OS-specific function like QueryPerformanceCounter()
or clock_gettime()
followed by a conversion to ns unitsQEMU_CLOCK_VIRTUAL
runs only during the emulation. In icount mode, virtual clock value is calculated based on number of executed instructions.It looks like QEMU_CLOCK_VIRTUAL
is used by default.
I therefore wonder whether the QEMU_CLOCK_VIRTUAL
is synchronized with the realtime clock? In other words, how virtual nanoseconds obtained from instruction counter are related to real nanoseconds so the user can perceive speed wise the emulated HW as the original one?
Can someone give me a hint? Thank you in advance!
In other words, how virtual nanoseconds obtained from instruction counter are related to real nanoseconds
Virtual time is related to instruction counter only when QEMU runs with -icount
option. In that case it does not match real time and its advancement speed depends on how fast host CPU runs guest instructions.
When -icount
is not specified virtual time ticks synchronously with real time. If you try to measure guest instructions timing from inside the guest the result may be unrealistic.