summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyutaroh Matsumoto <ryutaroh@ict.e.titech.ac.jp>2021-01-10 17:24:35 +0100
committerLars Wirzenius <liw@liw.fi>2021-01-11 07:46:55 +0000
commit4ae1792710bf1b7d85e3f009e38cb0a977d388f1 (patch)
treeacb9e23a5062e4611842b82e0320817e8411b788
parenteb43e509b5f92e255d470babab8cf9c0183f4d0c (diff)
downloadvmdb2-4ae1792710bf1b7d85e3f009e38cb0a977d388f1.tar.gz
feat: Add armhf (UEFI) support
-rw-r--r--armhf-uefi.vmdb62
-rwxr-xr-xcheck-all12
-rwxr-xr-xsmoke-armhf.sh8
-rw-r--r--smoke-armhf.yarn70
-rw-r--r--smoke-uefi-armhf.vmdb75
5 files changed, 227 insertions, 0 deletions
diff --git a/armhf-uefi.vmdb b/armhf-uefi.vmdb
new file mode 100644
index 0000000..0597b81
--- /dev/null
+++ b/armhf-uefi.vmdb
@@ -0,0 +1,62 @@
+# This is a sample VMDB2 input file that specifies a simple system for
+# an armhf machine that boots with UEFI.
+
+steps:
+ - mkimg: "{{ output }}"
+ size: 4G
+
+ - mklabel: gpt
+ device: "{{ output }}"
+
+ - mkpart: primary
+ device: "{{ output }}"
+ start: 0%
+ end: 1G
+ tag: efi
+
+ - mkpart: primary
+ device: "{{ output }}"
+ start: 1G
+ end: 100%
+ tag: /
+
+ - kpartx: "{{ output }}"
+
+ - mkfs: vfat
+ partition: efi
+
+ - mkfs: ext4
+ partition: /
+
+ - mount: /
+
+ # Using the virtual-filesystems plugin here upsets qemu-debootstrap,
+ # which ends up unable to create /dev/fd within the chroot, causing
+ # the qemu-debootstrap phase to fail. Until we get to the bottom
+ # that, don't enable the plugin.
+ #- virtual-filesystems: /
+
+ - unpack-rootfs: /
+
+ - qemu-debootstrap: buster
+ arch: armhf
+ mirror: http://deb.debian.org/debian
+ target: /
+ unless: rootfs_unpacked
+
+ - apt: install
+ packages:
+ - linux-image-armmp-lpae
+ fs-tag: /
+ unless: rootfs_unpacked
+
+ - cache-rootfs: /
+ unless: rootfs_unpacked
+
+ - chroot: /
+ shell: |
+ echo armhf-uefi-vmdb2 > /etc/hostname
+
+ - grub: uefi
+ tag: /
+ efi: efi
diff --git a/check-all b/check-all
index 6c38385..9a67f1c 100755
--- a/check-all
+++ b/check-all
@@ -8,6 +8,8 @@ i386_tarball="$1"
shift
arm64_tarball="$1"
shift
+armhf_tarball="$1"
+shift
tryit()
{
@@ -60,4 +62,14 @@ do
tryit "$dst/$x.img" "$x.vmdb" "$arm64_tarball"
done
+
+./smoke-armhf.sh "$dst/$armhf_tarball"
+
+for x in "$@" armhf-uefi
+do
+ tryit "$dst/$x.img" "$x.vmdb" "$armhf_tarball"
+done
+
+
echo All test images built successfully.
+
diff --git a/smoke-armhf.sh b/smoke-armhf.sh
new file mode 100755
index 0000000..c346df1
--- /dev/null
+++ b/smoke-armhf.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -eu
+
+tarball="$1"
+shift
+
+yarn smoke-armhf.yarn --env ROOTFS_TARBALL="$tarball" "$@"
diff --git a/smoke-armhf.yarn b/smoke-armhf.yarn
new file mode 100644
index 0000000..4e06681
--- /dev/null
+++ b/smoke-armhf.yarn
@@ -0,0 +1,70 @@
+# Smoke test vmdb2-built images
+
+This yarn file builds a basic image, and runs it under Qemu. The image
+is configured to have a serial console enabled, and the scenario below
+will log in as root (no password), and command the virtual machine to
+power off. If this works, the image is at least minimally functional,
+so the "smoke test" passes.
+
+More elaborate testing can be added, but smoke testing is enough for
+now.
+
+To run this yarn file, you need to run it as root (since it needs to
+build an image as root), and you need to run on a system where
+qemu-system-aarch64 is installed. Additionally, you need to add the
+following option to yarn:
+
+ EXAMPLE
+ --env ROOTFS_TARBALL=/path/to/rootfs/tarball
+
+This means vmdb2 will use the given tarball when creating an image,
+and if the tarball doesn't exist yet, it will create it. This makes
+testing multiple time much faster.
+
+ SCENARIO smoke test armhf UEFI image
+ WHEN user runs vmdb smoke-uefi-armhf.vmdb --output smoke-uefi-armhf.img
+ THEN user can UEFI boot smoke-uefi-armhf.img and power it off from root shell
+
+ IMPLEMENTS WHEN user runs vmdb (\S+) --output (\S+)
+ "$SRCDIR/vmdb2" "$SRCDIR/$MATCH_1" \
+ --output "$DATADIR/$MATCH_2" \
+ --log "$DATADIR/vmdb.log" \
+ --verbose \
+ --rootfs-tarball "$ROOTFS_TARBALL"
+
+ IMPLEMENTS THEN user can UEFI boot (\S+) and power it off from root shell
+ cd "$DATADIR"
+ img="$MATCH_1"
+ cat << EOF > run.sh
+ cp /usr/share/AAVMF/AAVMF32_VARS.fd .
+ qemu-system-arm \
+ -machine virt \
+ -cpu max \
+ -m 1024 \
+ -drive if=pflash,format=raw,unit=0,file=/usr/share/AAVMF/AAVMF32_CODE.fd,readonly=on \
+ -drive if=pflash,format=raw,unit=1,file=AAVMF32_VARS.fd \
+ -drive format=raw,file="$img" \
+ -nographic
+ EOF
+ chmod a+rx run.sh
+ cat << EOF > expect.txt
+ set timeout 600
+ proc abort {} {
+ puts "ERROR ERROR\n"
+ exit 1
+ }
+ spawn ./run.sh
+ expect "login: "
+ send "root\n"
+ expect "# "
+ send "poweroff\r"
+ set timeout 5
+ expect {
+ "reboot: Power down" {puts poweroffing\n}
+ eof abort
+ timeout abort
+ }
+ expect eof
+ wait
+ EOF
+ expect -d expect.txt > expect.out
diff --git a/smoke-uefi-armhf.vmdb b/smoke-uefi-armhf.vmdb
new file mode 100644
index 0000000..9f996f9
--- /dev/null
+++ b/smoke-uefi-armhf.vmdb
@@ -0,0 +1,75 @@
+steps:
+ - mkimg: "{{ output }}"
+ size: 4G
+
+ - mklabel: gpt
+ device: "{{ output }}"
+
+ - mkpart: primary
+ device: "{{ output }}"
+ start: 0%
+ end: 1G
+ tag: efifs
+
+ - mkpart: primary
+ device: "{{ output }}"
+ start: 1G
+ end: 100%
+ tag: rootfs
+
+ - kpartx: "{{ output }}"
+
+ - mkfs: vfat
+ partition: efifs
+
+ - mkfs: ext4
+ partition: rootfs
+ label: smoke
+
+ - mount: rootfs
+
+ - create-dir: /smoke-dir
+ perm: 0777
+ uid: 1000
+ gid: 1000
+
+ - create-file: /smoke-create-file.txt
+ contents: No smoke here.
+ perm: 0777
+ uid: 1000
+ gid: 1000
+
+ - copy-file: /smoke-copy-file.txt
+ src: smoke-copy-file.txt
+ perm: 0777
+ uid: 1000
+ gid: 1000
+
+ - unpack-rootfs: rootfs
+
+ - qemu-debootstrap: buster
+ arch: armhf
+ mirror: http://deb.debian.org/debian
+ keyring: /usr/share/keyrings/debian-archive-keyring.gpg
+ target: rootfs
+ unless: rootfs_unpacked
+
+ - apt: install
+ packages:
+ - linux-image-armmp-lpae
+ tag: rootfs
+ unless: rootfs_unpacked
+
+ - cache-rootfs: rootfs
+ unless: rootfs_unpacked
+
+ - chroot: rootfs
+ shell: |
+ sed -i '/^root:[^:]*:/s//root::/' /etc/passwd
+ echo armhf-vmdb2 > /etc/hostname
+
+ - fstab: rootfs
+
+ - grub: uefi
+ tag: rootfs
+ efi: efifs