diff options
author | Ryutaroh Matsumoto <ryutaroh@ict.e.titech.ac.jp> | 2021-01-10 15:59:55 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-01-11 07:46:55 +0000 |
commit | eb43e509b5f92e255d470babab8cf9c0183f4d0c (patch) | |
tree | 8e09c69a66adc75a931fb7b416c0b1f9030d4145 | |
parent | dc07436536f1e891e16b1dc0056fbcd99688bbda (diff) | |
download | vmdb2-eb43e509b5f92e255d470babab8cf9c0183f4d0c.tar.gz |
feat: Add i386 (UEFI) support
-rwxr-xr-x | check-all | 14 | ||||
-rw-r--r-- | i386-uefi.vmdb | 62 | ||||
-rwxr-xr-x | smoke-i386.sh | 8 | ||||
-rw-r--r-- | smoke-i386.yarn | 70 | ||||
-rw-r--r-- | smoke-uefi-i386.vmdb | 76 |
5 files changed, 229 insertions, 1 deletions
@@ -4,6 +4,8 @@ set -eu amd64_tarball="$1" shift +i386_tarball="$1" +shift arm64_tarball="$1" shift @@ -29,13 +31,23 @@ cd "$src" #tryit luks.img "$src/luks.vmdb" #tryit lvm2.img "$src/lvm2.vmdb"; exit -./smoke.sh "$amd64_tarball" + +./smoke.sh "$dst/$amd64_tarball" for x in "$@" pc uefi ansible smoke-pc smoke-uefi do tryit "$dst/$x.img" "$x.vmdb" "$amd64_tarball" done + +./smoke-i386.sh "$dst/$i386_tarball" + +for x in "$@" i386-uefi +do + tryit "$dst/$x.img" "$x.vmdb" "$i386_tarball" +done + + # On amd64, qemu-user-static has occasionally been observed to segfault. This # is being investigated further. # [ 865.372027] show_signal_msg: 21 callbacks suppressed diff --git a/i386-uefi.vmdb b/i386-uefi.vmdb new file mode 100644 index 0000000..1082a7e --- /dev/null +++ b/i386-uefi.vmdb @@ -0,0 +1,62 @@ +# This is a sample VMDB2 input file that specifies a simple system for +# an i386 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: i386 + mirror: http://deb.debian.org/debian + target: / + unless: rootfs_unpacked + + - apt: install + packages: + - linux-image-686-pae + fs-tag: / + unless: rootfs_unpacked + + - cache-rootfs: / + unless: rootfs_unpacked + + - chroot: / + shell: | + echo i386-uefi-vmdb2 > /etc/hostname + + - grub: uefi + tag: / + efi: efi diff --git a/smoke-i386.sh b/smoke-i386.sh new file mode 100755 index 0000000..b81a11c --- /dev/null +++ b/smoke-i386.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -eu + +tarball="$1" +shift + +yarn smoke-i386.yarn --env ROOTFS_TARBALL="$tarball" "$@" diff --git a/smoke-i386.yarn b/smoke-i386.yarn new file mode 100644 index 0000000..8d94b56 --- /dev/null +++ b/smoke-i386.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-i386 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 i386 UEFI image + WHEN user runs vmdb smoke-uefi-i386.vmdb --output smoke-uefi-i386.img + THEN user can UEFI boot smoke-uefi-i386.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/OVMF/OVMF32_VARS_4M.fd . + qemu-system-i386 \ + -machine q35 \ + -cpu max \ + -m 1024 \ + -drive if=pflash,format=raw,unit=0,file=/usr/share/OVMF/OVMF32_CODE_4M.secboot.fd,readonly=on \ + -drive if=pflash,format=raw,unit=1,file=OVMF32_VARS_4M.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-i386.vmdb b/smoke-uefi-i386.vmdb new file mode 100644 index 0000000..f04d74a --- /dev/null +++ b/smoke-uefi-i386.vmdb @@ -0,0 +1,76 @@ +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: i386 + mirror: http://deb.debian.org/debian + keyring: /usr/share/keyrings/debian-archive-keyring.gpg + target: rootfs + unless: rootfs_unpacked + + - apt: install + packages: + - linux-image-686-pae + tag: rootfs + unless: rootfs_unpacked + + - cache-rootfs: rootfs + unless: rootfs_unpacked + + - chroot: rootfs + shell: | + sed -i '/^root:[^:]*:/s//root::/' /etc/passwd + echo i386-vmdb2 > /etc/hostname + + - fstab: rootfs + + - grub: uefi + tag: rootfs + efi: efifs + console: serial |