Unverified Commit 67b53796 authored by Adam C. Stephens's avatar Adam C. Stephens Committed by GitHub
Browse files

Merge pull request #304919 from adamcstephens/lxd/cpu-hotplug

nixos/lxd-virtual-machine: enable CPU hotplug for x86_64
parents bc279bba 76c69af6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@ in {

    boot.kernelParams = ["console=tty1" "console=${serialDevice}"];

    services.udev.extraRules = ''
      SUBSYSTEM=="cpu", CONST{arch}=="x86-64", TEST=="online", ATTR{online}=="0", ATTR{online}="1"
    '';

    virtualisation.lxd.agent.enable = lib.mkDefault true;
  };
}
+9 −0
Original line number Diff line number Diff line
@@ -57,5 +57,14 @@ in

    with subtest("lxd-agent has a valid path"):
        machine.succeed("incus exec ${instance-name} -- bash -c 'true'")

    with subtest("guest supports cpu hotplug"):
        machine.succeed("incus config set ${instance-name} limits.cpu=1")
        count = int(machine.succeed("incus exec ${instance-name} -- nproc").strip())
        assert count == 1, f"Wrong number of CPUs reported, want: 1, got: {count}"

        machine.succeed("incus config set ${instance-name} limits.cpu=2")
        count = int(machine.succeed("incus exec ${instance-name} -- nproc").strip())
        assert count == 2, f"Wrong number of CPUs reported, want: 2, got: {count}"
  '';
})