2021-05-13 14:23:23 +00:00
|
|
|
# Microdroid Payload
|
2021-04-14 06:34:24 +00:00
|
|
|
|
2021-06-08 08:10:21 +00:00
|
|
|
Payload disk is a composite disk image referencing host APEXes and an APK so that microdroid
|
|
|
|
mounts/activates APK/APEXes and executes a binary within the APK.
|
2021-04-14 06:34:24 +00:00
|
|
|
|
2021-08-05 02:25:23 +00:00
|
|
|
Payload disk is created by [VirtualizationService](../../virtualizationservice) Service when
|
|
|
|
starting a VM.
|
|
|
|
|
2021-06-08 08:10:21 +00:00
|
|
|
## Partitions
|
2021-04-14 06:34:24 +00:00
|
|
|
|
2021-05-13 14:23:23 +00:00
|
|
|
Payload disk has 1 + N(number of APEX/APK payloads) partitions.
|
|
|
|
|
2021-07-06 11:48:38 +00:00
|
|
|
The first partition is a "payload-metadata" partition which describes other partitions.
|
2021-05-13 14:23:23 +00:00
|
|
|
And APEXes and an APK are following as separate partitions.
|
|
|
|
|
|
|
|
For now, the order of partitions are important.
|
|
|
|
|
2021-06-08 08:10:21 +00:00
|
|
|
* partition 1: Metadata partition
|
2021-05-13 14:23:23 +00:00
|
|
|
* partition 2 ~ n: APEX payloads
|
2021-08-05 02:25:23 +00:00
|
|
|
* partition n+1, n+2: APK payload and its idsig
|
2021-05-13 14:23:23 +00:00
|
|
|
|
|
|
|
It's subject to change in the future, though.
|
|
|
|
|
2021-06-08 08:10:21 +00:00
|
|
|
### Metadata partition
|
2021-05-13 14:23:23 +00:00
|
|
|
|
2021-06-08 08:10:21 +00:00
|
|
|
Metadata partition provides description of the other partitions and the location for VM payload
|
|
|
|
configuration.
|
2021-05-13 14:23:23 +00:00
|
|
|
|
2021-06-08 08:10:21 +00:00
|
|
|
The partition is a protobuf message prefixed with the size of the message.
|
2021-04-14 06:34:24 +00:00
|
|
|
|
2021-08-16 12:16:50 +00:00
|
|
|
| offset | size | description |
|
|
|
|
| ------ | ---- | ---------------------------------------------------- |
|
|
|
|
| 0 | 4 | Header. unsigned int32: body length(L) in big endian |
|
|
|
|
| 4 | L | Body. A protobuf message. [schema](metadata.proto) |
|
2021-04-14 09:46:14 +00:00
|
|
|
|
2021-06-08 08:10:21 +00:00
|
|
|
### Payload partitions
|
|
|
|
|
|
|
|
Each payload partition presents APEX or APK passed from the host.
|
2021-04-19 18:57:19 +00:00
|
|
|
|
2021-08-16 12:16:50 +00:00
|
|
|
The size of a payload partition must be a multiple of 4096 bytes.
|
2021-04-14 09:46:14 +00:00
|
|
|
|
2021-08-05 02:25:23 +00:00
|
|
|
# `mk_payload`
|
2021-04-14 09:46:14 +00:00
|
|
|
|
2021-08-16 12:16:50 +00:00
|
|
|
`mk_payload` is a small utility to create a payload disk image. It is used by ARCVM.
|
2021-05-21 12:41:13 +00:00
|
|
|
|
2021-04-19 18:57:19 +00:00
|
|
|
```
|
|
|
|
$ cat payload_config.json
|
|
|
|
{
|
|
|
|
"apexes": [
|
|
|
|
{
|
|
|
|
"name": "com.my.hello",
|
2021-08-05 02:25:23 +00:00
|
|
|
"path": "hello.apex",
|
2021-04-19 18:57:19 +00:00
|
|
|
}
|
2021-05-13 14:23:23 +00:00
|
|
|
],
|
|
|
|
"apk": {
|
|
|
|
"name": "com.my.world",
|
2021-08-05 02:25:23 +00:00
|
|
|
"path": "/path/to/world.apk",
|
|
|
|
"idsigPath": "/path/to/world.apk.idsig",
|
2021-05-13 14:23:23 +00:00
|
|
|
}
|
2021-04-19 18:57:19 +00:00
|
|
|
}
|
2021-08-05 02:25:23 +00:00
|
|
|
$ m mk_payload
|
|
|
|
$ mk_payload payload_config.json payload.img
|
|
|
|
$ ls
|
2021-05-13 14:23:23 +00:00
|
|
|
payload.img
|
2021-04-19 18:57:19 +00:00
|
|
|
payload-footer.img
|
|
|
|
payload-header.img
|
2021-06-08 08:10:21 +00:00
|
|
|
payload-metadata.img
|
2021-08-05 02:25:23 +00:00
|
|
|
payload-filler-0.img
|
|
|
|
payload-filler-1.img
|
2021-05-13 14:23:23 +00:00
|
|
|
...
|
2021-04-19 18:57:19 +00:00
|
|
|
```
|