How to run VirtIO on AGL Reference Hardware

How to run VirtIO on AGL Reference Hardware

This guide explains how to run virtual AGL on bare-metal AGL (AGL-in-AGL) on AGL Reference Hardware board with help of QEMU.

For simplicity reasons, this guide configures only virtio-blk and virtio-rng.

To run two AGLs, flash storage (SD-Card or eMMC) with two partitions for different root file systems is needed.

NOTE: To be able to use eMMC, a method to partition and flash it is needed. For example, U-Boot can be used for that, but necessary configuration options shall be enabled in U-Boot for that.

  1. Partition SD-Card or eMMC to have two partitions, at least 1 GiB each. Actually, can be less but just rounded up to have nice number.

    1. For example, SD-Card can be partitioned using fdisk utility.

      Execute fdisk:

      Here <disk> should be SD-Card device file, for example /dev/sdb.

      CAUCTION: Using wrong SD-Card device file can result in data lost on your computer!

      Partition SD-Card:

    2. For example, eMMC can be partitioned from U-Boot command line using:

      NOTE: gpt command should be enable in U-Boot configuration.
      NOTE: partition 'misc' are needed to make fastboot happy when using it to flash eMMC.

  2. Download Koky Koi M2:

  3. Build AGL for virtio-aarch64 machine:

    Flash root file system to the second partition on SD-Card or eMMC.

    1. Flashing SD-Card:

      Here FILE should be SD-Card second partition device file, for example /dev/sdb2.

      CAUCTION: Using wrong SD-Card partition device file can result in data lost on your computer!

    2. Flashing eMMC via fastboot

      NOTE: U-Boot should have fastboot running.

  4. Build AGL for AGL Reference Hardware.

    NOTE: To build AGL for AGL Reference Hardware and for virtio, the same folder could be reused. It takes a little bit more time when switching between AGL Reference Hardware build and virtio build but this overhead is not critical.

    Initialize build environment:


    In build/conf/local.conf add:

    CAUTION: Calling aglsetup.sh with "-f" flag will remove above modification in "local.conf", so they will be needed to be re-applied.

    Build AGL for AGL Reference Hardware:

    Add Linux 2 kernel to the Linux 1 rootfs:

    Flash root file system to the first partition on SD-Card or eMMC.

    1. Flashing SD-Card:

      Here FILE should be SD-Card second partition device file, for example /dev/sdb1.

      CAUCTION: Using wrong SD-Card partition device file can result in data lost on your computer!

    2. Flashing eMMC via fastboot:

      NOTE: U-Boot should have fastboot running.

  5. Boot AGL Reference Hardware board using Linux located on the first partition of SD-Card or eMMC

  6. Run QEMU from Linux 1 command line

    NOTE: mmcblk0p2 above is used for when root file system is flashed on eMMC. In case of SD-Card, mmcblk1p2 has to be used.

  7. It is possible to exit from QEMU using monitor commands. Enter "Ctrl+a h" for help.

KVM

NOTE: QEMU is a bit slow because KVM is not working. Adding "-enable-kvm" to QEMU command fails with

qemu-system-aarch64: kvm_init_vcpu failed: Invalid argument

Somewhere in the Internet suggested:

  • To use "-cpu host" but it did not help.

  • To use taskset to set to specific CPU core. Not tried since requires busybox reconfiguration to enable taskset.

  • Update QEMU and/or KVM to latest version. There was some kvm_init_vcpu signature changes.