mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +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 struct Tuple<S, T>(pub Vec<(S, T)>);
|
||||||
|
|
||||||
pub enum TupleError {
|
pub enum TupleError {
|
||||||
|
@ -590,7 +590,7 @@ impl CpusConfig {
|
|||||||
.map_err(Error::ParseCpus)?
|
.map_err(Error::ParseCpus)?
|
||||||
.unwrap_or(DEFAULT_MAX_PHYS_BITS);
|
.unwrap_or(DEFAULT_MAX_PHYS_BITS);
|
||||||
let affinity = parser
|
let affinity = parser
|
||||||
.convert::<Tuple<u8, Vec<u8>>>("affinity")
|
.convert::<Tuple<u8, Vec<usize>>>("affinity")
|
||||||
.map_err(Error::ParseCpus)?
|
.map_err(Error::ParseCpus)?
|
||||||
.map(|v| {
|
.map(|v| {
|
||||||
v.0.iter()
|
v.0.iter()
|
||||||
|
@ -479,7 +479,7 @@ pub struct CpuManager {
|
|||||||
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
||||||
acpi_address: Option<GuestAddress>,
|
acpi_address: Option<GuestAddress>,
|
||||||
proximity_domain_per_cpu: BTreeMap<u8, u32>,
|
proximity_domain_per_cpu: BTreeMap<u8, u32>,
|
||||||
affinity: BTreeMap<u8, Vec<u8>>,
|
affinity: BTreeMap<u8, Vec<usize>>,
|
||||||
dynamic: bool,
|
dynamic: bool,
|
||||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||||
}
|
}
|
||||||
@ -921,7 +921,7 @@ impl CpuManager {
|
|||||||
unsafe { libc::CPU_ZERO(&mut cpuset) };
|
unsafe { libc::CPU_ZERO(&mut cpuset) };
|
||||||
for host_cpu in host_cpus {
|
for host_cpu in host_cpus {
|
||||||
// SAFETY: FFI call, trivially safe
|
// SAFETY: FFI call, trivially safe
|
||||||
unsafe { libc::CPU_SET(*host_cpu as usize, &mut cpuset) };
|
unsafe { libc::CPU_SET(*host_cpu, &mut cpuset) };
|
||||||
}
|
}
|
||||||
cpuset
|
cpuset
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ use virtio_devices::RateLimiterConfig;
|
|||||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
pub struct CpuAffinity {
|
pub struct CpuAffinity {
|
||||||
pub vcpu: u8,
|
pub vcpu: u8,
|
||||||
pub host_cpus: Vec<u8>,
|
pub host_cpus: Vec<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user