summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kastner <ckk@kvr.at>2021-01-10 21:32:51 +0100
committerLars Wirzenius <liw@liw.fi>2021-01-11 07:46:55 +0000
commit7978ff479215a83cff373ff01558f26f7ab3ffe5 (patch)
treee0ab54599bd0db0b43923c0b6390fa8301e69ef5
parentfc94aeb18e8779a13d5aee959a5dab3770147c2a (diff)
downloadvmdb2-7978ff479215a83cff373ff01558f26f7ab3ffe5.tar.gz
feat: Add i386 (BIOS) support
-rwxr-xr-xcheck-all2
-rw-r--r--i386.vmdb56
-rw-r--r--pc.vmdb2
-rw-r--r--smoke-i386.vmdb72
-rw-r--r--smoke-i386.yarn35
-rw-r--r--uefi.vmdb2
6 files changed, 164 insertions, 5 deletions
diff --git a/check-all b/check-all
index 79abc0b..35c4ec1 100755
--- a/check-all
+++ b/check-all
@@ -45,7 +45,7 @@ done
./smoke-i386.sh "$dst/$i386_tarball"
-for x in "$@" i386-uefi
+for x in "$@" i386 i386-uefi
do
tryit "$dst/$x.img" "$x.vmdb" "$i386_tarball"
done
diff --git a/i386.vmdb b/i386.vmdb
new file mode 100644
index 0000000..239b58e
--- /dev/null
+++ b/i386.vmdb
@@ -0,0 +1,56 @@
+# This is a sample VMDB2 input file to specify a simple
+# system that boots on a 32-bit PC with BIOS.
+
+steps:
+ - mkimg: "{{ output }}"
+ size: 4G
+
+ - mklabel: msdos
+ device: "{{ output }}"
+
+ - mkpart: primary
+ device: "{{ output }}"
+ start: 0%
+ end: 50%
+ tag: /
+
+ - kpartx: "{{ output }}"
+
+ - mkfs: ext4
+ partition: /
+
+ - mount: /
+
+ - unpack-rootfs: /
+
+ - qemu-debootstrap: buster
+ arch: i386
+ mirror: http://deb.debian.org/debian
+ target: /
+ unless: rootfs_unpacked
+
+ - apt: install
+ packages:
+ - linux-image-686-pae
+ tag: /
+ unless: rootfs_unpacked
+
+ - cache-rootfs: /
+ unless: rootfs_unpacked
+
+ - chroot: /
+ shell: |
+ echo i386 > /etc/hostname
+ apt -y install python3 parted
+
+ - fstab: /
+
+ - chroot: /
+ shell: |
+ sed -i 's,^root:[^:]*:,root::,' /etc/passwd
+
+ - resize-rootfs: /
+
+ - grub: bios
+ tag: /
+ quiet: false
diff --git a/pc.vmdb b/pc.vmdb
index 17d50fa..59aeb9e 100644
--- a/pc.vmdb
+++ b/pc.vmdb
@@ -1,5 +1,5 @@
# This is a sample VMDB2 input file to specify a simple
-# system that boots on a PC with BIOS.
+# system that boots on a 64-bit PC with BIOS.
steps:
- mkimg: "{{ output }}"
diff --git a/smoke-i386.vmdb b/smoke-i386.vmdb
new file mode 100644
index 0000000..8f769d9
--- /dev/null
+++ b/smoke-i386.vmdb
@@ -0,0 +1,72 @@
+steps:
+ - mkimg: "{{ output }}"
+ size: 4G
+
+ - mklabel: msdos
+ device: "{{ output }}"
+
+ - mkpart: primary
+ device: "{{ output }}"
+ start: 1M
+ end: 10M
+ tag: unused
+
+ - mkpart: primary
+ device: "{{ output }}"
+ start: 10M
+ end: 100%
+ tag: rootfs
+
+ - kpartx: "{{ output }}"
+
+ - 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 pc-vmdb2 > /etc/hostname
+
+ - fstab: rootfs
+
+ - grub: bios
+ tag: rootfs
+ console: serial
diff --git a/smoke-i386.yarn b/smoke-i386.yarn
index 8d94b56..bf71bb1 100644
--- a/smoke-i386.yarn
+++ b/smoke-i386.yarn
@@ -13,7 +13,6 @@ 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
@@ -21,7 +20,10 @@ 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
+ SCENARIO smoke test i386 image
+ WHEN user runs vmdb smoke-i386.vmdb --output smoke-i386.img
+ THEN user can BIOS boot smoke-i386.img and power it off from root shell
+
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
@@ -32,6 +34,35 @@ testing multiple time much faster.
--verbose \
--rootfs-tarball "$ROOTFS_TARBALL"
+ IMPLEMENTS THEN user can BIOS boot (\S+) and power it off from root shell
+ cd "$DATADIR"
+ img="$MATCH_1"
+ cat << EOF > run.sh
+ qemu-system-x86_64 -drive file="$img",format=raw -m 1024 -nographic
+ EOF
+ chmod a+rx run.sh
+ cat << EOF > expect.txt
+ set timeout 300
+ 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
+
IMPLEMENTS THEN user can UEFI boot (\S+) and power it off from root shell
cd "$DATADIR"
img="$MATCH_1"
diff --git a/uefi.vmdb b/uefi.vmdb
index 9a1d87f..f75193f 100644
--- a/uefi.vmdb
+++ b/uefi.vmdb
@@ -1,5 +1,5 @@
# This is a sample VMDB2 input file that specifies a simple system for
-# a PC that boots with UEFI.
+# a 64-bit PC that boots with UEFI.
steps:
- mkimg: "{{ output }}"