KVM Rapid Iteration
Rebuilding a the full linux kernel when modifying KVM for the purposes of patching VM exit RDTSC timings is a tedious process. Thankfully, the linux kernel is modular and can be built in pieces and incrementally upgraded.
This can be accomplished relatively safely by following the rough steps outlined below:
Fully build the kernel once, and loading this built kernel.
Compile only KVM as a module.
Kill all running VMs.
Remove existing KVM modules.
Load freshly built KVM modules.
Restart killed VMs.
On first use, the script may perform a full kernel build if it cannot find vmlinux in the source folder. Subsequent iterations skip the full build, reducing iteration time from ~10 minutes to approximately 5 seconds, plus the time it takes to reboot your virtual machines.
To use the script:
Clone a copy of AutoVirt. (commit
c69721fwas tested.)Drop the script in the
modulesfolder.Build the kernel by executing the kernel script in
modulesfolder.Make your changes to the linux kernel KVM source code on disk.
Run the iteration script after killing all VMs.
Restart your VMs.
Note that a full build will revert to the tag specified. For iterative builds, the script uses the current source files on disk directly, no Git operations are performed.
Source:⌗
Available at: https://gist.github.com/virtfunc/2278f2f6f1d486521cb635813ff8dde7
Caveats and assumptions:
Hardcoded to use
kvm_amd, but should work on Intel processors with simple modifications.Expects to be present in the
modulesfolder of an AutoVirt git project. (Tested against commitc69721f.)Assumes Arch Linux, other distros untested.