Skip to content

Commit

Permalink
Configure memory ballooning at 50% for the VM
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed May 5, 2024
1 parent 368ac82 commit 97195a9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion user-machines/vm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ in
base = virtlib.domain.templates.linux {
name = "acm-vm-${user.id}";
uuid = user.uuid;
memory = { count = 512; unit = "MiB"; };
storage_vol = {
# Replaced by final.devices.disk[0].
};
Expand All @@ -214,6 +213,7 @@ in

final = base // {
type = "kvm";

os = {
type = "hvm";
arch = "x86_64";
Expand All @@ -224,14 +224,22 @@ in
# Set each devices.disk[]'s boot order instead.
# boot = [];
};

# Allow 512BM total to the VM, but only allocate 128MB initially.
# See https://pmhahn.github.io/virtio-balloon/.
memory = { count = 512; unit = "MiB"; };
currentMemory = { count = 256; unit = "MiB"; };

sysinfo = {
type = "smbios";
system.serial = "ds=nocloud";
};

vcpu = {
placement = "static";
count = 1;
};

cputune = {
vcpupin =
if self.cpuPinning == null
Expand All @@ -245,6 +253,7 @@ in
}
];
};

devices = base.devices // {
emulator = "/run/libvirt/nix-emulators/qemu-system-x86_64";
disk = with lib; [
Expand Down

0 comments on commit 97195a9

Please sign in to comment.