(I'm using xcp-ng/xen as my hypervisor but general question as I also wonder this about qemu/kvm and virtualbox when I use them) whenever I make a VM, I have an option to give it as many cores as I want, up to however many the system has anyway...and I can give all my VMs all my cpu cores if I want, which seems to imply they will share them.

which then brings up the question in my head: is there a reason not to give all my VMs all my cores, if the host system is just doing hypervisor duty?

2 Answers 2


Because you will increase the amount of context switching that happens when any of the VMs are under any non-negligible load. Context switching is much more expensive when running under a hypervisor. Here are some recent performance measurements of virtualization overhead I made.

There are other benefits to limiting each VM to fewer CPU cores that you have - for example, it means that one VM, if it goes rogue, cannot make everything else on the machine grind to a halt. There are also potential security concerns with VMs sharing CPUs, but that is not too important of you trust all the VMs you are running (e.g. spectre / meltdown style attacks).

  • 1
    Thank you! Also ended up finding this article from Citrix about overprovisioning guidelines (granted it seems to be more towards a very specific use case, but nice to find something to read about the topic anyway)
    – user863492
    Nov 3, 2020 at 21:20

When making a VM, why would I want to not pass it all my cpu cores?

By the title of your question, seems like you are mixing two completely different things. "Passing" would mean dedicating it to the exclusive use by the VM. That is not what you're doing when you are setting the number of "virtual CPUs" in Virtualbox. And although the traditional wisdom has been for that number to be no more than the number of physical cores on the host, my experience has proven that this is not necessarily the case. For example, in Virtualbox, I have started a few VMs with 6 virtual CPUs each, on a host thas a 4-core-8-thread CPU. Some of these VMs are doing some heavy compiling tasks, and at the same time I am doing my usual work on the host. No negative effects whatsoever -- I feel no lag, no stutter, no slowdown on the host. As to the benefit, there is a measurable, though marginal speed improvement over 4-CPU guests -- the kernel compilation tasks finish measurably faster, though not by much. Further increasing the number of virtual CPUs in the guest has shown me to bring no further benefit. So, again, in this setup we are not "passing" CPU cores to the guest -- it is up to qemu/kvm/Virtualbox how to present virtual CPUs to the guests, and apparently Virtualbox is doing a good job of it.

(Note: In your post you also mention the word "Xen". I can not comment on Xen, but I have a suspicion that with Xen it may actually be a matter of "passing" CPU cores. Somebody else may want to comment on Xen.)

  • Yeah seems like what I was actually talking about is more normally referred to as "over provisioning". can read more about Xenserver overprovis here seems to be a pretty normal practice in both Xenserver and vmware, with caveats about not exceeding a certain ratio of cores provisioned:actual cores.
    – user863492
    Nov 7, 2020 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .