Hyper-V CPU details

Matt Coleman mcoleman at datto.com
Fri Oct 23 02:58:28 UTC 2020


I'm implementing domainGetVcpus and could use some guidance on what 
value to use for virVcpuInfo->cpu.

Hyper-V does not allow the user to pin vCPUs to host CPUs and doesn't 
allow the user to see which host CPU a vCPU is currently running on. 
Since it's a type 1 hypervisor, none of its scheduling data is 
available to the Windows userspace: there aren't any processes or 
threads that correspond to vCPUs that I could query the OS scheduler 

My code currently sets it to -1, which produces the following `virsh 
vcpuinfo` output for a running VM with two cores:

VCPU:           0
CPU:            -1
State:          running
CPU time:       1684.5s
CPU Affinity:   yyyy

VCPU:           1
CPU:            -1
State:          running
CPU time:       1346.0s
CPU Affinity:   yyyy

However, this doesn't match the comment in _virVcpuInfo's declaration, 
which says that -1 signifies an offline CPU:


Should I stick with -1? Or, should I introduce -2 as a value that 
indicates that the hypervisor doesn't provide that information? Or, is 
there some better way to handle this that I'm not aware of?


More information about the libvir-list mailing list