Launch a guest which supports cpu hotplug like F18 or Win 2008 with a qemu qmp server:
$ qemu-kvm -cpu host -enable-kvm -m 1024 -smp 2,maxcpus=4 -drive file=/root/f18-live.iso -qmp tcp:localhost:4444,server
Connect to the qmp server using telnet
$ telnet localhost 4444
Issue the json command as follows to check qmp capabilities, otherwise the following cpu-add command does not work.
INPUT: { "execute": "qmp_capabilities" }
OUTPUT: {"return": {}}
Issue the json commands to add vcpus to the guest:
INPUT: { "execute": "cpu-add", "arguments": { "id": 2} }
OUTPUT: {"return": {}}
INPUT: { "execute": "cpu-add", "arguments": { "id": 3} }
OUTPUT: {"return": {}}
Go check the guest, and if it is a linux, you will see 2 cpus have been made available under /sys/devices/system/cpu/. To activate either of them, issue a command like:
$ echo 1 > /sys/devices/system/cpu/cpu2/online
结语
cpu hotplug的邮件列表,请参考:http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg01156.html