From 943fd5ea4b17b9d7d2be3b2ff9316858fde61270 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 26 Jun 2022 11:38:05 +0000 Subject: [PATCH 1/9] pkgsi686Linux.linuxPackages.virtualboxGuestAdditions: mark broken Hasn't built since the upgrade to Linux 5.10. https://forums.virtualbox.org/viewtopic.php?t=104819 --- .../virtualization/virtualbox/guest-additions/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix index da9f32b9c685..0168b46f47e5 100644 --- a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix +++ b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix @@ -159,6 +159,6 @@ in stdenv.mkDerivation rec { license = "GPL"; maintainers = [ lib.maintainers.sander ]; platforms = lib.platforms.linux; - broken = kernel.kernelAtLeast "5.17"; + broken = kernel.kernelAtLeast (if stdenv.hostPlatform.is32bit then "5.10" else "5.17"); }; } From 97a16f52d718073531ddc3bb3aa038110793ae06 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 26 Jun 2022 11:45:42 +0000 Subject: [PATCH 2/9] linuxPackages.virtualboxGuestAdditions: properly mark platforms This saves a lot of defensive checking inside the expression. --- .../virtualbox/guest-additions/default.nix | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix index 0168b46f47e5..538ebfa78cf8 100644 --- a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix +++ b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix @@ -45,26 +45,15 @@ in stdenv.mkDerivation rec { patchFlags = [ "-p1" "-d" "src/vboxguest-${version}" ]; unpackPhase = '' - ${if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then '' - isoinfo -J -i $src -x /VBoxLinuxAdditions.run > ./VBoxLinuxAdditions.run - chmod 755 ./VBoxLinuxAdditions.run - # An overflow leads the is-there-enough-space check to fail when there's too much space available, so fake how much space there is - sed -i 's/\$leftspace/16383/' VBoxLinuxAdditions.run - ./VBoxLinuxAdditions.run --noexec --keep - '' - else throw ("Architecture: "+stdenv.hostPlatform.system+" not supported for VirtualBox guest additions") - } + isoinfo -J -i $src -x /VBoxLinuxAdditions.run > ./VBoxLinuxAdditions.run + chmod 755 ./VBoxLinuxAdditions.run + # An overflow leads the is-there-enough-space check to fail when there's too much space available, so fake how much space there is + sed -i 's/\$leftspace/16383/' VBoxLinuxAdditions.run + ./VBoxLinuxAdditions.run --noexec --keep # Unpack files cd install - ${if stdenv.hostPlatform.system == "i686-linux" then '' - tar xfvj VBoxGuestAdditions-x86.tar.bz2 - '' - else if stdenv.hostPlatform.system == "x86_64-linux" then '' - tar xfvj VBoxGuestAdditions-amd64.tar.bz2 - '' - else throw ("Architecture: "+stdenv.hostPlatform.system+" not supported for VirtualBox guest additions") - } + tar xfvj VBoxGuestAdditions-${if stdenv.hostPlatform.is32bit then "x86" else "amd64"}.tar.bz2 ''; buildPhase = '' @@ -158,7 +147,7 @@ in stdenv.mkDerivation rec { sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; license = "GPL"; maintainers = [ lib.maintainers.sander ]; - platforms = lib.platforms.linux; + platforms = [ "i686-linux" "x86_64-linux" ]; broken = kernel.kernelAtLeast (if stdenv.hostPlatform.is32bit then "5.10" else "5.17"); }; } From 6ce4afce638fd7d2033518fa6550a0aba731edf7 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 26 Jun 2022 11:41:05 +0000 Subject: [PATCH 3/9] nixosTests.virtualbox: always use nested KVM Nested KVM has been enabled by default on Linux on Intel for a long time now, and since Virtualbox 6.1.0, the test won't run without it because Virtualbox now only supports running hardware-accelerated VMs. Additionally, this means we can 64-bit guests by default. The 32-bit guest additions don't currently build, so this is important to have the tests work with the default options. --- nixos/tests/virtualbox.nix | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/nixos/tests/virtualbox.nix b/nixos/tests/virtualbox.nix index 4eb402a7d36e..569f7589bc41 100644 --- a/nixos/tests/virtualbox.nix +++ b/nixos/tests/virtualbox.nix @@ -3,18 +3,9 @@ pkgs ? import ../.. { inherit system config; }, debug ? false, enableUnfree ? false, - # Nested KVM virtualization (https://www.linux-kvm.org/page/Nested_Guests) - # requires a modprobe flag on the build machine: (kvm-amd for AMD CPUs) - # boot.extraModprobeConfig = "options kvm-intel nested=Y"; - # Without this VirtualBox will use SW virtualization and will only be able - # to run 32-bit guests. - useKvmNestedVirt ? false, - # Whether to run 64-bit guests instead of 32-bit. Requires nested KVM. - use64bitGuest ? false + use64bitGuest ? true }: -assert use64bitGuest -> useKvmNestedVirt; - with import ../lib/testing-python.nix { inherit system pkgs; }; with pkgs.lib; @@ -359,8 +350,7 @@ let vmConfigs = mapAttrsToList mkVMConf vms; in [ ./common/user-account.nix ./common/x11.nix ] ++ vmConfigs; virtualisation.memorySize = 2048; - virtualisation.qemu.options = - if useKvmNestedVirt then ["-cpu" "kvm64,vmx=on"] else []; + virtualisation.qemu.options = ["-cpu" "kvm64,vmx=on"]; virtualisation.virtualbox.host.enable = true; test-support.displayManager.auto.user = "alice"; users.users.alice.extraGroups = let From ecaa6f5c60db3db0e0080df81663a8f2b1731a2a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 25 Jun 2022 17:35:51 +0000 Subject: [PATCH 4/9] nixosTests.virtualbox.host-usb-permissions: import sys Otherwise, sys.stderr is not defined. Fixes: db614e11d67 ("nixos/tests/test-driver: better control test env symbols") --- nixos/tests/virtualbox.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nixos/tests/virtualbox.nix b/nixos/tests/virtualbox.nix index 569f7589bc41..e9b228f07277 100644 --- a/nixos/tests/virtualbox.nix +++ b/nixos/tests/virtualbox.nix @@ -466,6 +466,8 @@ in mapAttrs (mkVBoxTest false vboxVMs) { ''; host-usb-permissions = '' + import sys + user_usb = remove_uuids(vbm("list usbhost")) print(user_usb, file=sys.stderr) root_usb = remove_uuids(machine.succeed("VBoxManage list usbhost")) From 17b00794360dc3161f5e5a24d7d8f635fea774eb Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 23 Jun 2022 20:02:10 +0000 Subject: [PATCH 5/9] nixosTests.virtualbox: create shared dir before VM Otherwise, since the update to Virtualbox 6.1.22, the test would fail due to the shared directory not existing. Fixes: ba0da8a076e ("virtualbox: 6.1.18 -> 6.1.22") --- nixos/tests/virtualbox.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/tests/virtualbox.nix b/nixos/tests/virtualbox.nix index e9b228f07277..95eff74d1e5b 100644 --- a/nixos/tests/virtualbox.nix +++ b/nixos/tests/virtualbox.nix @@ -217,6 +217,7 @@ let def create_vm_${name}(): + cleanup_${name}() vbm("createvm --name ${name} ${createFlags}") vbm("modifyvm ${name} ${vmFlags}") vbm("setextradata ${name} VBoxInternal/PDM/HaltOnReset 1") @@ -224,7 +225,6 @@ let vbm("storageattach ${name} ${diskFlags}") vbm("sharedfolder add ${name} ${sharedFlags}") vbm("sharedfolder add ${name} ${nixstoreFlags}") - cleanup_${name}() ${mkLog "$HOME/VirtualBox VMs/${name}/Logs/VBox.log" "HOST-${name}"} From e2617706ed138e27f912871cf4a3dd30cf6aa079 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 21 Jun 2022 21:35:51 +0000 Subject: [PATCH 6/9] nixosTests.virtualbox: fix logging service This used to be StandardOutput=syslog, which was removed because syslog is deprecated, but that caused the test to fail. So bring it back, but set it to the non-deprecated "journal" value instead (which is what systemd interprets "syslog" as now anyway). Fixes: 962e15aebcc ("nixos: remove StandardOutput=syslog, StandardError=syslog lines") --- nixos/tests/virtualbox.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/tests/virtualbox.nix b/nixos/tests/virtualbox.nix index 95eff74d1e5b..ad8819562a2f 100644 --- a/nixos/tests/virtualbox.nix +++ b/nixos/tests/virtualbox.nix @@ -191,6 +191,7 @@ let systemd.services."vboxtestlog-${name}@" = { description = "VirtualBox Test Machine Log For ${name}"; serviceConfig.StandardInput = "socket"; + serviceConfig.StandardOutput = "journal"; serviceConfig.SyslogIdentifier = "GUEST-${name}"; serviceConfig.ExecStart = "${pkgs.coreutils}/bin/cat"; }; From 34ec11729e4a5a415c10785b79ed1a651a710857 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 24 Jun 2022 10:22:35 +0000 Subject: [PATCH 7/9] nixosTests.virtualbox: fix for blocking stdout Fixes: 1640359f333 ("nixos/test-runner: Fix execute() flakiness") --- nixos/tests/virtualbox.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/tests/virtualbox.nix b/nixos/tests/virtualbox.nix index ad8819562a2f..1fd2f23b3691 100644 --- a/nixos/tests/virtualbox.nix +++ b/nixos/tests/virtualbox.nix @@ -459,7 +459,7 @@ in mapAttrs (mkVBoxTest false vboxVMs) { headless = '' create_vm_headless() - machine.succeed(ru("VBoxHeadless --startvm headless & disown %1")) + machine.succeed(ru("VBoxHeadless --startvm headless >&2 & disown %1")) wait_for_startup_headless() wait_for_vm_boot_headless() shutdown_vm_headless() From 253fa03ea93550f2c8659cdfcd436e089d8fd78b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 25 Jun 2022 17:11:34 +0000 Subject: [PATCH 8/9] nixosTests.virtualbox.net-hostonlyif: use dhcpcd dhclient is no longer built by default in the dhcp package, so this test has been broken since that change was made. To fix, switch to dhcpcd. dhcpcd insists on writing into /var/run, so we need to ensure that exists. Fixes: a2c379d4b6d ("dhcp: make client and relay component optional") --- nixos/tests/virtualbox.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nixos/tests/virtualbox.nix b/nixos/tests/virtualbox.nix index 1fd2f23b3691..08a26a2f0d3d 100644 --- a/nixos/tests/virtualbox.nix +++ b/nixos/tests/virtualbox.nix @@ -17,7 +17,8 @@ let #!${pkgs.runtimeShell} -xe export PATH="${lib.makeBinPath [ pkgs.coreutils pkgs.util-linux ]}" - mkdir -p /run/dbus + mkdir -p /run/dbus /var + ln -s /run /var cat > /etc/passwd < Date: Mon, 27 Jun 2022 07:49:25 +0000 Subject: [PATCH 9/9] nixosTests.virtualbox: fix on AMD --- nixos/tests/virtualbox.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/tests/virtualbox.nix b/nixos/tests/virtualbox.nix index 08a26a2f0d3d..1c1b0dac7f37 100644 --- a/nixos/tests/virtualbox.nix +++ b/nixos/tests/virtualbox.nix @@ -349,7 +349,7 @@ let vmConfigs = mapAttrsToList mkVMConf vms; in [ ./common/user-account.nix ./common/x11.nix ] ++ vmConfigs; virtualisation.memorySize = 2048; - virtualisation.qemu.options = ["-cpu" "kvm64,vmx=on"]; + virtualisation.qemu.options = ["-cpu" "kvm64,svm=on,vmx=on"]; virtualisation.virtualbox.host.enable = true; test-support.displayManager.auto.user = "alice"; users.users.alice.extraGroups = let