Virtual guest virtual cores?

Anyone know if it is possible with kvm/qemu to have virtual cpu cores on the guest - ie. guest cores not mapped to host cores ?

What I’d like to be able to do is set the VM up with say 8 cores and from time to time have those 8 cores serviced by a different number of host cores eg. the host might be providing/using 2 cores exclusively for the vm but the vm thinks it’s got 8 cores then I allocate 4 host cores for the vm and the vm doesn’t know anything has changed (but it runs faster).

(The reason I ask is that when you change the vm cpu config, Windows VMs insist on being “reactivated”)

It sounds like you want to Hot Swap CPUs. Set the Current to 2 and the Max to 8. When you want to enable all 8 use the “virsh setvcpus vmname 8” command. (To go back to 2, replace the 8 with a 2)

Windows VMs would require the virtio drivers to work correctly.

image

Cheers ! I’ll give that a go / run some tests.

TLDR:

Relates specifically to Windows VMs.

It seems you can modify most cpu resources without having to worry about Windows reactivation.

Using VMM (virt-manager)…

  1. Alter CPUs > Current allocation as desired.
  2. Manually alter CPU Topology with Sockets = 1 or 2 (Windows 10 limit *) and Core = Current allocation / Sockets, leaving Threads = 1

This did not trigger a Windows reactivation demand for me but your experience may vary so maybe try on a backup first.

Changing the CPU Model did trigger a Windows reactivation demand for me (there may be other stuff too).

* Windows cpu limits
_________________________________________________________________________

@joebeasley3, tried your suggestion and changing cpu allocation or maximum allocation didn’t trigger a Windows reactivation demand :+1:. However Windows didn’t report any change in the number of virtual processors either… not that I originally wanted that but it had me wondering if those changes were having any effect…

I since found these:

Windows 2 socket limit and how altering topology will get windows to recognise additional threads

Viewing all Virtual processors

I haven’t managed to find a set of actions that lets me go from:
a VM with 8 Virtual processors (VPs) serviced by 4 Logical Host CPUs (LHCs)
to
a VM with 8 Virtual processors serviced by 6 Logical Host CPUs

…then again I haven’t managed to get a situation where I have more VPs than allocated LHCs. (maybe its not possible ?) *1

…but it doesn’t matter as a combination of altering cpu allocation as you suggested and changing topology gives me what I wanted as neither triggers a Windows reactivation and I can vary resource allocation.

Probably best to alter the topology so Windows sees the extra VPs but it would be nice to know (curiosity) if increasing allocated cpus alone does have any effect:
(Window 10 Pro VM)

A   allocated 4 Maximum 8  Sockets 8 Cores 1 Threads 1   = VM : Sockets 2 VPs 2
B   allocated 8 Maximum 8  Sockets 8 Cores 1 Threads 1   = VM : Sockets 2 VPs 2 - alocation increased but not recognised in VM - are the 2 VPs able to handle twice the load of the 2 VPs in config A ?
C   allocated 4 Maximum 8  Sockets 4 Cores 2 Threads 1   = VM : Sockets 2 VPs 4 - same allocation as A but twice the VPs recognised
D   allocated 8 Maximum 8  Sockets 4 Cores 2 Threads 1   = VM : Sockets 2 VPs 4 - no change on C despite twice the allocation ( Windows 2 socket limit ) 
E   allocated 2 Maximum 8  Sockets 4 Cores 2 Threads 1   = VM : Sockets 1 VPs 2 - Can only service 1 2-core socket with 2 LHCs it seems
F   allocated 4 Maximum 12 Sockets 2 Cores 6 Threads 1   = VM : Sockets 1 VPs 4 - Does the best it can: 4 of the 6 cores for 1 socket.
G   allocated 4 Maximum 8  Sockets 2 Cores 4 Threads 1   = VM : Sockets 1 VPs 4 - Can only service 1 4-core socket with 4 LHCs it seems
H   allocated 8 Maximum 8  Sockets 2 Cores 4 Threads 1   = VM : Sockets 2 VPs 8 - Can service 2 4-core sockets with 8 LHCs.

So from E-H it looks like a 1-to-1 LHC-to-VP relationship which’d suggest *1 above and that with allocation alone (B) the extra resources don’t get used as that would imply more than one LHC servicing a single VP which’d be harder to implement than one LHC servicing multiple VPs which doesn’t appear to be happening.

Someone somewhere knows…

Thanks for the steer !