sandbox/profiles/sandbox_profiles.rs
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Sandbox policy definitions for OpenVMM worker hosts.
5
6use crate::Profile;
7
8/// Selects the sandbox policy for an OpenVMM worker host.
9#[derive(Copy, Clone)]
10pub enum SandboxRole {
11 /// Virtual machine worker host.
12 Vm,
13 /// TPM device worker host.
14 Tpm,
15}
16
17impl SandboxRole {
18 /// Returns the worker's role name.
19 pub fn name(self) -> &'static str {
20 match self {
21 Self::Vm => "vm",
22 Self::Tpm => "tpm",
23 }
24 }
25
26 /// Builds the worker's sandbox profile.
27 pub fn profile(self) -> Profile {
28 match self {
29 Self::Vm => super::vm_worker().build(),
30 Self::Tpm => super::tpm_worker().build(),
31 }
32 }
33}