Hello. I have some experience with virtual machines, I have ran them, know how Intel VT-x helps, but I would like to know more about CPU cores for VMs. If I assign 1 CPU core to a VM, will that allow the VM to get exclusive access to the core? Can a CPU with 4 cores run more than 4 VMs? And also, does Intel Hyperthreading help with virtualisation?
The hypervisor is responsible for slicing up the CPU resources amongst all the running virtual machines. CPU performance depends on how many things need how much resources at any given time. Most likely, whatever you're running in any one VM doesn't need 100% CPU 24/7 so those resources are available to other VMs. If you run into a situation where many or all VMs need a lot of CPU at the same time and you have more virtual cores than real cores, well then you got a problem. Just as an example, on a 4-core i7 machine (2012R2 Hyper-V, hyperthreading enabled so it sees 8 "cores") I have 6 virtual machines running. Two have four cores allocated, the others have two. I have several other machines that I can spin up as needed but aren't running all the time. That's 14+ cores total on an 8 core machine. But none of them are a heavy load so it is ok 99% of the time. There are also settings if I need them where I can specify that a particular VM can only use xx% of the cores it has access to. In a typical situation, RAM is the limiting factor, not CPU. Long before you have enough stuff running to bog down all the CPU, you'll run out of memory. Not sure why I decided to go back into this and write a thesis after adequately answering in the first two sentences.
The thing to remember when running VM's is that you are sharing resources from the host. if you have a quad core CPU and make a VM with one core then yes that vm guest will run on one core sharing with the host but will be slow. If you have set it to use all 4 core's it will still share with the host resources but will be more faster. what i am trying to say here is if the host computer is heavy loaded and using all 4 core's then a vm using 4 core's will run very slowly as the host is more important machine the resources then have to be delegated in time segment's between the host and guest.
Which is why if you are going to run virtual machines in a production environment, the host should be as lean as possible with very little or no function other than the hypervisor itself.
Yes and No. Yes, exclusive access only between VM's - VMware ESX for example allows you to dedicate a specific core to a vm. No, because altough you have a vm pointed to a certain core, the host machine will still keep using this core for its own operations (including certain vm handling operations). From the 'No' point of view, you will never have exclusive access to a processor core on any system. Hyperthreading helps with processing in general, it does not matter if it is calculating simple formulas on Excel, or processing complex operations of an operating system, such as making virtualization possible. As far as i know, virtual machines do not see hyperthread queues as individual cores. But in the background, yes, it is helping the physical host process operations.