run Android under crosvm on ChromiumOS

291 views
Skip to first unread message

Igor Igor

unread,
Mar 24, 2024, 5:06:02 PMMar 24
to crosvm-dev
 Hi Everyone,
 
 As far as I understand there is possibility run Android under crosvm on ChromiumOS. I checked openwrt under crosvm on ChromiumOS works fine.
 Run Android 12 a pretty complicated has a lot of images vendor.img, system.img, product.img etc.
 I tried to run Android 12 following:
./crosvm run --no-smt --cpus 4 --mem 8642 --balloon-bias-mib 48 --no-smt --delay-rt --per-vm-core-scheduling \
> --initrd /test/out/cuttlefish_assembly/vendor_ramdisk00 \
> --rwdisk /test/out/target/product/vsoc_x86_64/system.img \
> --rwdisk /test/out/target/product/vsoc_x86_64/vendor.img \
> --rwdisk  /test/out/target/product/vsoc_x86_64/product.img \
> --socket=/tmp/vcrosvm.sock \
> --pstore=path=/test/out/cuttlefish_runtime.1/pstore,size=2097152 \
> --disable-sandbox --cid=3 \
> --serial=hardware=virtio-console,num=1,type=sink \
> --serial=hardware=virtio-console,num=2,type=sink \
> --serial=hardware=virtio-console,num=3,type=sink \
> --serial=hardware=virtio-console,num=4,type=sink \
> --serial=hardware=virtio-console,num=5,type=sink \
> --serial=hardware=virtio-console,num=6,type=sink \
> -p "androidboot.serialno=CUTTLEFISHCVD011 root=/dev/vda init=/init androidboot.hardware=bertha androidboot.container=1 androidboot.host_is_in_vm=1 androidboot.dev_mode=1 ramoops.record_size=262144 ramoops.console_size=262144 ramoops.ftrace_size=4096 ramoops.pmsg_size=4096 ramoops.dump_oops=1 squashfs.cached_blks=20 androidboot.fstab_suffix=f2fs" \
> /test/out/target/product/vsoc_x86_64/kernel

And faced with issue, full log attached, snippet below:
...
[    0.991713] virtio_blk virtio6: [vda] 1932744 512-byte logical blocks (990 MB/944 MiB)
[    0.992951] vda: detected capacity change from 0 to 989564928
[    0.999361] virtio_blk virtio7: [vdb] 636304 512-byte logical blocks (326 MB/311 MiB)
[    0.999952] vdb: detected capacity change from 0 to 325787648
[    1.006905] virtio_blk virtio8: [vdc] 595568 512-byte logical blocks (305 MB/291 MiB)
[    1.008122] vdc: detected capacity change from 0 to 304930816
...
[    1.046247] printk: init: 108 output lines suppressed due to ratelimiting
[    1.066298] init: [libfs_mgr]Error updating for slotselect
[    1.066777] init: [libfs_mgr]ReadFstabFromFile(): failed to load fstab from : '/etc/recovery.fstab'
[    1.068094] init: [libfs_mgr]ReadDefaultFstab(): failed to find device default fstab
[    1.069329] init: Could not read default fstab
[    1.070102] init: Could not find mount entry for /system

It seems /system mount point is placed on vda virtio_blk so the fstab should be specified to crosvm via --android-fstab <path to Android fstab> option something like was done for old Android version https://android.googlesource.com/device/google/cuttlefish/+/bf9f2563bdddbf2fac3bed98120bcf6d8a578409/shared/config/gsi.fstab

1. Could you please confirm run Android 12 under crosvm on ChromiumOS is supported?
2. What is the format of the Android fstab file is required for --android-fstab option? If issue not here correct me please

Thanks,
Igor
crosvm_run_Android12.log

Ron Tuo

unread,
Apr 5, 2024, 10:38:13 AMApr 5
to crosvm-dev, Igor Igor
I have tried it.You should use BlissOS-14/15 to run instead of AOSP.The guide is:https://xtr126.github.io/XtMapper-docs/blissos/running_in_crosvm/

But it has some problems:1.Doesn't support Virtio-sound on Linux. 2.The camera built-in your PC may cannot use
3.I cannot turn off the Swiftshader rendering on Vulkan

Frederick Mayle

unread,
Apr 5, 2024, 2:08:41 PMApr 5
to Ron Tuo, crosvm-dev, Igor Igor
It seems /system mount point is placed on vda virtio_blk so the fstab should be specified to crosvm via --android-fstab <path to Android fstab> option something like was done for old Android version https://android.googlesource.com/device/google/cuttlefish/+/bf9f2563bdddbf2fac3bed98120bcf6d8a578409/shared/config/gsi.fstab

1. Could you please confirm run Android 12 under crosvm on ChromiumOS is supported?
2. What is the format of the Android fstab file is required for --android-fstab option? If issue not here correct me please

I think you are trying to run the cuttlefish device images. Cuttlefish uses crosvm to launch these images by default, so it is definitely possible. There is likely a lot of coupling with their host side code though. Here is the main source file that builds the crosvm cmdline invocation: https://cs.android.com/android/platform/superproject/main/+/main:device/google/cuttlefish/host/libs/vm_manager/crosvm_manager.cpp;drc=44e44b0e73cd2049649fc3f2ba89c2a6babf3392

They don't use --android-fstab. For the block devices, I'd bet the key difference is that, instead of providing each ".img" file as a separate device, they are providing a single "composite disk". This might be the right code https://cs.android.com/android/platform/superproject/main/+/main:device/google/cuttlefish/host/commands/assemble_cvd/disk/initialize_instance_composite_disk.cc;l=97-112;drc=4babe8e40035dd30d2dd50411470d9c8dae3959f

There are also going to be other hurdles, for example, the cuttlefish android device expects a lot of virtio-console devices to be present. In the guest, there are HAL processes that use those consoles to communicate with host processes that emulate hardware functionality, like bluetooth.

If you just want to run android in a VM, you might want to consider using cuttlefish in the supported way: https://source.android.com/docs/devices/cuttlefish/get-started

--
You received this message because you are subscribed to the Google Groups "crosvm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to crosvm-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/crosvm-dev/63bd62e4-371a-43f1-8025-c6951b826763n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages