mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-03 20:15:45 +00:00
vmm: cpu: Save CpusConfig into CpuManager
Rather than saving the individual parts into the CpuManager save the full struct as it now also contains the topology data. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
284891b5df
commit
b81bc77390
@ -535,8 +535,7 @@ impl Snapshottable for Vcpu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct CpuManager {
|
pub struct CpuManager {
|
||||||
boot_vcpus: u8,
|
config: CpusConfig,
|
||||||
max_vcpus: u8,
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
io_bus: Arc<devices::Bus>,
|
io_bus: Arc<devices::Bus>,
|
||||||
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
||||||
@ -689,8 +688,7 @@ impl CpuManager {
|
|||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
let cpuid = CpuManager::patch_cpuid(kvm)?;
|
let cpuid = CpuManager::patch_cpuid(kvm)?;
|
||||||
let cpu_manager = Arc::new(Mutex::new(CpuManager {
|
let cpu_manager = Arc::new(Mutex::new(CpuManager {
|
||||||
boot_vcpus: config.boot_vcpus,
|
config: config.clone(),
|
||||||
max_vcpus: config.max_vcpus,
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
io_bus: device_manager.io_bus().clone(),
|
io_bus: device_manager.io_bus().clone(),
|
||||||
mmio_bus: device_manager.mmio_bus().clone(),
|
mmio_bus: device_manager.mmio_bus().clone(),
|
||||||
@ -824,7 +822,7 @@ impl CpuManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_vcpus(&mut self, desired_vcpus: u8, entry_point: Option<EntryPoint>) -> Result<()> {
|
fn create_vcpus(&mut self, desired_vcpus: u8, entry_point: Option<EntryPoint>) -> Result<()> {
|
||||||
if desired_vcpus > self.max_vcpus {
|
if desired_vcpus > self.config.max_vcpus {
|
||||||
return Err(Error::DesiredVCPUCountExceedsMax);
|
return Err(Error::DesiredVCPUCountExceedsMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -923,7 +921,7 @@ impl CpuManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn activate_vcpus(&mut self, desired_vcpus: u8, inserting: bool) -> Result<()> {
|
fn activate_vcpus(&mut self, desired_vcpus: u8, inserting: bool) -> Result<()> {
|
||||||
if desired_vcpus > self.max_vcpus {
|
if desired_vcpus > self.config.max_vcpus {
|
||||||
return Err(Error::DesiredVCPUCountExceedsMax);
|
return Err(Error::DesiredVCPUCountExceedsMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,11 +1000,11 @@ impl CpuManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn boot_vcpus(&self) -> u8 {
|
pub fn boot_vcpus(&self) -> u8 {
|
||||||
self.boot_vcpus
|
self.config.boot_vcpus
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn max_vcpus(&self) -> u8 {
|
pub fn max_vcpus(&self) -> u8 {
|
||||||
self.max_vcpus
|
self.config.max_vcpus
|
||||||
}
|
}
|
||||||
|
|
||||||
fn present_vcpus(&self) -> u8 {
|
fn present_vcpus(&self) -> u8 {
|
||||||
@ -1028,18 +1026,18 @@ impl CpuManager {
|
|||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
pub fn create_madt(&self) -> SDT {
|
pub fn create_madt(&self) -> SDT {
|
||||||
// This is also checked in the commandline parsing.
|
// This is also checked in the commandline parsing.
|
||||||
assert!(self.boot_vcpus <= self.max_vcpus);
|
assert!(self.config.boot_vcpus <= self.config.max_vcpus);
|
||||||
|
|
||||||
let mut madt = SDT::new(*b"APIC", 44, 5, *b"CLOUDH", *b"CHMADT ", 1);
|
let mut madt = SDT::new(*b"APIC", 44, 5, *b"CLOUDH", *b"CHMADT ", 1);
|
||||||
madt.write(36, layout::APIC_START);
|
madt.write(36, layout::APIC_START);
|
||||||
|
|
||||||
for cpu in 0..self.max_vcpus {
|
for cpu in 0..self.config.max_vcpus {
|
||||||
let lapic = LocalAPIC {
|
let lapic = LocalAPIC {
|
||||||
r#type: 0,
|
r#type: 0,
|
||||||
length: 8,
|
length: 8,
|
||||||
processor_id: cpu,
|
processor_id: cpu,
|
||||||
apic_id: cpu,
|
apic_id: cpu,
|
||||||
flags: if cpu < self.boot_vcpus {
|
flags: if cpu < self.config.boot_vcpus {
|
||||||
1 << MADT_CPU_ENABLE_FLAG
|
1 << MADT_CPU_ENABLE_FLAG
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
@ -1335,12 +1333,12 @@ impl Aml for CpuManager {
|
|||||||
let uid = aml::Name::new("_CID".into(), &aml::EISAName::new("PNP0A05"));
|
let uid = aml::Name::new("_CID".into(), &aml::EISAName::new("PNP0A05"));
|
||||||
// Bundle methods together under a common object
|
// Bundle methods together under a common object
|
||||||
let methods = CPUMethods {
|
let methods = CPUMethods {
|
||||||
max_vcpus: self.max_vcpus,
|
max_vcpus: self.config.max_vcpus,
|
||||||
};
|
};
|
||||||
let mut cpu_data_inner: Vec<&dyn aml::Aml> = vec![&hid, &uid, &methods];
|
let mut cpu_data_inner: Vec<&dyn aml::Aml> = vec![&hid, &uid, &methods];
|
||||||
|
|
||||||
let mut cpu_devices = Vec::new();
|
let mut cpu_devices = Vec::new();
|
||||||
for cpu_id in 0..self.max_vcpus {
|
for cpu_id in 0..self.config.max_vcpus {
|
||||||
let cpu_device = CPU { cpu_id };
|
let cpu_device = CPU { cpu_id };
|
||||||
|
|
||||||
cpu_devices.push(cpu_device);
|
cpu_devices.push(cpu_device);
|
||||||
|
Loading…
Reference in New Issue
Block a user