4

I'm trying to increase the speed at which qemu runs, so for example one tick of the real CPU will correspond to two ticks of the virtual time of qemu. Is this possible and if so does anyone have any pointers on how to go about doing this?

mwray
  • 41
  • 1
  • 3

3 Answers3

5

You can't do this. QEMU is not made for such thing.

QEMU does not simulate timing of execution. It doesn't know anything about CPU caches etc., so it can't be accurate even if it is desirable. It simply executes guest code, as fast as it can. No acceleration or deceleration.

At least do not seek solution this way.

halfer
  • 18,701
  • 13
  • 79
  • 158
VividD
  • 10,040
  • 6
  • 59
  • 107
  • It's possible to increase QEMU clock at least in full system emulation mode (using CPU emulation). See "-icount" option. I'm looking for the same thing as OP, but for KVM-enabled emulation, and still no success. – Artem Pisarenko May 07 '18 at 04:48
2

Maybe you should give a look at tickpolicy options from libvirt https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/Virtualization_Deployment_and_Administration_Guide/sect-Virtualization-Tips_and_tricks-Libvirt_Managed_Timers.html.

It's able to 'catchup' host time. The effect is that the guest seems accelerated.

The option is translated from libvirt to qemu as -rtc ,driftfix=slew

Note that it won't change how fast code will be executed.

needle
  • 145
  • 5
2

There are qemu options which can alter the advance of time as seen by the guest.

The args I used (with qemu v4.2.0) are:

qemu-system-x86_64 -rtc base=localtime,clock=vm -icount shift=7,align=off,sleep=off ...

Note that icount is not compatible with hardware acceleration. Also note that a shift value too high may cause the guest OS to misbehave. For example, when I tried a value of 10, the linux kernel kept complaining of tasks stalled >120s.

Of possible interest: comments on https://github.com/zephyrproject-rtos/zephyr/issues/14173 and the linked issues/PRs.

Mark
  • 965
  • 1
  • 9
  • 24