From: Daan De Meyer Date: Mon, 8 Apr 2024 20:32:06 +0000 (+0200) Subject: Allow setting QemuSmp=0 to use all available CPUs X-Git-Tag: v23~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b603426da726d27dca8ed2e4cdad25b667553ce2;p=thirdparty%2Fmkosi.git Allow setting QemuSmp=0 to use all available CPUs --- diff --git a/mkosi/qemu.py b/mkosi/qemu.py index 07e4e46f3..e32b3b485 100644 --- a/mkosi/qemu.py +++ b/mkosi/qemu.py @@ -808,7 +808,7 @@ def run_qemu(args: Args, config: Config) -> None: cmdline: list[PathString] = [ find_qemu_binary(config), "-machine", machine, - "-smp", str(config.qemu_smp), + "-smp", str(config.qemu_smp or os.cpu_count()), "-m", f"{config.qemu_mem // 1024**2}M", "-object", "rng-random,filename=/dev/urandom,id=rng0", "-device", "virtio-rng-pci,rng=rng0,id=rng-device0", diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index 762955c7d..15218de10 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -1530,6 +1530,9 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, : When used with the `qemu` verb, this options sets `qemu`'s `-smp` argument which controls the number of guest's CPUs. Defaults to `2`. +: When set to `0`, the number of CPUs available to the mkosi process + will be used. + `QemuMem=`, `--qemu-mem=` : When used with the `qemu` verb, this options sets `qemu`'s `-m` diff --git a/mkosi/vmspawn.py b/mkosi/vmspawn.py index c1b910f99..ecef21a2c 100644 --- a/mkosi/vmspawn.py +++ b/mkosi/vmspawn.py @@ -51,7 +51,7 @@ def run_vmspawn(args: Args, config: Config) -> None: cmdline: list[PathString] = [ "systemd-vmspawn", - "--cpus", str(config.qemu_smp), + "--cpus", str(config.qemu_smp or os.cpu_count()), "--ram", str(config.qemu_mem), "--kvm", config.qemu_kvm.to_tristate(), "--vsock", config.qemu_vsock.to_tristate(),