Hyper-V CPU details

Daniel P. Berrangé berrange at redhat.com
Wed Nov 4 11:17:44 UTC 2020


On Thu, Oct 22, 2020 at 10:58:28PM -0400, Matt Coleman wrote:
> Hello,
> 
> 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 
> about.
> 
> 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:
> 
> https://gitlab.com/libvirt/libvirt/-/blob/v6.8.0/include/libvirt/libvirt-domain.h#L1918
> 
> 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?

I don't believe there's any way to express this given the current
defined API semantics. So I think introducing "-2" is the only viable
option.

I'd suggest that we introduce some constants for this API

 #define VIR_DOMAIN_VCPU_INFO_CPU_OFFLINE     -1
 #define VIR_DOMAIN_VCPU_INFO_CPU_UNAVAILABLE -2

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list