android_packages_modules_Vi.../microdroid/payload
Jooyung Han 2e7eefdb32 mk_payload is a host tool
Because virtualization service makes a microdroid payload disk image,
we don't need mk_payload any longer. But having a host tool might be
helpful for other uses. For example, ARCVM can use this tool for its own
use.

example_config.json:
{
  "apexes": [
    { "name": "com.android.foo",
      "path": "path/to/com.android.foo.apex" },
    ...
}

Bug: 189242583
Test: mk_payload example_config.json payload.img
Change-Id: I8d04701ed27782ddebb28449ba75e089309ec4c8
2021-08-05 11:30:01 +09:00
..
config
include/microdroid
metadata
Android.bp mk_payload is a host tool 2021-08-05 11:30:01 +09:00
README.md mk_payload is a host tool 2021-08-05 11:30:01 +09:00
metadata.cc
metadata.proto
mk_payload.cc mk_payload is a host tool 2021-08-05 11:30:01 +09: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.

Note that each payload passed to the Guest is read by a block device. If a payload is not sized to a multiples of 4k, reading it would fail. To prevent that, "zero fillers" are added for those files. For example, if an APK is 8000 byte big, the APK partition would be padded with 192 bytes of zeros.

mk_payload

mk_payload is a small utility to create a payload disk image.

$ 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
...