android_packages_modules_Vi.../microdroid/payload
Alan Stokes 6472ccd6e5 Migrate to Rust 2021 edition
I only wanted this in one place, but thought we might as well do it
all in one go.

In a couple of places I added an explicit edition instead of using the
default (whatever that is).

See https://doc.rust-lang.org/edition-guide/rust-2021/index.html.

Test: find . -name "Android.bp" -type f|xargs grep edition | grep -v 2021
Test: atest ComposHostTestCases MicrodroidHostTestCases
Change-Id: I4de050078b303cc5614d230e0d36d5454d60a807
2022-08-31 14:40:53 +01:00
..
config Migrate to Rust 2021 edition 2022-08-31 14:40:53 +01:00
include/microdroid
metadata Migrate to Rust 2021 edition 2022-08-31 14:40:53 +01:00
Android.bp Clean up READMEs and remove unused target. 2021-08-16 12:19:16 +00:00
README.md Clean up READMEs and remove unused target. 2021-08-16 12:19:16 +00:00
metadata.cc
metadata.proto Pass isFactory bit from host to Microdroid via payload metadata 2022-01-27 01:17:25 +09:00
mk_payload.cc Use apex name for partition name 2022-04-27 22:32:19 +00:00

README.md

Microdroid Payload

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.

Payload disk is created by VirtualizationService Service when starting a VM.

Partitions

Payload disk has 1 + N(number of APEX/APK payloads) partitions.

The first partition is a "payload-metadata" partition which describes other partitions. And APEXes and an APK are following as separate partitions.

For now, the order of partitions are important.

  • partition 1: Metadata partition
  • partition 2 ~ n: APEX payloads
  • partition n+1, n+2: APK payload and its idsig

It's subject to change in the future, though.

Metadata partition

Metadata partition provides description of the other partitions and the location for VM payload configuration.

The partition is a protobuf message prefixed with the size of the message.

offset size description
0 4 Header. unsigned int32: body length(L) in big endian
4 L Body. A protobuf message. schema

Payload partitions

Each payload partition presents APEX or APK passed from the host.

The size of a payload partition must be a multiple of 4096 bytes.

mk_payload

mk_payload is a small utility to create a payload disk image. It is used by ARCVM.

$ cat payload_config.json
{
  "apexes": [
    {
      "name": "com.my.hello",
      "path": "hello.apex",
    }
  ],
  "apk": {
    "name": "com.my.world",
    "path": "/path/to/world.apk",
    "idsigPath": "/path/to/world.apk.idsig",
  }
}
$ m mk_payload
$ mk_payload payload_config.json payload.img
$ ls
payload.img
payload-footer.img
payload-header.img
payload-metadata.img
payload-filler-0.img
payload-filler-1.img
...