nixosTests.virtualbox: add happy path KVM test

The KVM support is still new and experimental. There is no point in
doing extensive testing. Just check whether it works in general.
This commit is contained in:
Julian Stecklina 2024-02-14 18:40:46 +01:00
parent 77c7ac6c35
commit 3661b3ee53

View File

@ -3,6 +3,7 @@
pkgs ? import ../.. { inherit system config; },
debug ? false,
enableUnfree ? false,
enableKvm ? false,
use64bitGuest ? true
}:
@ -349,7 +350,13 @@ let
vmConfigs = mapAttrsToList mkVMConf vms;
in [ ./common/user-account.nix ./common/x11.nix ] ++ vmConfigs;
virtualisation.memorySize = 2048;
virtualisation.qemu.options = ["-cpu" "kvm64,svm=on,vmx=on"];
virtualisation.qemu.options = let
# IvyBridge is reasonably ancient to be compatible with recent
# Intel/AMD hosts and sufficient for the KVM flavor.
guestCpu = if config.virtualisation.virtualbox.host.enableKvm then "IvyBridge" else "kvm64";
in ["-cpu" "${guestCpu},svm=on,vmx=on"];
test-support.displayManager.auto.user = "alice";
users.users.alice.extraGroups = let
inherit (config.virtualisation.virtualbox.host) enableHardening;
@ -412,6 +419,23 @@ let
'';
};
kvmTests = mapAttrs (mkVBoxTest {
enableKvm = true;
# Once the KVM version supports these, we can enable them.
addNetworkInterface = false;
enableHardening = false;
} vboxVMs) {
kvm-headless = ''
create_vm_headless()
machine.succeed(ru("VBoxHeadless --startvm headless >&2 & disown %1"))
wait_for_startup_headless()
wait_for_vm_boot_headless()
shutdown_vm_headless()
destroy_vm_headless()
'';
};
in mapAttrs (mkVBoxTest {} vboxVMs) {
simple-gui = ''
# Home to select Tools, down to move to the VM, enter to start it.
@ -522,4 +546,6 @@ in mapAttrs (mkVBoxTest {} vboxVMs) {
destroy_vm_test1()
destroy_vm_test2()
'';
} // (optionalAttrs enableUnfree unfreeTests)
}
// (optionalAttrs enableKvm kvmTests)
// (optionalAttrs enableUnfree unfreeTests)