mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-28 01:16:50 +00:00
arch: use cfg_if to clean up hypervisor *Arch types
Also use the arch definitions in the main crosvm crate to avoid duplicating the cfg checks. BUG=None TEST=tools/dev_container tools/presubmit Change-Id: Ia92b2840b0f6c8f0daa25f4b2b185ef7ef372860 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4477764 Reviewed-by: Dennis Kempin <denniskempin@google.com> Reviewed-by: Noah Gold <nkgold@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
63f50362ec
commit
1aff211998
8 changed files with 50 additions and 130 deletions
|
@ -40,12 +40,6 @@ use devices::BusError;
|
|||
use devices::BusResumeDevice;
|
||||
use devices::HotPlugBus;
|
||||
use devices::IrqChip;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use devices::IrqChipAArch64 as IrqChipArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use devices::IrqChipRiscv64 as IrqChipArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use devices::IrqChipX86_64 as IrqChipArch;
|
||||
use devices::IrqEventSource;
|
||||
use devices::PciAddress;
|
||||
use devices::PciBus;
|
||||
|
@ -62,42 +56,8 @@ use devices::SerialParameters;
|
|||
use devices::VirtioMmioDevice;
|
||||
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), feature = "gdb"))]
|
||||
use gdbstub::arch::Arch;
|
||||
#[cfg(all(target_arch = "aarch64", feature = "gdb"))]
|
||||
use gdbstub_arch::aarch64::AArch64 as GdbArch;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
||||
use gdbstub_arch::x86::X86_64_SSE as GdbArch;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::CpuConfigAArch64 as CpuConfigArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::CpuConfigRiscv64 as CpuConfigArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::CpuConfigX86_64 as CpuConfigArch;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::Hypervisor as HypervisorArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::Hypervisor as HypervisorArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::HypervisorX86_64 as HypervisorArch;
|
||||
use hypervisor::IoEventAddress;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VcpuAArch64 as VcpuArch;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VcpuInitAArch64 as VcpuInitArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::VcpuInitRiscv64 as VcpuInitArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VcpuInitX86_64 as VcpuInitArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::VcpuRiscv64 as VcpuArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VcpuX86_64 as VcpuArch;
|
||||
use hypervisor::Vm;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VmAArch64 as VmArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::VmRiscv64 as VmArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VmX86_64 as VmArch;
|
||||
#[cfg(windows)]
|
||||
use jail::FakeMinijailStub as Minijail;
|
||||
#[cfg(unix)]
|
||||
|
@ -126,6 +86,35 @@ use vm_memory::GuestMemory;
|
|||
use vm_memory::GuestMemoryError;
|
||||
use vm_memory::MemoryRegionOptions;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] {
|
||||
pub use devices::IrqChipAArch64 as IrqChipArch;
|
||||
#[cfg(feature = "gdb")]
|
||||
pub use gdbstub_arch::aarch64::AArch64 as GdbArch;
|
||||
pub use hypervisor::CpuConfigAArch64 as CpuConfigArch;
|
||||
pub use hypervisor::Hypervisor as HypervisorArch;
|
||||
pub use hypervisor::VcpuAArch64 as VcpuArch;
|
||||
pub use hypervisor::VcpuInitAArch64 as VcpuInitArch;
|
||||
pub use hypervisor::VmAArch64 as VmArch;
|
||||
} else if #[cfg(target_arch = "riscv64")] {
|
||||
pub use devices::IrqChipRiscv64 as IrqChipArch;
|
||||
pub use hypervisor::CpuConfigRiscv64 as CpuConfigArch;
|
||||
pub use hypervisor::Hypervisor as HypervisorArch;
|
||||
pub use hypervisor::VcpuInitRiscv64 as VcpuInitArch;
|
||||
pub use hypervisor::VcpuRiscv64 as VcpuArch;
|
||||
pub use hypervisor::VmRiscv64 as VmArch;
|
||||
} else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
|
||||
pub use devices::IrqChipX86_64 as IrqChipArch;
|
||||
#[cfg(feature = "gdb")]
|
||||
pub use gdbstub_arch::x86::X86_64_SSE as GdbArch;
|
||||
pub use hypervisor::CpuConfigX86_64 as CpuConfigArch;
|
||||
pub use hypervisor::HypervisorX86_64 as HypervisorArch;
|
||||
pub use hypervisor::VcpuInitX86_64 as VcpuInitArch;
|
||||
pub use hypervisor::VcpuX86_64 as VcpuArch;
|
||||
pub use hypervisor::VmX86_64 as VmArch;
|
||||
}
|
||||
}
|
||||
|
||||
pub enum VmImage {
|
||||
Kernel(File),
|
||||
Bios(File),
|
||||
|
|
|
@ -9,6 +9,8 @@ use std::time::Duration;
|
|||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use aarch64::AArch64 as CrosvmArch;
|
||||
use anyhow::Context;
|
||||
use arch::GdbArch;
|
||||
use arch::VcpuArch;
|
||||
use base::error;
|
||||
use base::info;
|
||||
use base::Tube;
|
||||
|
@ -36,14 +38,6 @@ use gdbstub::target::ext::breakpoints::HwBreakpointOps;
|
|||
use gdbstub::target::Target;
|
||||
use gdbstub::target::TargetError::NonFatal;
|
||||
use gdbstub::target::TargetResult;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use gdbstub_arch::aarch64::AArch64 as GdbArch;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use gdbstub_arch::x86::X86_64_SSE as GdbArch;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VcpuAArch64 as VcpuArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VcpuX86_64 as VcpuArch;
|
||||
use remain::sorted;
|
||||
use sync::Mutex;
|
||||
use thiserror::Error as ThisError;
|
||||
|
|
|
@ -45,10 +45,13 @@ use anyhow::anyhow;
|
|||
use anyhow::bail;
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use arch::IrqChipArch;
|
||||
use arch::LinuxArch;
|
||||
use arch::RunnableLinuxVm;
|
||||
use arch::VcpuAffinity;
|
||||
use arch::VcpuArch;
|
||||
use arch::VirtioDeviceStub;
|
||||
use arch::VmArch;
|
||||
use arch::VmComponents;
|
||||
use arch::VmImage;
|
||||
use base::ReadNotifier;
|
||||
|
@ -93,12 +96,6 @@ use devices::HostHotPlugKey;
|
|||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use devices::HotPlugBus;
|
||||
use devices::IommuDevType;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use devices::IrqChipAArch64 as IrqChipArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use devices::IrqChipRiscv64 as IrqChipArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use devices::IrqChipX86_64 as IrqChipArch;
|
||||
use devices::IrqEventIndex;
|
||||
use devices::IrqEventSource;
|
||||
use devices::KvmKernelIrqChip;
|
||||
|
@ -149,20 +146,8 @@ use hypervisor::CpuConfigX86_64;
|
|||
use hypervisor::Hypervisor;
|
||||
use hypervisor::HypervisorCap;
|
||||
use hypervisor::ProtectionType;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VcpuAArch64 as VcpuArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::VcpuRiscv64 as VcpuArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VcpuX86_64 as VcpuArch;
|
||||
use hypervisor::Vm;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VmAArch64 as VmArch;
|
||||
use hypervisor::VmCap;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::VmRiscv64 as VmArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VmX86_64 as VmArch;
|
||||
use jail::*;
|
||||
use libc;
|
||||
use minijail::Minijail;
|
||||
|
|
|
@ -21,48 +21,23 @@ use aarch64::AArch64 as Arch;
|
|||
use aarch64::MsrHandlers;
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use arch::CpuConfigArch;
|
||||
use arch::CpuSet;
|
||||
use arch::IrqChipArch;
|
||||
use arch::LinuxArch;
|
||||
use arch::MsrConfig;
|
||||
use arch::VcpuArch;
|
||||
use arch::VcpuInitArch;
|
||||
use arch::VmArch;
|
||||
use base::*;
|
||||
use devices::Bus;
|
||||
use devices::IrqChip;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use devices::IrqChipAArch64 as IrqChipArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use devices::IrqChipRiscv64 as IrqChipArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use devices::IrqChipX86_64 as IrqChipArch;
|
||||
use devices::VcpuRunState;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::CpuConfigAArch64 as CpuConfigArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::CpuConfigRiscv64 as CpuConfigArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::CpuConfigX86_64 as CpuConfigArch;
|
||||
use hypervisor::IoOperation;
|
||||
use hypervisor::IoParams;
|
||||
use hypervisor::Vcpu;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VcpuAArch64 as VcpuArch;
|
||||
use hypervisor::VcpuExit;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VcpuInitAArch64 as VcpuInitArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::VcpuInitRiscv64 as VcpuInitArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VcpuInitX86_64 as VcpuInitArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::VcpuRiscv64 as VcpuArch;
|
||||
use hypervisor::VcpuRunHandle;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VcpuX86_64 as VcpuArch;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VmAArch64 as VmArch;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use hypervisor::VmRiscv64 as VmArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VmX86_64 as VmArch;
|
||||
use libc::c_int;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use riscv64::MsrHandlers;
|
||||
|
|
|
@ -38,9 +38,13 @@ use anyhow::anyhow;
|
|||
use anyhow::bail;
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use arch::CpuConfigArch;
|
||||
use arch::IrqChipArch;
|
||||
use arch::LinuxArch;
|
||||
use arch::RunnableLinuxVm;
|
||||
use arch::VcpuArch;
|
||||
use arch::VirtioDeviceStub;
|
||||
use arch::VmArch;
|
||||
use arch::VmComponents;
|
||||
use arch::VmImage;
|
||||
use base::enable_high_res_timers;
|
||||
|
@ -105,10 +109,6 @@ use devices::BusDeviceObj;
|
|||
use devices::GvmIrqChip;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use devices::IrqChip;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use devices::IrqChipAArch64 as IrqChipArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use devices::IrqChipX86_64 as IrqChipArch;
|
||||
use devices::UserspaceIrqChip;
|
||||
use devices::VirtioPciDevice;
|
||||
#[cfg(feature = "whpx")]
|
||||
|
@ -141,24 +141,14 @@ use hypervisor::whpx::WhpxFeature;
|
|||
use hypervisor::whpx::WhpxVcpu;
|
||||
#[cfg(feature = "whpx")]
|
||||
use hypervisor::whpx::WhpxVm;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::CpuConfigX86_64;
|
||||
use hypervisor::Hypervisor;
|
||||
#[cfg(feature = "whpx")]
|
||||
use hypervisor::HypervisorCap;
|
||||
#[cfg(feature = "whpx")]
|
||||
use hypervisor::HypervisorX86_64;
|
||||
use hypervisor::ProtectionType;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VcpuAArch64 as VcpuArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VcpuX86_64 as VcpuArch;
|
||||
#[cfg(any(feature = "gvm", feature = "whpx"))]
|
||||
use hypervisor::Vm;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VmAArch64 as VmArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VmX86_64 as VmArch;
|
||||
use irq_wait::IrqWaitWorker;
|
||||
use jail::FakeMinijailStub as Minijail;
|
||||
#[cfg(not(feature = "crash-report"))]
|
||||
|
|
|
@ -7,7 +7,9 @@ use std::thread::JoinHandle;
|
|||
|
||||
use anyhow::Result;
|
||||
use arch::RunnableLinuxVm;
|
||||
use arch::VcpuArch;
|
||||
use arch::VirtioDeviceStub;
|
||||
use arch::VmArch;
|
||||
use base::AsRawDescriptor;
|
||||
use base::Event;
|
||||
use base::EventToken;
|
||||
|
@ -34,8 +36,6 @@ use devices::virtio::DisplayBackend;
|
|||
use devices::virtio::EventDevice;
|
||||
use devices::virtio::Gpu;
|
||||
use devices::virtio::GpuParameters;
|
||||
use hypervisor::VcpuX86_64 as VcpuArch;
|
||||
use hypervisor::VmX86_64 as VmArch;
|
||||
pub(crate) use metrics::log_descriptor;
|
||||
pub(crate) use metrics::MetricEventType;
|
||||
use sync::Mutex;
|
||||
|
|
|
@ -12,6 +12,7 @@ use std::thread::JoinHandle;
|
|||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
|
||||
use arch::IrqChipArch;
|
||||
use base::error;
|
||||
use base::info;
|
||||
use base::warn;
|
||||
|
@ -23,10 +24,6 @@ use base::Tube;
|
|||
use base::TubeError;
|
||||
use base::WaitContext;
|
||||
use base::MAXIMUM_WAIT_OBJECTS;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use devices::IrqChipAArch64 as IrqChipArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use devices::IrqChipX86_64 as IrqChipArch;
|
||||
use devices::IrqEdgeEvent;
|
||||
use devices::IrqEventIndex;
|
||||
use devices::IrqEventSource;
|
||||
|
|
|
@ -20,10 +20,14 @@ use std::time::Instant;
|
|||
use aarch64::AArch64 as Arch;
|
||||
use anyhow::anyhow;
|
||||
use anyhow::Result;
|
||||
use arch::CpuConfigArch;
|
||||
use arch::CpuSet;
|
||||
use arch::IrqChipArch;
|
||||
use arch::LinuxArch;
|
||||
use arch::RunnableLinuxVm;
|
||||
use arch::VcpuAffinity;
|
||||
use arch::VcpuArch;
|
||||
use arch::VmArch;
|
||||
use base::error;
|
||||
use base::info;
|
||||
use base::set_audio_thread_priorities;
|
||||
|
@ -48,12 +52,6 @@ use crosvm_cli::sys::windows::exit::ExitContext;
|
|||
use crosvm_cli::sys::windows::exit::ExitContextAnyhow;
|
||||
use devices::tsc::TscSyncMitigations;
|
||||
use devices::Bus;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use devices::IrqChip;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use devices::IrqChipAArch64 as IrqChipArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use devices::IrqChipX86_64 as IrqChipArch;
|
||||
use devices::VcpuRunState;
|
||||
use futures::pin_mut;
|
||||
#[cfg(feature = "whpx")]
|
||||
|
@ -64,17 +62,9 @@ use hypervisor::HypervisorCap;
|
|||
use hypervisor::IoEventAddress;
|
||||
use hypervisor::IoOperation;
|
||||
use hypervisor::IoParams;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VcpuAArch64 as VcpuArch;
|
||||
use hypervisor::VcpuExit;
|
||||
use hypervisor::VcpuInitX86_64;
|
||||
use hypervisor::VcpuRunHandle;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VcpuX86_64 as VcpuArch;
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
use hypervisor::VmAArch64 as VmArch;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use hypervisor::VmX86_64 as VmArch;
|
||||
use sync::Condvar;
|
||||
use sync::Mutex;
|
||||
use vm_control::VmRunMode;
|
||||
|
|
Loading…
Reference in a new issue