Commit 3661b3ee authored by Julian Stecklina's avatar Julian Stecklina
Browse files

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.
parent 77c7ac6c
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -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)