blob: d6f65bd9bc130ecda895c4447ca61bafc878301b [file] [log] [blame]
Jooyung Han634e2d72021-06-10 16:27:38 +09001// Copyright 2021, The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! VM Payload Config
16
17use serde::{Deserialize, Serialize};
18
19/// VM payload config
Inseob Kim89b24592024-02-23 18:59:43 +090020#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
Jooyung Han634e2d72021-06-10 16:27:38 +090021pub struct VmPayloadConfig {
Inseob Kim89b24592024-02-23 18:59:43 +090022 /// OS config.
23 /// Deprecated: don't use. Error if not "" or "microdroid".
Jooyung Han634e2d72021-06-10 16:27:38 +090024 #[serde(default)]
Inseob Kim89b24592024-02-23 18:59:43 +090025 #[deprecated]
Jooyung Han634e2d72021-06-10 16:27:38 +090026 pub os: OsConfig,
27
28 /// Task to run in a VM
29 #[serde(default)]
30 pub task: Option<Task>,
31
32 /// APEXes to activate in a VM
33 #[serde(default)]
34 pub apexes: Vec<ApexConfig>,
Jooyung Han5dc42172021-10-05 16:43:47 +090035
Inseob Kima5a262f2021-11-17 19:41:03 +090036 /// Extra APKs to be passed to a VM
37 #[serde(default)]
38 pub extra_apks: Vec<ApkConfig>,
39
Jooyung Han5dc42172021-10-05 16:43:47 +090040 /// Tells VirtualizationService to use staged APEXes if possible
41 #[serde(default)]
42 pub prefer_staged: bool,
Shikha Panwar6f03c942022-04-13 20:26:50 +000043
44 /// Whether to export the tomsbtones (VM crashes) out of VM to host
Inseob Kimab1037d2023-02-08 17:03:31 +090045 /// Default: true for debuggable VMs, false for non-debuggable VMs
46 pub export_tombstones: Option<bool>,
Alan Stokes01b3ef02022-09-22 17:43:24 +010047
48 /// Whether the authfs service should be started in the VM. This enables read or write of host
49 /// files with integrity checking, but not confidentiality.
50 #[serde(default)]
51 pub enable_authfs: bool,
Jooyung Han634e2d72021-06-10 16:27:38 +090052}
53
54/// OS config
55#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
56pub struct OsConfig {
57 /// The name of OS to use
58 pub name: String,
59}
60
61impl Default for OsConfig {
62 fn default() -> Self {
Inseob Kim89b24592024-02-23 18:59:43 +090063 Self { name: "".to_owned() }
Jooyung Han634e2d72021-06-10 16:27:38 +090064 }
65}
66
67/// Payload's task can be one of plain executable
68/// or an .so library which can be started via /system/bin/microdroid_launcher
Charisee668224f2023-03-03 02:02:34 +000069#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, Default)]
Jooyung Han634e2d72021-06-10 16:27:38 +090070pub enum TaskType {
71 /// Task's command indicates the path to the executable binary.
72 #[serde(rename = "executable")]
Charisee668224f2023-03-03 02:02:34 +000073 #[default]
Jooyung Han634e2d72021-06-10 16:27:38 +090074 Executable,
75 /// Task's command indicates the .so library in /mnt/apk/lib/{arch}
76 #[serde(rename = "microdroid_launcher")]
77 MicrodroidLauncher,
78}
79
80/// Task to run in a VM
81#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
82pub struct Task {
83 /// Decides how to execute the command: executable(default) | microdroid_launcher
84 #[serde(default, rename = "type")]
85 pub type_: TaskType,
86
87 /// Command to run
88 /// - For executable task, this is the path to the executable.
89 /// - For microdroid_launcher task, this is the name of .so
90 pub command: String,
Jooyung Han634e2d72021-06-10 16:27:38 +090091}
92
Jooyung Han634e2d72021-06-10 16:27:38 +090093/// APEX config
94/// For now, we only pass the name of APEX.
95#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
96pub struct ApexConfig {
97 /// The name of APEX
98 pub name: String,
99}
Inseob Kima5a262f2021-11-17 19:41:03 +0900100
101/// APK config
102#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
103pub struct ApkConfig {
104 /// The path of APK
105 pub path: String,
106}