On Thu, Oct 22, 2020 at 11:01 PM Matt Coleman <mcoleman(a)datto.com> 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-...
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 would suggest introducing a new value. The problem with overloading
values is that if there's other code expecting that to mean something,
it gets confusing really quickly.
--
真実はいつも一つ!/ Always, there's only one truth!