Skip to content

Giving -smp option a negative argument makes QEMU dump core

If you pass the '-smp' option a negative argument, QEMU tries to allocate a massive amount of memory and dumps core due to the trap in the glib memory allocation function:

$ qemu-system-x86_64 -smp -2 -display none
qemu-system-x86_64: GLib: ../../../../glib/gmem.c:135: failed to allocate 34359738352 bytes
Trace/breakpoint trap (core dumped)

This isn't specific to the x86 machines -- it happens also for at least the arm and riscv virt machines.

David Gilbert reports that in 5.2 we used to diagnose this cleanly:

qemu-system-x86_64: Invalid SMP CPUs -2. The max CPUs supported by machine 'pc-q35-5.2' is 288

(though even there we are mistakenly interpreting '-2' as a very large number, not a negative one.)

Edited by Peter Maydell
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information