openvmm_helpers/config.rs
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Helpers for constructing VM configurations.
5
6use openvmm_defs::config::LinuxDirectBootMode;
7use openvmm_defs::config::LoadMode;
8
9/// Whether this boot path exposes the host's ACPI power button to the guest.
10///
11/// IGVM images supply their own firmware tables, and device-tree-only Linux
12/// boot has no ACPI button description. `None` carries no firmware information;
13/// snapshot restore must reconstruct the original device configuration.
14pub fn supports_acpi_power_button(load_mode: &LoadMode) -> bool {
15 match load_mode {
16 LoadMode::Linux { boot_mode, .. } => match boot_mode {
17 LinuxDirectBootMode::Acpi => true,
18 LinuxDirectBootMode::DeviceTree => false,
19 },
20 LoadMode::Uefi { .. } | LoadMode::Pcat { .. } => true,
21 LoadMode::Igvm { .. } | LoadMode::None => false,
22 }
23}