mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 11:05:46 +00:00
vmm: cpu: Create vCPU state for all possible vCPUs
This will make it more straightforward when we attempt to remove vCPUs. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
156ea392a2
commit
7e81b0ded7
@ -440,6 +440,7 @@ impl BusDevice for CpuManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
struct VcpuState {
|
struct VcpuState {
|
||||||
inserting: bool,
|
inserting: bool,
|
||||||
handle: Option<thread::JoinHandle<()>>,
|
handle: Option<thread::JoinHandle<()>>,
|
||||||
@ -483,6 +484,9 @@ impl CpuManager {
|
|||||||
cpuid: CpuId,
|
cpuid: CpuId,
|
||||||
reset_evt: EventFd,
|
reset_evt: EventFd,
|
||||||
) -> Result<Arc<Mutex<CpuManager>>> {
|
) -> 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 cpu_manager = Arc::new(Mutex::new(CpuManager {
|
let cpu_manager = Arc::new(Mutex::new(CpuManager {
|
||||||
boot_vcpus,
|
boot_vcpus,
|
||||||
max_vcpus,
|
max_vcpus,
|
||||||
@ -494,7 +498,7 @@ impl CpuManager {
|
|||||||
fd,
|
fd,
|
||||||
vcpus_kill_signalled: Arc::new(AtomicBool::new(false)),
|
vcpus_kill_signalled: Arc::new(AtomicBool::new(false)),
|
||||||
vcpus_pause_signalled: Arc::new(AtomicBool::new(false)),
|
vcpus_pause_signalled: Arc::new(AtomicBool::new(false)),
|
||||||
vcpu_states: Vec::with_capacity(max_vcpus as usize),
|
vcpu_states,
|
||||||
reset_evt,
|
reset_evt,
|
||||||
selected_cpu: 0,
|
selected_cpu: 0,
|
||||||
}));
|
}));
|
||||||
@ -608,10 +612,8 @@ impl CpuManager {
|
|||||||
|
|
||||||
// On hot plug calls into this function entry_addr is None. It is for
|
// On hot plug calls into this function entry_addr is None. It is for
|
||||||
// those hotplug CPU additions that we need to set the inserting flag.
|
// those hotplug CPU additions that we need to set the inserting flag.
|
||||||
self.vcpu_states.push(VcpuState {
|
self.vcpu_states[usize::from(cpu_id)].handle = handle;
|
||||||
handle,
|
self.vcpu_states[usize::from(cpu_id)].inserting = entry_addr.is_none();
|
||||||
inserting: entry_addr.is_none(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unblock all CPU threads.
|
// Unblock all CPU threads.
|
||||||
@ -656,7 +658,9 @@ impl CpuManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn present_vcpus(&self) -> u8 {
|
fn present_vcpus(&self) -> u8 {
|
||||||
self.vcpu_states.len() as u8
|
self.vcpu_states
|
||||||
|
.iter()
|
||||||
|
.fold(0, |acc, state| acc + state.active() as u8)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
|
Loading…
Reference in New Issue
Block a user