vmm: support setting cpu affinity with host cpu indices >255

On hosts with >256 cpus, setting the cpu affinity to a host cpu index
>255 will return an error because type of `host_cpu` is `u8`.
This commit changes the type of `host_cpu` to `usize` to remove this
limitation.

Signed-off-by: Sean Banko <sbanko@crusoeenergy.com>
This commit is contained in:
Sean Banko
2024-01-16 23:39:09 +00:00
committed by Rob Bradford
parent 993a8324e2
commit e33279471f
4 changed files with 15 additions and 4 deletions

View File

@@ -479,7 +479,7 @@ pub struct CpuManager {
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
acpi_address: Option<GuestAddress>,
proximity_domain_per_cpu: BTreeMap<u8, u32>,
affinity: BTreeMap<u8, Vec<u8>>,
affinity: BTreeMap<u8, Vec<usize>>,
dynamic: bool,
hypervisor: Arc<dyn hypervisor::Hypervisor>,
}
@@ -921,7 +921,7 @@ impl CpuManager {
unsafe { libc::CPU_ZERO(&mut cpuset) };
for host_cpu in host_cpus {
// SAFETY: FFI call, trivially safe
unsafe { libc::CPU_SET(*host_cpu as usize, &mut cpuset) };
unsafe { libc::CPU_SET(*host_cpu, &mut cpuset) };
}
cpuset
});