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

nixos/lxd-virtual-machine: enable CPU hotplug for x86_64
This commit is contained in:
Adam C. Stephens 2024-04-18 11:55:34 -04:00 committed by GitHub
commit 67b5379607
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -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;
};
}

View File

@ -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}"
'';
})