diff --git a/Taskfile.yml b/Taskfile.yml index 6be6e2e..43310dd 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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. diff --git a/hack/demo-lib.sh b/hack/demo-lib.sh index 5922553..a99f6af 100755 --- a/hack/demo-lib.sh +++ b/hack/demo-lib.sh @@ -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 diff --git a/hack/spin-machine b/hack/spin-machine index 00b548c..07559fc 100755 --- a/hack/spin-machine +++ b/hack/spin-machine @@ -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() { @@ -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 ] || { @@ -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() { @@ -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" diff --git a/hack/stage1-demo.sh b/hack/stage1-demo.sh index dde6459..bdd33ba 100755 --- a/hack/stage1-demo.sh +++ b/hack/stage1-demo.sh @@ -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" \ @@ -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" \ diff --git a/hack/stage2-demo.sh b/hack/stage2-demo.sh index 52b6fe0..7dc77b1 100755 --- a/hack/stage2-demo.sh +++ b/hack/stage2-demo.sh @@ -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" \ @@ -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" \ diff --git a/hack/stage3-demo.sh b/hack/stage3-demo.sh index 0b99594..a7ee2fc 100755 --- a/hack/stage3-demo.sh +++ b/hack/stage3-demo.sh @@ -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" \ @@ -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" \ diff --git a/hack/stage4-demo.sh b/hack/stage4-demo.sh index fa2f5f5..f7e32c3 100755 --- a/hack/stage4-demo.sh +++ b/hack/stage4-demo.sh @@ -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" \ @@ -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" \ diff --git a/hack/stage5-demo.sh b/hack/stage5-demo.sh index 5609730..9967699 100755 --- a/hack/stage5-demo.sh +++ b/hack/stage5-demo.sh @@ -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" \ diff --git a/hack/stage6-demo.sh b/hack/stage6-demo.sh index cefbd5b..f235d80 100755 --- a/hack/stage6-demo.sh +++ b/hack/stage6-demo.sh @@ -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" \ @@ -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" \ @@ -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" \ @@ -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" \ diff --git a/taskfiles/machine.yml b/taskfiles/machine.yml index 55515b8..03a9afa 100644 --- a/taskfiles/machine.yml +++ b/taskfiles/machine.yml @@ -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