underhill_entry/
lib.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! The entry point for the underhill environment.
5
6#![forbid(unsafe_code)]
7#![cfg(target_os = "linux")]
8
9// Use mimalloc instead of the system malloc for performance.
10#[global_allocator]
11static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
12
13// OpenVMM-HCL only needs libcrypto from openssl, not libssl.
14#[cfg(target_os = "linux")]
15openssl_crypto_only::openssl_crypto_only!();
16
17/// Entry point into the underhill multi-binary, dispatching between various
18/// entrypoints based on argv0.
19pub fn underhill_main() -> anyhow::Result<()> {
20    let argv0 = std::path::PathBuf::from(std::env::args_os().next().unwrap());
21    match argv0.file_name().unwrap().to_str().unwrap() {
22        "underhill-init" => underhill_init::main(),
23        "underhill-crash" => underhill_crash::main(),
24        "underhill-dump" => underhill_dump::main(),
25        _ => underhill_core::main(),
26    }
27}