Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ vars:
DEVDB_CONTAINER: spin-storage-devdb
DEVDB_PORT: '{{.DEVDB_PORT | default "55432"}}'
# The guest kernel, at the one path the lane reads. Put there by `task machine`.
GUEST_KERNEL: '{{.OUTPUT_DIR}}/guest/vmlinux'
GUEST_KERNEL: '{{.OUTPUT_DIR}}/kernel/vmlinux'
# Target database for db:plan / db:apply — the local development database by
# default. Point DB_* at a real one to plan or apply against it; the password
# comes from the environment (PGPASSWORD), never from a var in this file.
Expand Down
2 changes: 1 addition & 1 deletion hack/demo-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ OUT=$ROOT/_output
QEMU=$OUT/bin/qemu-system-x86_64
QEMU_TCG=$OUT/bin/qemu-system-x86_64-tcg
QEMU_IMG=$OUT/bin/qemu-img
KERNEL=$OUT/guest/vmlinux
KERNEL=$OUT/kernel/vmlinux
INITRAMFS=$OUT/guest/initramfs.cpio.gz
CP=$OUT/bin/control-plane
AGENT=$OUT/bin/volume-agent
Expand Down
34 changes: 19 additions & 15 deletions hack/spin-machine
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ NAME="spin-machine-${VERSION}-linux-${ARCH}"
# Both qemu-system binaries: the Agent runs on hosts with /dev/kvm and CI does not, and the
# split between a binary that refuses to emulate and one that can is the whole reason there
# are two. qemu-img because every qcow2 chain is created and inspected by running it — v6
# forbids a parser of our own. The kernel goes to _output/guest/vmlinux, which is the one
# path the guest lane reads.
# forbids a parser of our own.
#
# Each of them at the path the release already gives it, so _output/ has the release's own
# shape. What this repository builds for itself — the guest initramfs — keeps its own
# directory, and the split is worth reading off a listing: bin/, kernel/ and qemu/ came
# from a release, guest/ was built here.
#
# Not taken: the base image. Nothing here boots from it.
place() {
Expand All @@ -48,12 +52,17 @@ place() {
install -m "$([ -x "${src}" ] && echo 0755 || echo 0644)" "${src}" "${dest}"
}

# Each file at the path the release already gives it. This used to rearrange
# them — the kernel to guest/, the firmware under share/spin-stack/ — which
# meant the same files had one layout in the release and another here, with a
# translation between the two that every reader had to know about. There is
# nothing to know now: what the tarball says is where it is.
copy bin/qemu-system-x86_64 bin/qemu-system-x86_64
copy bin/qemu-system-x86_64-tcg bin/qemu-system-x86_64-tcg
copy bin/qemu-img bin/qemu-img
copy kernel/vmlinux guest/vmlinux
copy kernel/vmlinux kernel/vmlinux
for f in bios.bin bios-256k.bin pvh.bin kvmvapic.bin efi-virtio.rom; do
copy "qemu/${f}" "share/spin-stack/qemu/${f}"
copy "qemu/${f}" "qemu/${f}"
done

[ "${missing}" -eq 0 ] || {
Expand All @@ -69,20 +78,15 @@ place() {
# left-hand function, so a copy that failed halfway reports success.
have_sibling() {
local out="${SIBLING}/_output"
[ -f "${out}/bin/qemu-system-x86_64" ] && [ -f "${out}/vmlinux" ]
[ -f "${out}/bin/qemu-system-x86_64" ] && [ -f "${out}/kernel/vmlinux" ]
}

from_sibling() {
local out="${SIBLING}/_output" staged
echo "Using the machine built in ${SIBLING}"
staged="$(mktemp -d)"
trap 'rm -rf "${staged}"' RETURN
mkdir -p "${staged}/bin" "${staged}/kernel" "${staged}/qemu"
cp "${out}/bin/qemu-system-x86_64" "${out}/bin/qemu-system-x86_64-tcg" \
"${out}/bin/qemu-img" "${staged}/bin/"
cp "${out}/vmlinux" "${staged}/kernel/vmlinux"
cp "${out}"/share/spin-stack/qemu/* "${staged}/qemu/"
place "${staged}"
# A built tree and an unpacked release are the same shape, so this is the same copy
# the release path does. It used to stage the files into a third layout first,
# because they were not.
place "${SIBLING}/_output"
}

from_release() {
Expand Down Expand Up @@ -154,4 +158,4 @@ done
exit 1
}

echo "✓ machine ${VERSION}: qemu $("${OUTPUT_DIR}/bin/qemu-img" --version | head -1 | awk '{print $3}'), kernel $(stat -c%s "${OUTPUT_DIR}/guest/vmlinux") bytes"
echo "✓ machine ${VERSION}: qemu $("${OUTPUT_DIR}/bin/qemu-img" --version | head -1 | awk '{print $3}'), kernel $(stat -c%s "${OUTPUT_DIR}/kernel/vmlinux") bytes"
4 changes: 2 additions & 2 deletions hack/stage1-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mkfifo "$DIR/ctl"
exec 9<>"$DIR/ctl"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=hold" \
-drive "file=$IMAGE,format=qcow2,if=virtio,cache=writeback" \
Expand Down Expand Up @@ -97,7 +97,7 @@ grep -m1 "GUESTINIT-PASS" "$DIR/logs/guest1.log"
say "7. a second boot, reading only"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=verify" \
-drive "file=$IMAGE,format=qcow2,if=virtio,cache=writeback" \
Expand Down
4 changes: 2 additions & 2 deletions hack/stage2-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mkfifo "$DIR/ctl"
exec 9<>"$DIR/ctl"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=hold spin.churn=$CHURN" \
-blockdev "driver=file,filename=$FIRST,node-name=vol-file,discard=unmap" \
Expand Down Expand Up @@ -139,7 +139,7 @@ echo " qemu-img check: all $LAYERS layers sound"
say "8. a second boot, reading only, through the whole chain"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=verify" \
-drive "file=$TIP,format=qcow2,if=virtio,cache=writeback" \
Expand Down
4 changes: 2 additions & 2 deletions hack/stage3-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mkfifo "$DIR/ctl"
exec 9<>"$DIR/ctl"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=hold spin.churn=$CHURN" \
-drive "file=$FIRST,format=qcow2,if=virtio,cache=writeback" \
Expand Down Expand Up @@ -136,7 +136,7 @@ say "9. a second boot, reading only"
TIP=$(cat "$POINTER")
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=verify" \
-drive "file=$TIP,format=qcow2,if=virtio,cache=writeback" \
Expand Down
4 changes: 2 additions & 2 deletions hack/stage4-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mkfifo "$DIR/ctl"
exec 9<>"$DIR/ctl"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=hold spin.churn=$CHURN" \
-drive "file=$FIRST,format=qcow2,if=virtio,cache=writeback" \
Expand Down Expand Up @@ -141,7 +141,7 @@ echo " qemu-img check: every downloaded layer is sound"
say "9. a guest reads back what a guest on a host that no longer exists wrote"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=verify" \
-drive "file=$RECOVERED,format=qcow2,if=virtio,cache=writeback" \
Expand Down
2 changes: 1 addition & 1 deletion hack/stage5-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mkfifo "$DIR/ctl"
exec 9<>"$DIR/ctl"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=hold spin.churn=$CHURN" \
-drive "file=$FIRST,format=qcow2,if=virtio,cache=writeback" \
Expand Down
8 changes: 4 additions & 4 deletions hack/stage6-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mkfifo "$DIR/ctl"
exec 9<>"$DIR/ctl"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=hold spin.churn=8 spin.slot=0" \
-drive "file=$(cat "$POINTER"),format=qcow2,if=virtio,cache=writeback" \
Expand Down Expand Up @@ -112,7 +112,7 @@ say "7. a second guest boots the clone and reads the FIRST guest's pattern"
CSOCK=$(grep "volume_id=$CLONE" "$DIR/logs/agent1.log" | grep -m1 -o 'qmp_socket=[^ ]*' | cut -d= -f2)
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=verify spin.slot=0" \
-drive "file=$CIMAGE,format=qcow2,if=virtio,cache=writeback" \
Expand All @@ -132,7 +132,7 @@ mkfifo "$DIR/ctl2"
exec 8<>"$DIR/ctl2"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=hold spin.slot=1" \
-drive "file=$CIMAGE,format=qcow2,if=virtio,cache=writeback" \
Expand Down Expand Up @@ -182,7 +182,7 @@ echo " its chain is $GDEPTH layers deep"
say "12. a guest boots the clone of the clone and reads the ORIGINAL guest's slot"
"$QEMU" -machine "q35,accel=$ACCEL" -m 512 -smp 1 -display none -vga none -monitor none -no-reboot \
-net none \
-L "$OUT/share/spin-stack/qemu" \
-L "$OUT/qemu" \
-kernel "$KERNEL" -initrd "$INITRAMFS" \
-append "console=ttyS0 panic=1 spin.mode=verify spin.slot=0" \
-drive "file=$GIMAGE,format=qcow2,if=virtio,cache=writeback" \
Expand Down
4 changes: 2 additions & 2 deletions taskfiles/machine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ tasks:
- "{{.OUTPUT_DIR}}/bin/qemu-img --version"
- "{{.OUTPUT_DIR}}/bin/qemu-system-x86_64 --version"
- "{{.OUTPUT_DIR}}/bin/qemu-system-x86_64-tcg --version"
- "test -f {{.OUTPUT_DIR}}/guest/vmlinux"
- "test -f {{.OUTPUT_DIR}}/share/spin-stack/qemu/pvh.bin"
- "test -f {{.OUTPUT_DIR}}/kernel/vmlinux"
- "test -f {{.OUTPUT_DIR}}/qemu/pvh.bin"
cmds:
- |
set -euo pipefail
Expand Down
Loading