mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-04-01 20:04:37 +00:00
vmm: cpu: Pass CpusConfig to simplify the new() prototype
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
b584ec3fb3
commit
0646a90626
@ -10,6 +10,8 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
//
|
||||
|
||||
use crate::config::CpusConfig;
|
||||
use crate::device_manager::DeviceManager;
|
||||
#[cfg(feature = "acpi")]
|
||||
use acpi_tables::{aml, aml::Aml, sdt::SDT};
|
||||
@ -507,22 +509,21 @@ impl VcpuState {
|
||||
|
||||
impl CpuManager {
|
||||
pub fn new(
|
||||
boot_vcpus: u8,
|
||||
max_vcpus: u8,
|
||||
config: &CpusConfig,
|
||||
device_manager: &Arc<Mutex<DeviceManager>>,
|
||||
guest_memory: GuestMemoryAtomic<GuestMemoryMmap>,
|
||||
kvm: &Kvm,
|
||||
fd: Arc<VmFd>,
|
||||
reset_evt: EventFd,
|
||||
) -> Result<Arc<Mutex<CpuManager>>> {
|
||||
let mut vcpu_states = Vec::with_capacity(usize::from(max_vcpus));
|
||||
vcpu_states.resize_with(usize::from(max_vcpus), VcpuState::default);
|
||||
let mut vcpu_states = Vec::with_capacity(usize::from(config.max_vcpus));
|
||||
vcpu_states.resize_with(usize::from(config.max_vcpus), VcpuState::default);
|
||||
|
||||
let device_manager = device_manager.lock().unwrap();
|
||||
let cpuid = CpuManager::patch_cpuid(kvm)?;
|
||||
let cpu_manager = Arc::new(Mutex::new(CpuManager {
|
||||
boot_vcpus,
|
||||
max_vcpus,
|
||||
boot_vcpus: config.boot_vcpus,
|
||||
max_vcpus: config.max_vcpus,
|
||||
io_bus: device_manager.io_bus().clone(),
|
||||
mmio_bus: device_manager.mmio_bus().clone(),
|
||||
ioapic: device_manager.ioapic().clone(),
|
||||
|
@ -314,7 +314,6 @@ impl Vm {
|
||||
let memory_manager = MemoryManager::new(fd.clone(), &config.lock().unwrap().memory.clone())
|
||||
.map_err(Error::MemoryManager)?;
|
||||
|
||||
let guest_memory = memory_manager.lock().unwrap().guest_memory();
|
||||
let device_manager = DeviceManager::new(
|
||||
fd.clone(),
|
||||
config.clone(),
|
||||
@ -325,21 +324,17 @@ impl Vm {
|
||||
)
|
||||
.map_err(Error::DeviceManager)?;
|
||||
|
||||
let on_tty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0;
|
||||
|
||||
let boot_vcpus = config.lock().unwrap().cpus.boot_vcpus;
|
||||
let max_vcpus = config.lock().unwrap().cpus.max_vcpus;
|
||||
let cpu_manager = cpu::CpuManager::new(
|
||||
boot_vcpus,
|
||||
max_vcpus,
|
||||
&config.lock().unwrap().cpus.clone(),
|
||||
&device_manager,
|
||||
guest_memory,
|
||||
memory_manager.lock().unwrap().guest_memory(),
|
||||
&kvm,
|
||||
fd,
|
||||
reset_evt,
|
||||
)
|
||||
.map_err(Error::CpuManager)?;
|
||||
|
||||
let on_tty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0;
|
||||
Ok(Vm {
|
||||
kernel,
|
||||
initramfs,
|
||||
|
Loading…
x
Reference in New Issue
Block a user