vmm: cpu: Introduce concept of maximum vs boot vCPUs in CpuManager

For now the max vCPUs is the same as the boot vCPUs.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2019-11-25 13:55:10 +00:00
parent 669d9a8ae8
commit df0907845a
2 changed files with 13 additions and 0 deletions

View File

@ -336,6 +336,7 @@ impl Vcpu {
pub struct CpuManager {
boot_vcpus: u8,
max_vcpus: u8,
io_bus: Weak<devices::Bus>,
mmio_bus: Arc<devices::Bus>,
ioapic: Option<Arc<Mutex<ioapic::Ioapic>>>,
@ -388,6 +389,7 @@ impl BusDevice for CpuManager {
impl CpuManager {
pub fn new(
boot_vcpus: u8,
max_vcpus: u8,
device_manager: &DeviceManager,
guest_memory: Arc<RwLock<GuestMemoryMmap>>,
fd: Arc<VmFd>,
@ -396,6 +398,7 @@ impl CpuManager {
) -> Result<Arc<Mutex<CpuManager>>> {
let cpu_manager = Arc::new(Mutex::new(CpuManager {
boot_vcpus,
max_vcpus,
io_bus: Arc::downgrade(&device_manager.io_bus().clone()),
mmio_bus: device_manager.mmio_bus().clone(),
ioapic: device_manager.ioapic().clone(),
@ -568,4 +571,12 @@ impl CpuManager {
}
Ok(())
}
pub fn boot_vcpus(&self) -> u8 {
self.boot_vcpus
}
pub fn max_vcpus(&self) -> u8 {
self.max_vcpus
}
}

View File

@ -451,8 +451,10 @@ impl Vm {
let on_tty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0;
let boot_vcpus = config.cpus.cpu_count;
let max_vcpus = config.cpus.cpu_count;
let cpu_manager = cpu::CpuManager::new(
boot_vcpus,
max_vcpus,
&device_manager,
guest_memory.clone(),
fd,