With virtual machines running modern server operating systems, VirtualBox supports CPU hot-plugging.Whereas on a physical computer this would mean that a CPU can be added or removed while the machine is running, VirtualBox supports adding and removing virtual CPUs while a virtual machine is running.

CPU hot-plugging works only with guest operating systems that support it. So far this applies only to Linux and Windows Server 2008 x64 Data Center Edition. Windows supports only hot-add while Linux supports hot-add and hot-remove but to use this feature with more than 8 CPUs a 64bit Linux guest is required.

At this time, CPU hot-plugging requires using the VBoxManage command-line interface. First, hot-plugging needs to be enabled for a virtual machine:

VBoxManage modifyvm <vmname> –cpuhotplug on

After that, the –cpus option specifies the maximum number of CPUs that the virtual machine can have:

VBoxManage modifyvm <vmname> –cpus 8

When the VM is off, you can then add and remove virtual CPUs with the modifyvm –plugcpu and –unplugcpu subcommands, which take the number of the virtual CPU as a parameter, like this:

ERROR: Hot-Remove was aborted because the CPU may still be used by the guest
Details: code VBOX_E_VM_ERROR (0x80bb0003), component Console, interface IConsole, callee nsISupports
Context: “HotUnplugCPU(n)” at line 125 of file VBoxManageControlVM.cpp
Based on the virtual box manual as following, we need guest addition installed to manage the hot-remove event.

With Linux guests, the following applies: To .prevent ejection while the CPU is still used it has to be ejected from within the guest before. The Linux Guest Additions contain a service which receives hot-remove events and ejects the CPU