Xen: maintenance Xen and QEMU repos for TRS

Introduction

We need to maintain the upstreaming patches for Xen and QEMU repositories for support virtio device modules (e.g. virtio GPU device mode), this page is to describe how to download the related source code and build TRS. It also gives commands for launching Android Cuttlefish images on Xen virtual machine.

Download TRS offical repository

We can refer the TRS documenation Developer setup to download TRS repository and Getting the host packages to install dependencies on the PC.

Checkout the maintenance branches

$ cd /path/to/trs-workspace/meta-ledge-secure $ git remote add trs-maintenance https://gitlab.com/Linaro/blueprints/automotive/xen-aosp/trs-fragments/meta-ledge-secure.git $ git fetch trs-maintenance $ git checkout trs-maintenance/xen_aosp_maintenance_20231211 $ cd /path/to/trs-workspace/meta-virtualization/ $ git remote add trs-maintenance https://gitlab.com/Linaro/blueprints/automotive/xen-aosp/trs-fragments/meta-virtualization.git $ git fetch trs-maintenance $ git checkout trs-maintenance/xen_aosp_maintenance_20231211 $ cd /path/to/trs-workspace/trs/ $ git remote add trs-maintenance https://gitlab.com/Linaro/blueprints/automotive/xen-aosp/trs-fragments/trs.git $ git fetch trs-maintenance $ git checkout trs-maintenance/xen_aosp_maintenance_20231211

Build TRS image for qemuarm64 target

TS_SUPPORTED_TARGETS=tsqemuarm64-secureboot make

Flash TRS images on AVA platform

We need to copy TRS wic image trs-image-trs-qemuarm64.wic on AVA with Ubuntu system, then we can execuate below shell script to flash TRS images onto a NVME block device with command ./flash_ewaol_image.sh /dev/nvmeXnY (you might need to change the nvme block device name nvmeXnY based on your local environment).

Below is the source code for flash_ewaol_image.sh. Note, the script executes commands e2fsck and resize2fs to enlarge the partition size, when you use older version’s binary for e2fsck and resize2fs, it will fail and report errors. In this case, you need to download e2fsprogs package (version 1.47.0 is verified) and build these two binaries.

#!/bin/bash DEV=$1 sudo parted ${DEV} print echo "Please confirm if the partition is right?" while : ; do read -n 1 k <&1 if [[ $k = y ]] ; then printf "\n" break else printf "\nExit\n" exit 0 fi done echo "Copy image to ${DEV}" sudo dd bs=4M if=./trs-image-trs-qemuarm64.wic of=$DEV status=progress && sync sudo growpart $DEV 2 sudo /home/leoy/Downloads/e2fsprogs-1.47.0/e2fsck/e2fsck -f "${DEV}p2" sudo /home/leoy/Downloads/e2fsprogs-1.47.0/resize/resize2fs "${DEV}p2" sudo parted ${DEV} print

Run Android image on Xen virtual machine

By following up the steps described in https://linaro.atlassian.net/wiki/spaces/AUT/pages/28961243137, we can get the Android Cuttlefish images, then we need to copy the U-boot binary and Cuttlefish images into Xen Dom0 (e.g. copy into the folder /home/cuttlefish/ (You need to replace the IP address in your local environment with TRS_IP_ADDRESS in below commands).

Hint: If Android Cuttlefish images are used from mounted partition or located under some other path,

then cuttlefish expects some image files under path /home/USERNAME/<path_to_cuttlefish>/cuttlefish/instances/cvd-1/ to be valid. The easiest way to do that is to create 3 symlinks to the right location:

Then we can use below Xen configuration file to launch Xen virtual machine with command xl -vvv create aaos_vm.cfg -c:

Once the system boot up, since we have added the option -c in the xl create command, we can directly access the virtual machine's console. Android prints out verbose logs and this is hard for us to interact with the virtual machine, we can mute the logs with the command:

Then we can check the virtual networking interface’s IP address:

Android Cuttlefish uses eth0 and eth1 for specific purpose for emulation WiFi and other networking devices, this is why we can see eth2 is used as normal networking interface and it acquires IP address via DHCP. We can connect eth2 with ADB on the host: