2021-02-04 02:36:27 +00:00
|
|
|
package {
|
|
|
|
default_applicable_licenses: ["Android-Apache-2.0"],
|
|
|
|
}
|
|
|
|
|
2021-11-11 21:28:09 +00:00
|
|
|
microdroid_filesystem_images = [
|
|
|
|
"microdroid_super",
|
|
|
|
"microdroid_boot-5.10",
|
|
|
|
"microdroid_vendor_boot-5.10",
|
|
|
|
"microdroid_vbmeta",
|
|
|
|
"microdroid_vbmeta_bootconfig",
|
|
|
|
]
|
|
|
|
|
2020-12-07 06:58:23 +00:00
|
|
|
apex {
|
|
|
|
name: "com.android.virt",
|
|
|
|
|
|
|
|
// TODO(jiyong): make it updatable
|
2021-02-16 14:43:40 +00:00
|
|
|
updatable: false,
|
2021-11-29 02:29:16 +00:00
|
|
|
future_updatable: true,
|
2021-06-22 11:24:56 +00:00
|
|
|
platform_apis: true,
|
2020-12-07 06:58:23 +00:00
|
|
|
|
2021-11-19 14:11:30 +00:00
|
|
|
system_ext_specific: true,
|
|
|
|
|
2020-12-07 06:58:23 +00:00
|
|
|
manifest: "manifest.json",
|
|
|
|
|
|
|
|
key: "com.android.virt.key",
|
|
|
|
certificate: ":com.android.virt.certificate",
|
2021-10-26 16:50:51 +00:00
|
|
|
custom_sign_tool: "sign_virt_apex",
|
2020-12-07 06:58:23 +00:00
|
|
|
|
2021-06-10 13:59:56 +00:00
|
|
|
// crosvm and virtualizationservice are only enabled for 64-bit targets on device
|
2020-12-07 06:58:47 +00:00
|
|
|
arch: {
|
|
|
|
arm64: {
|
|
|
|
binaries: [
|
2021-01-05 14:14:46 +00:00
|
|
|
"crosvm",
|
2021-06-10 13:59:56 +00:00
|
|
|
"virtualizationservice",
|
2021-01-05 14:14:46 +00:00
|
|
|
],
|
2021-11-11 21:28:09 +00:00
|
|
|
filesystems: microdroid_filesystem_images,
|
2021-01-05 14:14:46 +00:00
|
|
|
},
|
|
|
|
x86_64: {
|
|
|
|
binaries: [
|
2020-12-07 06:58:47 +00:00
|
|
|
"crosvm",
|
2021-06-10 13:59:56 +00:00
|
|
|
"virtualizationservice",
|
2020-12-07 06:58:47 +00:00
|
|
|
],
|
2021-11-11 21:28:09 +00:00
|
|
|
filesystems: microdroid_filesystem_images,
|
2020-12-07 06:58:47 +00:00
|
|
|
},
|
|
|
|
},
|
2021-02-16 04:23:00 +00:00
|
|
|
binaries: [
|
2021-03-11 22:19:18 +00:00
|
|
|
"fd_server",
|
2021-03-04 16:11:12 +00:00
|
|
|
"vm",
|
2021-02-16 04:23:00 +00:00
|
|
|
],
|
2021-06-28 09:37:26 +00:00
|
|
|
java_libs: [
|
|
|
|
"android.system.virtualmachine",
|
|
|
|
],
|
2021-08-31 01:00:42 +00:00
|
|
|
jni_libs: [
|
|
|
|
"libvirtualmachine_jni",
|
|
|
|
],
|
2021-07-12 12:21:09 +00:00
|
|
|
apps: [
|
|
|
|
"android.system.virtualmachine.res",
|
|
|
|
],
|
2021-04-12 05:48:42 +00:00
|
|
|
prebuilts: [
|
|
|
|
"com.android.virt.init.rc",
|
2021-06-21 05:39:12 +00:00
|
|
|
"microdroid.json",
|
2021-04-12 05:48:42 +00:00
|
|
|
"microdroid_uboot_env",
|
|
|
|
"microdroid_bootloader",
|
2021-10-26 18:35:42 +00:00
|
|
|
"microdroid_bootloader.avbpubkey",
|
Define debug levels
Previously, a VM can be configured as running in debug mode or not.
However, the debug mode was not defined clearly and debugging features
like logging and adb-shell were actually left enabled even when the
debug mode is off.
This CL re-defines the debuggability of a VM. A VM has a debug level
which can be either of these three:
1. None: In this level, VM is not debuggable at all. No log is exported
from the VM, and debugger can't be attached to any process in the VM.
adb-shell of course is not supported.
2. App-only: In this level, only the app payload is debuggable. Logs
from the app process is exported to the host and the process can be
attached to debugger. adb-shell is not supported.
3. Full: In this level, the VM is fully debuggable. All logs including
kernel logs are exported to the VM and developers can adb-shell into the
VM.
Note that this CL doesn't fully implement all the levels yet, but
implements the framework around supporting multiple debug levels.
Specifically, each debug level is associated with a bootconfig image.
Each image has config values each of which enables or disables a
debugging feature. For example, bootconfig images for the none and
app-only levels have "kernel.console = none" to not show kernel console
output.
The `vm` tool and the Java APIs are also amended accordingly. The debug
level can be set via `--debug <level>` flag and the `DebugLevel(...)`
method.
Future work:
* Implement each debug level
* Each level uses different vm-instance image. Debug level is stored in
the instance image and is compared against the given level when
microdroid boots.
* Sign bootconfig images with avb and let uboot verify them
(b/203031847)
Bug: 201362865
Test: atest MicrodroidHostTestCases
Test: adb shell /apex/com.android.virt/bin/vm run-app
/data/local/tmp/virt/MicrodroidDemoApp.apk
/data/local/tmp/virt/MicrodroidDemoApp.apk.idsig
/data/local/tmp/virt/instance.img assets/vm_config.json
shows ...
Created VM from
"/data/local/tmp/virt/MicrodroidDemoApp.apk"!"assets/vm_config.json"
with CID 13, state is NOT_STARTED.
Started VM, state now STARTING.
Hello Microdroid /mnt/apk/lib/arm64-v8a/MicrodroidTestNativeLib.so hello
microdroid
, which is without logs from the bootloader and the kernel
Change-Id: I897dcd88723f014524d2cd2b6ffaa6f9fb5696d6
2021-10-14 15:02:12 +00:00
|
|
|
"microdroid_bootconfig_normal",
|
|
|
|
"microdroid_bootconfig_app_debuggable",
|
|
|
|
"microdroid_bootconfig_full_debuggable",
|
2021-04-12 05:48:42 +00:00
|
|
|
],
|
2021-03-25 21:18:53 +00:00
|
|
|
file_contexts: ":com.android.virt-file_contexts",
|
2021-12-15 16:47:54 +00:00
|
|
|
canned_fs_config: "canned_fs_config",
|
2020-12-07 06:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
apex_key {
|
|
|
|
name: "com.android.virt.key",
|
|
|
|
public_key: "com.android.virt.avbpubkey",
|
|
|
|
private_key: "com.android.virt.pem",
|
|
|
|
}
|
|
|
|
|
|
|
|
android_app_certificate {
|
|
|
|
name: "com.android.virt.certificate",
|
|
|
|
certificate: "com.android.virt",
|
|
|
|
}
|
2021-03-25 21:18:53 +00:00
|
|
|
|
|
|
|
prebuilt_etc {
|
|
|
|
name: "com.android.virt.init.rc",
|
2021-05-21 12:41:13 +00:00
|
|
|
src: "virtualizationservice.rc",
|
2021-03-25 21:18:53 +00:00
|
|
|
filename: "init.rc",
|
2021-09-08 10:51:06 +00:00
|
|
|
installable: false,
|
2021-03-25 21:18:53 +00:00
|
|
|
}
|
2021-10-26 06:54:50 +00:00
|
|
|
|
|
|
|
// Virt apex needs a custom signer for its payload
|
|
|
|
python_binary_host {
|
|
|
|
name: "sign_virt_apex",
|
|
|
|
srcs: [
|
|
|
|
"sign_virt_apex.py",
|
|
|
|
],
|
|
|
|
version: {
|
|
|
|
py2: {
|
|
|
|
enabled: false,
|
|
|
|
},
|
|
|
|
py3: {
|
|
|
|
enabled: true,
|
|
|
|
embedded_launcher: true,
|
|
|
|
},
|
|
|
|
},
|
2021-10-26 16:50:51 +00:00
|
|
|
required: [
|
|
|
|
"img2simg",
|
|
|
|
"lpmake",
|
|
|
|
"lpunpack",
|
|
|
|
"simg2img",
|
|
|
|
],
|
2021-10-26 06:54:50 +00:00
|
|
|
}
|
2021-11-08 08:53:47 +00:00
|
|
|
|
2021-11-08 08:50:22 +00:00
|
|
|
sh_test_host {
|
|
|
|
name: "sign_virt_apex_test",
|
|
|
|
src: "sign_virt_apex_test.sh",
|
|
|
|
test_config: "sign_virt_apex_test.xml",
|
|
|
|
data_bins: [
|
|
|
|
// deapexer
|
|
|
|
"deapexer",
|
|
|
|
"debugfs_static",
|
|
|
|
|
|
|
|
// sign_virt_apex
|
|
|
|
"avbtool",
|
|
|
|
"img2simg",
|
|
|
|
"lpmake",
|
|
|
|
"lpunpack",
|
|
|
|
"sign_virt_apex",
|
|
|
|
"simg2img",
|
|
|
|
],
|
|
|
|
data_libs: [
|
|
|
|
"libbase",
|
|
|
|
"libc++",
|
|
|
|
"libcrypto_utils",
|
|
|
|
"libcrypto",
|
|
|
|
"libext4_utils",
|
|
|
|
"liblog",
|
|
|
|
"liblp",
|
|
|
|
"libsparse",
|
|
|
|
"libz",
|
|
|
|
],
|
|
|
|
data: [
|
|
|
|
":com.android.virt",
|
|
|
|
"test.com.android.virt.pem",
|
|
|
|
],
|
|
|
|
test_suites: ["general-tests"],
|
|
|
|
}
|
|
|
|
|
2021-11-08 08:53:47 +00:00
|
|
|
// custom tool to replace bytes in a file
|
|
|
|
python_binary_host {
|
|
|
|
name: "replace_bytes",
|
|
|
|
srcs: [
|
|
|
|
"replace_bytes.py",
|
|
|
|
],
|
|
|
|
version: {
|
|
|
|
py2: {
|
|
|
|
enabled: false,
|
|
|
|
},
|
|
|
|
py3: {
|
|
|
|
enabled: true,
|
|
|
|
embedded_launcher: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|