Update documentation for running via Virt Manager vith vm tool.
Also moved to a subdirecory of /data/local/tmp, to keep things a litle
tidier.
Bug: 181869875
Test: ran the commands
Change-Id: I9962e5165294c41a02bcc3b72501165dd85b7abe
diff --git a/microdroid/README.md b/microdroid/README.md
index a33e0cb..91371b5 100644
--- a/microdroid/README.md
+++ b/microdroid/README.md
@@ -14,7 +14,7 @@
included in the APEX, which is already in the `yukawa` (VIM3L) target. You can
of course build and install the APEX manually.
-```
+```sh
$ source build/envsetup.sh
$ choosecombo 1 aosp_arm64 userdebug // actually, any arm64-based target is ok
$ m com.android.virt
@@ -24,41 +24,71 @@
## Running
+Create a config file, `microdroid.json`:
+
+```json
+{
+ "bootloader": "/data/local/tmp/microdroid/bootloader",
+ "disks": [
+ {
+ "image": "/data/local/tmp/microdroid/os_composite.img",
+ "writable": false
+ },
+ {
+ "image": "/data/local/tmp/microdroid/env_composite.img",
+ "writable": false
+ },
+ {
+ "image": "/data/local/tmp/microdroid/payload.img",
+ "writable": false
+ },
+ {
+ "image": "/data/local/tmp/microdroid/userdata_composite.qcow2",
+ "writable": true
+ }
+ ]
+}
+```
+
Copy the artifacts to the temp directory, create the composite image using
-`mk_cdisk`, and run it via `crosvm`. For now, some other files have to be
-manually created. In the future, you won't need these, and this shall be done
-via [`virtmanager`](../virtmanager/).
+`mk_cdisk`, copy the VM config file, and run it via `vm`. For now, some other
+files have to be manually created. In the future, you won't need these, and this
+shall be done via [`virtmanager`](../virtmanager/).
+```sh
+$ adb root
+$ adb shell 'mkdir /data/local/tmp/microdroid'
+$ adb shell 'cp /apex/com.android.virt/etc/microdroid_bootloader /data/local/tmp/microdroid/bootloader'
+$ adb shell 'cp /apex/com.android.virt/etc/fs/*.img /data/local/tmp/microdroid'
+$ adb shell 'cp /apex/com.android.virt/etc/uboot_env.img /data/local/tmp/microdroid'
+$ adb shell 'dd if=/dev/zero of=/data/local/tmp/microdroid/misc.img bs=4k count=256'
+$ adb shell 'dd if=/dev/zero of=/data/local/tmp/microdroid/userdata.img bs=1 count=0 seek=4G'
+$ adb shell 'mkfs.ext4 /data/local/tmp/microdroid/userdata.img'
+$ adb shell 'cd /data/local/tmp/microdroid; /apex/com.android.virt/bin/mk_cdisk /apex/com.android.virt/etc/microdroid_cdisk.json os_composite.img'
+$ adb shell 'cd /data/local/tmp/microdroid; /apex/com.android.virt/bin/mk_cdisk /apex/com.android.virt/etc/microdroid_cdisk_env.json env_composite.img'
+$ adb shell 'cd /data/local/tmp/microdroid; /apex/com.android.virt/bin/mk_cdisk /apex/com.android.virt/etc/microdroid_cdisk_userdata.json userdata_composite.img'
+$ adb shell '/apex/com.android.virt/bin/crosvm create_qcow2 --backing_file=/data/local/tmp/microdroid/userdata_composite.img /data/local/tmp/microdroid/userdata_composite.$ qcow2'
+$ adb shell 'cd /data/local/tmp/microdroid; /apex/com.android.virt/bin/mk_payload /apex/com.android.virt/etc/microdroid_payload.json payload.img'
+$ adb shell 'chmod go+r /data/local/tmp/microdroid/*-header.img /data/local/tmp/microdroid/*-footer.img'
+$ adb push microdroid.json /data/local/tmp/microdroid/microdroid.json
+$ adb shell "start virtmanager"
+$ adb shell "RUST_BACKTRACE=1 RUST_LOG=trace /apex/com.android.virt/bin/vm run /data/local/tmp/microdroid/microdroid.json"
```
-$ adb shell 'cp /apex/com.android.virt/etc/microdroid_bootloader /data/local/tmp/bootloader'
-$ adb shell 'cp /apex/com.android.virt/etc/fs/*.img /data/local/tmp'
-$ adb shell 'cp /apex/com.android.virt/etc/uboot_env.img /data/local/tmp'
-$ adb shell 'dd if=/dev/zero of=/data/local/tmp/misc.img bs=4k count=256'
-$ adb shell 'dd if=/dev/zero of=/data/local/tmp/userdata.img bs=1 count=0 seek=4G'
-$ adb shell 'mkfs.ext4 /data/local/tmp/userdata.img'
-$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/mk_cdisk /apex/com.android.virt/etc/microdroid_cdisk.json os_composite.img'
-$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/mk_cdisk /apex/com.android.virt/etc/microdroid_cdisk_env.json env_composite.img'
-$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/mk_cdisk /apex/com.android.virt/etc/microdroid_cdisk_userdata.json userdata_composite.img'
-$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/crosvm create_qcow2 --backing_file=userdata_composite.img userdata_composite.qcow2'
-$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/mk_payload /apex/com.android.virt/etc/microdroid_payload.json payload.img'
-$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/crosvm run --cid=5 --disable-sandbox --bios=bootloader --serial=type=stdout --disk=os_composite.img --disk=env_composite.img --disk=payload.img --rwdisk=userdata_composite.qcow2'
-```
-
-The CID in `--cid` parameter can be anything greater than 2 (`VMADDR_CID_HOST`).
## ADB
-```
-$ adb forward tcp:8000 vsock:5:5555
+```sh
+$ CID=10
+$ adb forward tcp:8000 vsock:$CID:5555
$ adb connect localhost:8000
```
-`5` in `vsock:5` should match with the CID number that was given to `crosvm`.
-`5555` must be the value. `8000` however can be any port in the development
-machine.
+`CID` should be the CID that `vm` reported was assigned to the VM. You can also
+check it with `adb shell "/apex/com.android.virt/bin/vm list"`. `5555` must be
+the value. `8000` however can be any port in the development machine.
Done. Now you can log into microdroid. Have fun!
-```
+```sh
$ adb -s localhost:8000 shell
```