mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-21 13:15:19 +00:00
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:
parent
993a8324e2
commit
e33279471f
@ -290,6 +290,17 @@ impl TupleValue for Vec<u64> {
|
||||
}
|
||||
}
|
||||
|
||||
impl TupleValue for Vec<usize> {
|
||||
fn parse_value(input: &str) -> Result<Self, TupleError> {
|
||||
Ok(IntegerList::from_str(input)
|
||||
.map_err(TupleError::InvalidIntegerList)?
|
||||
.0
|
||||
.iter()
|
||||
.map(|v| *v as usize)
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Tuple<S, T>(pub Vec<(S, T)>);
|
||||
|
||||
pub enum TupleError {
|
||||
|
@ -590,7 +590,7 @@ impl CpusConfig {
|
||||
.map_err(Error::ParseCpus)?
|
||||
.unwrap_or(DEFAULT_MAX_PHYS_BITS);
|
||||
let affinity = parser
|
||||
.convert::<Tuple<u8, Vec<u8>>>("affinity")
|
||||
.convert::<Tuple<u8, Vec<usize>>>("affinity")
|
||||
.map_err(Error::ParseCpus)?
|
||||
.map(|v| {
|
||||
v.0.iter()
|
||||
|
@ -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
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ use virtio_devices::RateLimiterConfig;
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct CpuAffinity {
|
||||
pub vcpu: u8,
|
||||
pub host_cpus: Vec<u8>,
|
||||
pub host_cpus: Vec<usize>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
|
||||
|
Loading…
Reference in New Issue
Block a user