Skip to content

Commit b4ae3c2

Browse files
jcajkacgwalters
authored andcommitted
cmdlib: Cap max smp for qemu
Cap max smp for qemu as not to exceed platform limitations, for example qemu supports only up to 255 smp on x86_64, making the qemu invocation fail on host with 255+ LCPUs. Cap value for the smp has been selected arbitrary.
1 parent 34cb607 commit b4ae3c2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/cmd-run

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ VM_DISK=
1919
VM_MEMORY=2048
2020
VM_DISKSIZE=
2121
VM_PERSIST_IMG=
22-
VM_NCPUS="${VM_NCPUS:-$(nproc)}"
22+
VM_NCPUS="${VM_NCPUS:-${QEMU_PROCS}}"
2323
VM_SRV_MNT=
2424
SSH_PORT=${SSH_PORT:-}
2525
UEFI=0

src/cmdlib.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,18 @@ else
6565
esac
6666
fi
6767

68+
if grep -q 'kubepods' /proc/1/cgroup; then
6869
# only use 1 core on kubernetes since we can't determine how much we can actually use
69-
grep -q 'kubepods' /proc/1/cgroup && procs=1 || procs="$(nproc)"
70-
QEMU_KVM+=" -smp $procs"
70+
QEMU_PROCS=1
71+
elif [ "$(nproc)" -gt 16 ]; then
72+
# cap qemu simp at some reasonable level to not exceed limitation of some platforms
73+
QEMU_PROCS=16
74+
else
75+
QEMU_PROCS="$(nproc)"
76+
fi
77+
QEMU_KVM+=" -smp ${QEMU_PROCS}"
7178
export QEMU_KVM
79+
export QEMU_PROCS
7280

7381
_privileged=
7482
has_privileges() {

0 commit comments

Comments
 (0)