CPU provisioning on a type-1 hypervisor (KVM specifically)

CPU provisioning on a type-1 hypervisor (KVM specifically)

Author
Discussion

donkmeister

Original Poster:

8,967 posts

106 months

Tuesday 9th May 2023
quotequote all
TLDR: if I run a Windows VM in KVM on Debian, will the VM receive CPU time dynamically? Or do I need to specify a CPU that can cope with the max processing requirements of the host AND the VM simultaneously, even though it's unlikely this will ever happen simultaneously?

The lengthier version: As TrueNAS now comes in Linux flavour (aka TrueNAS Scale), I've been looking with interest at the KVM implementation as I could run a Windows VM on this and consolidate two machines (a BSD FreeNAS and a Windows machine) into one.

I use Hyper-V to run an Ubuntu VM to access Linux tools that don't require much grunt, but I am definitely a VM noob. I know that I need to set the RAM allocation, as OS's hate memory that expands and contracts, so I will spec the box accordingly. However, I am clueless about how CPU is allocated. To put some arbitrary numbers on it, if my VM and host each need 10 units of CPU at idle, and occasionally spiking to 90 units, I'm assuming that KVM would be smart enough to "give" processing power to the machine that currently needs it, so I could possibly get away with a box with 100 units of processing power, but certainly wouldn't need 180 units to cope with both peaks simultaneously?

Monsterlime

1,269 posts

172 months

Wednesday 10th May 2023
quotequote all
KVM works differently. You allocate vcpus/cores to each VM. You can 'pin' vcpus/cores to a VM, so when the VM is running it gets exclusive use of those and the OS doesn't use them. You do need to edit the VM's config file to do this, and a couple of other steps. You should also look at SPICE, and make sure that and the VirtIO drivers all get installed on Windows for the best performance (Linux VMs come with this all backed into the kernel).

KVM/Qemu is brilliant, but if you are looking to run the box as just a VM host, look at something like Proxmox. It uses KVM on the backend, but provides a pretty slick web interface and does a lot of the optimisation stuff for you, or makes it a lot easier to implement. I run my TrueNAS Scale install on Proxmox, although it was physical so I just passed the original SSD hosting the install and the HBA card with all the drives on through to the VM in Proxmox and it just worked. That machine also runs OPNSense, a Windows 11 VM and a couple of other things, with no problems.

donkmeister

Original Poster:

8,967 posts

106 months

Wednesday 10th May 2023
quotequote all
That's all useful, thanks. Funnily enough I'd actually decided against Proxmox as I wasn't convinced it would be as reliable to run TrueNAS on that Vs bare metal. As I'm not recycling hardware this time I'm looking at a build with ECC ram due to the general paranoia about ZFS on non-ECC systems (never had a problem yet, but that doesn't mean I will never have one).

I'd actually rather have CPU dynamically assigned; the windows box runs services that bumble along for most hours of the day but occasionally have a few minutes where they need to do some work... Would rather have that runtime available for other things than ringfenced and mostly unused.

Trustmeimadoctor

13,239 posts

161 months

Thursday 11th May 2023
quotequote all
Just don't reserve silly amounts of CPU MHz and set sensible restriction for core MHz

Reservation as CPU reserved for that VM per core restriction is restricting the maximum MHz each core can use ( in esxi anyway)

Proxmox can be bare metal

All bare metal hypervisors still run Linux underneath and proxmox do a baremetal

Edited by Trustmeimadoctor on Thursday 11th May 09:30