Assigning cores to VMs on HT / SMT CPUs: QEMU/KVM vs. Virtualbox

Ohai there!

I’d like to discuss the science (cause and effect) of assigning CPU cores to VMs. Especially with QEMU/KVM on Intel HT (Hyper-Threading) or AMD SMT (Simultaneous Multi-Threading). All my relevant CPUs are hyper-threaded, in a 4c8t configuration (i7-4790 / E3-1230v5) and i run VMs on both of’em.

Virtualbox throws a warning at me when i try to assign more than the physical 4 cores to a VM, but virt-manager (QEMU/KVM) doesn’t.

  1. Why does Virtualbox do that?
  2. Why does virt-manager (QEMU/KVM) not do that?
  3. What’s the science of assigning CPU cores?
  4. Doesn’t the bare-metal host OS distribute the load across those HT / SMT cores anyway?

Don’t know about virtual box but with kvm the number of CPUs is the number of processes that kvm will run for that vm. The host OS is still doing the scheduling. So it isn’t the case that a core is taken from the host and dedicated to the VM or that a specific physical core will be used for the VM.

From personal experience and reviewing various test results around the web, the VirtualBox warning is inane and pointless. Feel free to use your threads as needed.

Oracle is silly and probably had a lawyer add that warning, rather than a knowledgeable technician.

Open source is always better/smarter.

You can tell a virtual machine manager how many cores/threads to use, or in some cases (QEMU/KVM) you can pin specific cores and threads to a VM. The latter may or may not be beneficial to your use scenario. In all cases, the virtual machine manager creates a process per thread that, bluntly, transfers I/O as if that thread were part of a real processor.

Not really sure what you mean by “distribute the load”, but the OS does not take place in the assignment of cores and threads. If you mean hypervisors, then yes. However, VirtualBox and QEMU/KVM are both Type 2 hypervisors and run on the OS rather than the bare metal. Some Type 1 hypervisors (bare-metal) are Hyper-V, Xen, and VMware. QEMU/KVM are in a unique scenario where they run on Linux, but provide near bare-metal performance.

I hope that clears it up a bit, but feel free to ask more questions. :slight_smile: