mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-09 20:04:20 +00:00
windows: fix build without --features=stats
Add a top-level stats feature that selects devices/stats and guard the uses of stats-related types with a cfg check. Fixes the Windows build when the stats feature is not enabled. No change in behavior when building with the win64 feature, as that selected the stats feature already. BUG=None TEST=cargo build --no-default-features Change-Id: I468f6c34509753d640ea002199da74e1729d25f7 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3885496 Reviewed-by: Noah Gold <nkgold@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
8f13ec7af4
commit
bd13bdbfc8
4 changed files with 27 additions and 8 deletions
|
@ -118,7 +118,7 @@ all-linux = [
|
|||
"virgl_renderer",
|
||||
"x",
|
||||
]
|
||||
win64 = ["devices/stats", "balloon", "haxm"]
|
||||
win64 = ["stats", "balloon", "haxm"]
|
||||
audio = ["devices/audio"]
|
||||
audio_cras = ["devices/audio_cras"]
|
||||
balloon = ["devices/balloon", "vm_control/balloon"]
|
||||
|
@ -149,6 +149,7 @@ plugin-render-server = []
|
|||
power-monitor-powerd = ["arch/power-monitor-powerd"]
|
||||
qcow = ["disk/qcow"]
|
||||
slirp = ["devices/slirp"]
|
||||
stats = ["devices/stats"]
|
||||
tpm = ["devices/tpm"]
|
||||
usb = ["devices/usb"]
|
||||
video-decoder = ["devices/video-decoder"]
|
||||
|
|
|
@ -7,4 +7,5 @@ pub mod config;
|
|||
|
||||
pub(crate) mod broker;
|
||||
pub(crate) mod exit;
|
||||
#[cfg(feature = "stats")]
|
||||
pub(crate) mod stats;
|
||||
|
|
|
@ -210,6 +210,7 @@ use crate::crosvm::sys::config::IrqChipKind;
|
|||
use crate::crosvm::sys::windows::exit::Exit;
|
||||
use crate::crosvm::sys::windows::exit::ExitContext;
|
||||
use crate::crosvm::sys::windows::exit::ExitContextAnyhow;
|
||||
#[cfg(feature = "stats")]
|
||||
use crate::crosvm::sys::windows::stats::StatisticsCollector;
|
||||
use crate::sys::windows::metrics::log_descriptor;
|
||||
use crate::sys::windows::metrics::MetricEventType;
|
||||
|
@ -759,7 +760,7 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
pvclock_host_tube: Option<Tube>,
|
||||
map_request: Arc<Mutex<Option<ExternalMapping>>>,
|
||||
mut gralloc: RutabagaGralloc,
|
||||
stats: Option<Arc<Mutex<StatisticsCollector>>>,
|
||||
#[cfg(feature = "stats")] stats: Option<Arc<Mutex<StatisticsCollector>>>,
|
||||
#[cfg(feature = "kiwi")] service_pipe_name: Option<String>,
|
||||
ac97_host_tubes: Vec<Tube>,
|
||||
memory_size_mb: u64,
|
||||
|
@ -932,6 +933,7 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
&exit_evt,
|
||||
&vm_evt_wrtube,
|
||||
&pvclock_host_tube,
|
||||
#[cfg(feature = "stats")]
|
||||
&stats,
|
||||
host_cpu_topology,
|
||||
run_mode_arc.clone(),
|
||||
|
@ -1353,6 +1355,7 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
|
||||
let _ = irq_join_handle.join();
|
||||
|
||||
#[cfg(feature = "stats")]
|
||||
if let Some(stats) = stats {
|
||||
println!("Statistics Collected:\n{}", stats.lock());
|
||||
println!("Statistics JSON:\n{}", stats.lock().json());
|
||||
|
@ -2126,6 +2129,7 @@ where
|
|||
|
||||
let _render_node_host = ();
|
||||
|
||||
#[cfg(feature = "stats")]
|
||||
let stats = if cfg.exit_stats {
|
||||
Some(Arc::new(Mutex::new(StatisticsCollector::new())))
|
||||
} else {
|
||||
|
@ -2144,6 +2148,7 @@ where
|
|||
pvclock_host_tube,
|
||||
Arc::clone(&map_request),
|
||||
gralloc,
|
||||
#[cfg(feature = "stats")]
|
||||
stats,
|
||||
#[cfg(feature = "kiwi")]
|
||||
cfg.service_pipe_name,
|
||||
|
|
|
@ -85,7 +85,9 @@ use crate::bail_exit_code;
|
|||
use crate::crosvm::sys::windows::exit::Exit;
|
||||
use crate::crosvm::sys::windows::exit::ExitContext;
|
||||
use crate::crosvm::sys::windows::exit::ExitContextAnyhow;
|
||||
#[cfg(feature = "stats")]
|
||||
use crate::crosvm::sys::windows::stats::StatisticsCollector;
|
||||
#[cfg(feature = "stats")]
|
||||
use crate::crosvm::sys::windows::stats::VmExitStatistics;
|
||||
use crate::sys::windows::save_vcpu_tsc_offset;
|
||||
use crate::sys::windows::ExitState;
|
||||
|
@ -275,7 +277,7 @@ impl VcpuRunThread {
|
|||
vm_evt_wrtube: SendTube,
|
||||
requires_pvclock_ctrl: bool,
|
||||
run_mode_arc: Arc<VcpuRunMode>,
|
||||
stats: Option<Arc<Mutex<StatisticsCollector>>>,
|
||||
#[cfg(feature = "stats")] stats: Option<Arc<Mutex<StatisticsCollector>>>,
|
||||
host_cpu_topology: bool,
|
||||
tsc_offset: Option<u64>,
|
||||
force_calibrated_tsc_leaf: bool,
|
||||
|
@ -368,6 +370,7 @@ impl VcpuRunThread {
|
|||
mmio_bus,
|
||||
requires_pvclock_ctrl,
|
||||
run_mode_arc,
|
||||
#[cfg(feature = "stats")]
|
||||
stats,
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
cpuid_context,
|
||||
|
@ -559,7 +562,7 @@ pub fn run_all_vcpus<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
exit_evt: &Event,
|
||||
vm_evt_wrtube: &SendTube,
|
||||
pvclock_host_tube: &Option<Tube>,
|
||||
stats: &Option<Arc<Mutex<StatisticsCollector>>>,
|
||||
#[cfg(feature = "stats")] stats: &Option<Arc<Mutex<StatisticsCollector>>>,
|
||||
host_cpu_topology: bool,
|
||||
run_mode_arc: Arc<VcpuRunMode>,
|
||||
tsc_sync_mitigations: TscSyncMitigations,
|
||||
|
@ -636,6 +639,7 @@ pub fn run_all_vcpus<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
.exit_context(Exit::CloneTube, "failed to clone tube")?,
|
||||
pvclock_host_tube.is_none(),
|
||||
run_mode_arc.clone(),
|
||||
#[cfg(feature = "stats")]
|
||||
stats.clone(),
|
||||
host_cpu_topology,
|
||||
tsc_offset,
|
||||
|
@ -668,16 +672,21 @@ fn vcpu_loop<V>(
|
|||
mmio_bus: Bus,
|
||||
requires_pvclock_ctrl: bool,
|
||||
run_mode_arc: Arc<VcpuRunMode>,
|
||||
stats: Option<Arc<Mutex<StatisticsCollector>>>,
|
||||
#[cfg(feature = "stats")] stats: Option<Arc<Mutex<StatisticsCollector>>>,
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] cpuid_context: CpuIdContext,
|
||||
) -> Result<ExitState>
|
||||
where
|
||||
V: VcpuArch + 'static,
|
||||
{
|
||||
#[cfg(feature = "stats")]
|
||||
let mut exit_stats = VmExitStatistics::new();
|
||||
mmio_bus.stats.lock().set_enabled(stats.is_some());
|
||||
io_bus.stats.lock().set_enabled(stats.is_some());
|
||||
exit_stats.set_enabled(stats.is_some());
|
||||
|
||||
#[cfg(feature = "stats")]
|
||||
{
|
||||
mmio_bus.stats.lock().set_enabled(stats.is_some());
|
||||
io_bus.stats.lock().set_enabled(stats.is_some());
|
||||
exit_stats.set_enabled(stats.is_some());
|
||||
}
|
||||
|
||||
let mut save_tsc_offset = true;
|
||||
|
||||
|
@ -732,6 +741,7 @@ where
|
|||
save_tsc_offset = false;
|
||||
}
|
||||
|
||||
#[cfg(feature = "stats")]
|
||||
let start = exit_stats.start_stat();
|
||||
|
||||
match exit {
|
||||
|
@ -893,6 +903,7 @@ where
|
|||
},
|
||||
}
|
||||
|
||||
#[cfg(feature = "stats")]
|
||||
exit_stats.end_stat(&exit, start);
|
||||
}
|
||||
|
||||
|
@ -916,6 +927,7 @@ where
|
|||
}
|
||||
VmRunMode::Breakpoint => {}
|
||||
VmRunMode::Exiting => {
|
||||
#[cfg(feature = "stats")]
|
||||
if let Some(stats) = stats {
|
||||
let mut collector = stats.lock();
|
||||
collector.pio_bus_stats.push(io_bus.stats);
|
||||
|
|
Loading…
Reference in a new issue