mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-02 01:45:21 +00:00
cpu: Store hypervisor object directly instead of separate props
Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
parent
b52966a12c
commit
311fc05417
@ -454,7 +454,6 @@ impl Snapshottable for Vcpu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct CpuManager {
|
pub struct CpuManager {
|
||||||
hypervisor_type: HypervisorType,
|
|
||||||
config: CpusConfig,
|
config: CpusConfig,
|
||||||
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
||||||
interrupt_controller: Option<Arc<Mutex<dyn InterruptController>>>,
|
interrupt_controller: Option<Arc<Mutex<dyn InterruptController>>>,
|
||||||
@ -479,8 +478,7 @@ pub struct CpuManager {
|
|||||||
proximity_domain_per_cpu: BTreeMap<u8, u32>,
|
proximity_domain_per_cpu: BTreeMap<u8, u32>,
|
||||||
affinity: BTreeMap<u8, Vec<u8>>,
|
affinity: BTreeMap<u8, Vec<u8>>,
|
||||||
dynamic: bool,
|
dynamic: bool,
|
||||||
#[cfg(target_arch = "x86_64")]
|
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||||
cpu_vendor: CpuVendor,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CPU_ENABLE_FLAG: usize = 0;
|
const CPU_ENABLE_FLAG: usize = 0;
|
||||||
@ -699,7 +697,6 @@ impl CpuManager {
|
|||||||
let dynamic = true;
|
let dynamic = true;
|
||||||
|
|
||||||
Ok(Arc::new(Mutex::new(CpuManager {
|
Ok(Arc::new(Mutex::new(CpuManager {
|
||||||
hypervisor_type,
|
|
||||||
config: config.clone(),
|
config: config.clone(),
|
||||||
interrupt_controller: None,
|
interrupt_controller: None,
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
@ -720,8 +717,7 @@ impl CpuManager {
|
|||||||
proximity_domain_per_cpu,
|
proximity_domain_per_cpu,
|
||||||
affinity,
|
affinity,
|
||||||
dynamic,
|
dynamic,
|
||||||
#[cfg(target_arch = "x86_64")]
|
hypervisor: hypervisor.clone(),
|
||||||
cpu_vendor,
|
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,7 +759,7 @@ impl CpuManager {
|
|||||||
&self.vm,
|
&self.vm,
|
||||||
Some(self.vm_ops.clone()),
|
Some(self.vm_ops.clone()),
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
self.cpu_vendor,
|
self.hypervisor.get_cpu_vendor(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if let Some(snapshot) = snapshot {
|
if let Some(snapshot) = snapshot {
|
||||||
@ -803,7 +799,7 @@ impl CpuManager {
|
|||||||
let topology = self.config.topology.clone().map_or_else(
|
let topology = self.config.topology.clone().map_or_else(
|
||||||
|| {
|
|| {
|
||||||
#[cfg(feature = "mshv")]
|
#[cfg(feature = "mshv")]
|
||||||
if matches!(self.hypervisor_type, HypervisorType::Mshv) {
|
if matches!(self.hypervisor.hypervisor_type(), HypervisorType::Mshv) {
|
||||||
return Some((1, self.boot_vcpus(), 1));
|
return Some((1, self.boot_vcpus(), 1));
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
@ -889,7 +885,7 @@ impl CpuManager {
|
|||||||
let reset_evt = self.reset_evt.try_clone().unwrap();
|
let reset_evt = self.reset_evt.try_clone().unwrap();
|
||||||
let exit_evt = self.exit_evt.try_clone().unwrap();
|
let exit_evt = self.exit_evt.try_clone().unwrap();
|
||||||
#[cfg(feature = "kvm")]
|
#[cfg(feature = "kvm")]
|
||||||
let hypervisor_type = self.hypervisor_type;
|
let hypervisor_type = self.hypervisor.hypervisor_type();
|
||||||
#[cfg(feature = "guest_debug")]
|
#[cfg(feature = "guest_debug")]
|
||||||
let vm_debug_evt = self.vm_debug_evt.try_clone().unwrap();
|
let vm_debug_evt = self.vm_debug_evt.try_clone().unwrap();
|
||||||
let panic_exit_evt = self.exit_evt.try_clone().unwrap();
|
let panic_exit_evt = self.exit_evt.try_clone().unwrap();
|
||||||
@ -917,9 +913,12 @@ impl CpuManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve seccomp filter for vcpu thread
|
// Retrieve seccomp filter for vcpu thread
|
||||||
let vcpu_seccomp_filter =
|
let vcpu_seccomp_filter = get_seccomp_filter(
|
||||||
get_seccomp_filter(&self.seccomp_action, Thread::Vcpu, self.hypervisor_type)
|
&self.seccomp_action,
|
||||||
.map_err(Error::CreateSeccompFilter)?;
|
Thread::Vcpu,
|
||||||
|
self.hypervisor.hypervisor_type(),
|
||||||
|
)
|
||||||
|
.map_err(Error::CreateSeccompFilter)?;
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
let interrupt_controller_clone = self.interrupt_controller.as_ref().cloned();
|
let interrupt_controller_clone = self.interrupt_controller.as_ref().cloned();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user