Can I "Speed Up" a VM to emulate the passage of time?

Solution 1:

Apparently it can be done by playing with the jiffies in the kernel, by adding a speedup ratio. There is a document with a presentation about a quick 10 year test. It boils down to this:

Add a parameter to Kconfig (SPEEDUP_RATIO, ~1-1000), modify do_timer():

 void do_timer(...) {
        jiffies_64 = jiffies_64 + speedup_ratio;
    }

Finally, control ratio via procfs (echo 100 > /proc/accel). Then he had lots of timeouts on boot and had to adjust all the timeouts in the kernel (timeout * speedup_ratio). He says most of these values can be found with grep jiffies, but the "most" means it may involve some trial and error.

Also, according to man 7 time: "The size of a jiffy is determined by the value of the kernel constant HZ". It is configurable, but only takes the values 100, 250, 300 and 1000.

EDIT: If time leaps are acceptable, libfaketime may be a much simpler alternative. But I don't know how logging software will deal with that.