Environment: Openstack Juno. (Same code in the master as well).
Physical machine doesn't have continuous blocks of cpu in online state.
Online pCPUs are: 4,8 and 12.
vcpu pinning is enabled via the vcpu_pin_set attribute in /etc/nova/nova.conf
vcpu_pin_set="4,8,12"
The nova code in /nova/virt/libvirt/driver.py inside get_vcpu_total() is checking the length of available_ids from the nova.conf as:
if available_ids[-1] >= total_pcpus:
raise exception.Invalid(_("Invalid vcpu_pin_set config, "
"out of hypervisor cpu range."))
available_ids in this case contains [4,8,12].
The total pcpus count given by libvirt is 3 (number of on-line pcpus).
Hence the above check fails since it determines the total available CPUs as 12.
Nova should not expect the online CPUs to be continuous numbers always.
Filing a bug to address this.
Also figured out that the present check is like this:
sorted( available_ ids)[-1] >= total_pcpus
This allows us to detect the out of range pCPUs correctly.
For example if the range specified in the conf file is 0-16 and the total pcpus are only 10, then we would detect that as a invalid config. So the fix should be to retain this out of range behavior but the total_pcpus check needs to be improved.
Working on the same.