Include microdroid files to virt apex
All files to run microdroid is now included to the com.android.virt
APEX:
- super image
- boot images
- vbmeta images
- bootloader
- uboot_env image
- cdisk json config
Also the documentation README.md and microdroid host tests are updated
too.
Bug: 184803590
Test: follow instructions on README.md
Test: atest MicrodroidHostTestCases
Change-Id: I71f0e32ca774b351d9f49af2754f0a1c786c2400
diff --git a/apex/Android.bp b/apex/Android.bp
index 5357566..bc9e084 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -20,12 +20,26 @@
"authfs", // TODO(victorhsieh): move to microdroid once we can run the test in VM.
"crosvm",
],
+ filesystems: [
+ "microdroid_super",
+ "microdroid_boot-5.10",
+ "microdroid_vendor_boot-5.10",
+ "microdroid_vbmeta",
+ "microdroid_vbmeta_system",
+ ],
},
x86_64: {
binaries: [
"authfs", // TODO(victorhsieh): move to microdroid once we can run the test in VM.
"crosvm",
],
+ filesystems: [
+ "microdroid_super",
+ "microdroid_boot-5.10",
+ "microdroid_vendor_boot-5.10",
+ "microdroid_vbmeta",
+ "microdroid_vbmeta_system",
+ ],
},
},
binaries: [
@@ -34,8 +48,12 @@
"virtmanager",
"vm",
],
- filesystems: ["microdroid"],
- prebuilts: ["com.android.virt.init.rc"],
+ prebuilts: [
+ "com.android.virt.init.rc",
+ "microdroid_cdisk.json",
+ "microdroid_uboot_env",
+ "microdroid_bootloader",
+ ],
file_contexts: ":com.android.virt-file_contexts",
}
diff --git a/microdroid/README.md b/microdroid/README.md
index ffc8302..db9ed1a 100644
--- a/microdroid/README.md
+++ b/microdroid/README.md
@@ -10,49 +10,31 @@
You need a VIM3L board. Instructions for building Android for the target, and
flashing the image can be found [here](../docs/getting_started/yukawa.md).
-Then you build microdroid. Note that the instruction below is very likely to
-change in the future, because this is in active development. For example, the
-`microdroid_*` modules will eventually be included in the `com.android.virt`
-APEX, which is already in the `yukawa` (VIM3L) target.
+Then you install `com.android.virt` APEX. All files needed to run microdroid are
+included in the APEX, which is already in the `yukawa` (VIM3L) target. You can
+of course build and install the APEX manually.
```
$ source build/envsetup.sh
$ choosecombo 1 aosp_arm64 userdebug // actually, any arm64-based target is ok
-$ m microdroid_super
-$ m microdroid_boot-5.10
-$ m microdroid_vendor_boot-5.10
-$ m microdroid_bootloader
-$ m microdroid_uboot_env
-$ m microdroid_vbmeta
-$ m microdroid_vbmeta_system
-$ m microdroid_cdisk.json
-```
-
-## Installing
-
-Push the built files to the device. In addition to that, some other files have
-to be manually created, for now. In the future, you won't need these.
-
-```
-$ adb push $ANDROID_PRODUCT_OUT/system/etc/microdroid_bootloader /data/local/tmp/bootloader
-$ adb push $ANDROID_PRODUCT_OUT/system/etc/microdroid_super.img /data/local/tmp/super.img
-$ adb push $ANDROID_PRODUCT_OUT/system/etc/microdroid_boot-5.10.img /data/local/tmp/boot.img
-$ adb push $ANDROID_PRODUCT_OUT/system/etc/microdroid_vendor_boot-5.10.img /data/local/tmp/vendor_boot.img
-$ adb push $ANDROID_PRODUCT_OUT/system/etc/microdroid_vbmeta.img /data/local/tmp/vbmeta.img
-$ adb push $ANDROID_PRODUCT_OUT/system/etc/microdroid_vbmeta_system.img /data/local/tmp/vbmeta_system.img
-$ adb push $ANDROID_PRODUCT_OUT/system/etc/uboot_env.img /data/local/tmp
-$ adb push $ANDROID_PRODUCT_OUT/system/etc/microdroid_cdisk.json /data/local/tmp
-$ dd if=/dev/zero of=misc.img bs=4k count=256
-$ adb push misc.img /data/local/tmp/
+$ m com.android.virt
+$ adb install $ANDROID_PRODUCT_OUT/system/apex/com.android.virt.apex
+$ adb reboot
```
## Running
-Create the composite image using `assemble_cvd` and run it via `crosvm`. In the
-future, this shall be done via [`virtmanager`](../virtmanager/).
+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/).
```
-$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/mk_cdisk microdroid_cdisk.json os_composite.img'
+$ 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 '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/crosvm run --cid=5 --disable-sandbox --bios=bootloader --serial=type=stdout --disk=os_composite.img'
```
diff --git a/microdroid/microdroid_cdisk.json b/microdroid/microdroid_cdisk.json
index 2bf9fcf..88b7183 100644
--- a/microdroid/microdroid_cdisk.json
+++ b/microdroid/microdroid_cdisk.json
@@ -12,47 +12,47 @@
},
{
"label": "boot_a",
- "path": "boot.img",
+ "path": "microdroid_boot-5.10.img",
"read_only": true
},
{
"label": "boot_b",
- "path": "boot.img",
+ "path": "microdroid_boot-5.10.img",
"read_only": true
},
{
"label": "vendor_boot_a",
- "path": "vendor_boot.img",
+ "path": "microdroid_vendor_boot-5.10.img",
"read_only": true
},
{
"label": "vendor_boot_b",
- "path": "vendor_boot.img",
+ "path": "microdroid_vendor_boot-5.10.img",
"read_only": true
},
{
"label": "vbmeta_a",
- "path": "vbmeta.img",
+ "path": "microdroid_vbmeta.img",
"read_only": true
},
{
"label": "vbmeta_b",
- "path": "vbmeta.img",
+ "path": "microdroid_vbmeta.img",
"read_only": true
},
{
"label": "vbmeta_system_a",
- "path": "vbmeta_system.img",
+ "path": "microdroid_vbmeta_system.img",
"read_only": true
},
{
"label": "vbmeta_system_b",
- "path": "vbmeta_system.img",
+ "path": "microdroid_vbmeta_system.img",
"read_only": true
},
{
"label": "super",
- "path": "super.img",
+ "path": "microdroid_super.img",
"read_only": true
}
]
diff --git a/tests/hostside/Android.bp b/tests/hostside/Android.bp
index 37a9c5b..429b737 100644
--- a/tests/hostside/Android.bp
+++ b/tests/hostside/Android.bp
@@ -7,22 +7,4 @@
srcs: ["java/**/*.java"],
test_suites: ["device-tests"],
libs: ["tradefed"],
- data: [
- ":microdroid_cdisk.json",
- ":microdroid_super",
- ":microdroid_boot-5.10",
- ":microdroid_vendor_boot-5.10",
- ":microdroid_uboot_env",
- ":microdroid_bootloader",
- ":MicrodroidHostTestCase_misc",
- ":microdroid_vbmeta",
- ":microdroid_vbmeta_system",
- ],
-}
-
-genrule {
- name: "MicrodroidHostTestCase_misc",
- out: ["misc.img"],
- cmd: "dd if=/dev/zero of=$(out) bs=4k count=256",
- visibility: ["//visibility:private"],
}
diff --git a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
index 1f8cef5..4acdf4b 100644
--- a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
+++ b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
@@ -30,9 +30,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.io.File;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -45,17 +42,6 @@
private static final String MICRODROID_SERIAL = "localhost:" + TEST_VM_ADB_PORT;
private static final long MICRODROID_BOOT_TIMEOUT_MILLIS = 15000;
- private void pushFile(String localName, String remoteName) {
- try {
- File localFile = getTestInformation().getDependencyFile(localName, false);
- Path remotePath = Paths.get(TEST_ROOT, remoteName);
- getDevice().executeShellCommand("mkdir -p " + remotePath.getParent());
- getDevice().pushFile(localFile, remotePath.toString());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
private String executeCommand(String cmd) {
final long defaultCommandTimeoutMillis = 1000; // 1 sec
return executeCommand(defaultCommandTimeoutMillis, cmd);
@@ -69,21 +55,21 @@
@Test
public void testMicrodroidBoots() throws Exception {
// Prepare input files
- pushFile("microdroid_cdisk.json", "microdroid_cdisk.json");
- pushFile("microdroid_bootloader", "bootloader");
- pushFile("microdroid_super.img", "super.img");
- pushFile("microdroid_boot-5.10.img", "boot.img");
- pushFile("microdroid_vendor_boot-5.10.img", "vendor_boot.img");
- pushFile("uboot_env.img", "uboot_env.img");
- pushFile("misc.img", "misc.img");
- pushFile("microdroid_vbmeta.img", "vbmeta.img");
- pushFile("microdroid_vbmeta_system.img", "vbmeta_system.img");
+ String prepareImagesCmd =
+ String.format(
+ "mkdir -p %s; cd %s; "
+ + "cp %setc/microdroid_bootloader bootloader && "
+ + "cp %setc/fs/*.img . && "
+ + "cp %setc/uboot_env.img . && "
+ + "dd if=/dev/zero of=misc.img bs=4k count=256",
+ TEST_ROOT, TEST_ROOT, VIRT_APEX, VIRT_APEX, VIRT_APEX);
+ getDevice().executeShellCommand(prepareImagesCmd);
// Create os_composite.img
String makeOsCompositeCmd =
String.format(
- "cd %s; %sbin/mk_cdisk microdroid_cdisk.json os_composite.img",
- TEST_ROOT, VIRT_APEX);
+ "cd %s; %sbin/mk_cdisk %setc/microdroid_cdisk.json os_composite.img",
+ TEST_ROOT, VIRT_APEX, VIRT_APEX);
getDevice().executeShellCommand(makeOsCompositeCmd);
// Make sure that os_composite.img is created