use std::time::Duration;
use isothrum_runner::HyperVRights;
use super::Unavailable;
use crate::context::Context;
use crate::exec;
pub(super) async fn needs_admin(cx: &Context) -> bool {
isothrum_runner::may_manage_hyperv(cx.runner.as_ref()).await == HyperVRights::Missing
}
const HYPERVISOR_PROBE: Duration = Duration::from_secs(20);
pub(super) const HYPERVISOR_PRESENT: &str = "(Get-CimInstance -ClassName Win32_ComputerSystem).HypervisorPresent";
pub(super) async fn hypervisor_stopped(cx: &Context) -> Option<Unavailable> {
let asked = exec::read_ok(
cx.runner.as_ref(),
HYPERVISOR_PROBE,
"powershell",
&["-NoProfile", "-NonInteractive", "-Command", HYPERVISOR_PRESENT],
)
.await;
(asked.as_deref().map(str::trim) == Ok("False")).then_some(Unavailable::HypervisorStopped)
}