]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Allow setting QemuSmp=0 to use all available CPUs
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 8 Apr 2024 20:32:06 +0000 (22:32 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 10 Apr 2024 08:29:30 +0000 (10:29 +0200)
mkosi/qemu.py
mkosi/resources/mkosi.md
mkosi/vmspawn.py

index 07e4e46f337fcc741416315a2243dca954ce7286..e32b3b48512cc559865db150cc9573bea5254a5e 100644 (file)
@@ -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",
index 762955c7df6fa30b0840f26ed91153e3142cd01b..15218de100884ba708a5bb0ea15c8b07cd1f1351 100644 (file)
@@ -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`
index c1b910f99cdf43aeb25651ce61cb08750a861ee3..ecef21a2ca9c5e7214f9e6b52896b0e5d1993645 100644 (file)
@@ -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(),