From 6baf506947ba27ed9ce775cf9351cb0886166083 Mon Sep 17 00:00:00 2001 From: Clayton Wilkinson Date: Fri, 29 Mar 2024 13:26:50 -0700 Subject: docs/fuchsia: updating Fuchsia staging to use ffx This replaces the hard coded paths to files with running ffx commands to retrieve the value. This accomodates the changes that are being made to the structure of the Fuchsia build output. --- docs/fuchsia/README.md | 33 +++++++++++++++++++++++---------- docs/fuchsia/setup.sh | 37 +++++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 26 deletions(-) (limited to 'docs') diff --git a/docs/fuchsia/README.md b/docs/fuchsia/README.md index f8548fbbd..5f98955dd 100644 --- a/docs/fuchsia/README.md +++ b/docs/fuchsia/README.md @@ -72,17 +72,30 @@ make TARGETOS=fuchsia TARGETARCH=amd64 SOURCEDIR=${SOURCEDIR} Running syz-manager requires you to have built Fuchsia previously, and added the ssh keys to the fuchsia.zbi image: +The output of the Fuchsia build is a _product bundle_. Look up the image files needed +via `ffx product get-image-path`: + ```bash -${SOURCEDIR}/out/x64/host_x64/zbi -o ${SOURCEDIR}/out/x64/fuchsia-ssh.zbi \ - ${SOURCEDIR}/out/x64/fuchsia.zbi \ - --entry "data/ssh/authorized_keys=${SOURCEDIR}/.ssh/authorized_keys" + product_bundle_path="$(ffx config get product.path | tr -d '"')" + fxfs_path="$(ffx product get-image-path "$product_bundle_path" --slot a --image-type fxfs)" + zbi_path="$(ffx product get-image-path "$product_bundle_path" --slot a --image-type zbi)" + multiboot_path="$(ffx product get-image-path "$product_bundle_path" --slot a --image-type qemu-kernel)" ``` -You will also need to extend the `fvm` image: +Make sure the ssh keys exist and are properly configured: + +```bash + # Make sure there are ssh keys available + ffx config check-ssh-keys + auth_keys_path="$(ffx config get ssh.pub | tr -d '"')" + priv_key_path="$(ffx config get ssh.priv | tr -d '"')" +``` +Add the authorized keys to the zbi. ```bash -cp "${SOURCEDIR}/out/x64/obj/build/images/fuchsia/fuchsia/fvm.blk" "${SOURCEDIR}/out/x64/obj/build/images/fuchsia/fuchsia/fvm-extended.blk" -${SOURCEDIR}/out/x64/host_x64/fvm "${SOURCEDIR}/out/x64/obj/build/images/fuchsia/fuchsia/fvm-extended.blk" extend --length 3G +fx host-tool zbi -o "${SOURCEDIR}/out/x64/fuchsia-ssh.zbi" \ + "${zbi_path}" \ + --entry "data/ssh/authorized_keys=${auth_keys_path}" ``` Note: This needs to be repeated after each `fx build`. @@ -97,8 +110,8 @@ Create a `syz-manager` configuration file, using this as a starting point: "workdir": "/workdir.fuchsia", "kernel_obj": "/fuchsia/out/syz/kernel_x64-kasan/obj/zircon/kernel", "syzkaller": "/syzkaller", - "image": "/fuchsia/out/x64/obj/build/images/fuchsia/fuchsia/fvm-extended.blk", - "sshkey": "/fuchsia/.ssh/pkey", + "image": "$fxfs_path", + "sshkey": "$priv_key_path", "reproduce": false, "cover": false, "procs": 8, @@ -107,8 +120,8 @@ Create a `syz-manager` configuration file, using this as a starting point: "count": 10, "cpu": 4, "mem": 2048, - "kernel": "/fuchsia/out/x64/multiboot.bin", - "initrd": "/fuchsia/out/x64/fuchsia-ssh.zbi" + "kernel": "${multiboot_path}", + "initrd": " ${SOURCEDIR}/out/x64/fuchsia-ssh.zbi" } } ``` diff --git a/docs/fuchsia/setup.sh b/docs/fuchsia/setup.sh index 3eecf0308..d30cd76cd 100755 --- a/docs/fuchsia/setup.sh +++ b/docs/fuchsia/setup.sh @@ -89,21 +89,25 @@ run() { cd "$fuchsia" - # Look up needed deps from build_api metadata - fvm_path=$(jq -r '.[] | select(.name == "storage-full" and .type == "blk").path' out/x64/images.json) - zbi_path=$(jq -r '.[] | select(.name == "zircon-a" and .type == "zbi").path' out/x64/images.json) - multiboot_path=$(jq -r '.[] | select(.name == "qemu-kernel" and .type == "kernel").path' out/x64/images.json) + product_bundle_path="$(ffx config get product.path | tr -d '"')" + # Look up needed deps from the product bundle assembled + fxfs_path="$(ffx product get-image-path "$product_bundle_path" --slot a --image-type fxfs)" + zbi_path="$(ffx product get-image-path "$product_bundle_path" --slot a --image-type zbi)" + multiboot_path="$(ffx product get-image-path "$product_bundle_path" --slot a --image-type qemu-kernel)" + + # Make sure there are ssh keys available + ffx config check-ssh-keys + auth_keys_path="$(ffx config get ssh.pub | tr -d '"')" + priv_key_path="$(ffx config get ssh.priv | tr -d '"')" # Make a separate directory for copies of files we need to modify syz_deps_path=$fuchsia/out/x64/syzdeps - mkdir -p $syz_deps_path + mkdir -p "$syz_deps_path" + + ./out/x64/host_x64/zbi -o "${syz_deps_path}/fuchsia-ssh.zbi" "${zbi_path}" \ + --entry "data/ssh/authorized_keys=${auth_keys_path}" - ./out/x64/host_x64/zbi -o $syz_deps_path/fuchsia-ssh.zbi out/x64/$zbi_path \ - --entry "data/ssh/authorized_keys=${fuchsia}/.ssh/authorized_keys" - cp out/x64/$fvm_path \ - $syz_deps_path/fvm-extended.blk - ./out/x64/host_x64/fvm \ - $syz_deps_path/fvm-extended.blk extend --length 3G + cp "$fxfs_path" "${syz_deps_path}/fxfs.blk" echo "{ \"name\": \"fuchsia\", @@ -112,8 +116,8 @@ run() { \"workdir\": \"$workdir\", \"kernel_obj\": \"$fuchsia/out/x64/kernel_x64-kasan/obj/zircon/kernel\", \"syzkaller\": \"$syzkaller\", - \"image\": \"$syz_deps_path/fvm-extended.blk\", - \"sshkey\": \"$fuchsia/.ssh/pkey\", + \"image\": \"$syz_deps_path/fxfs.blk\", + \"sshkey\": \"$priv_key_path\", \"reproduce\": false, \"cover\": false, \"procs\": 8, @@ -122,7 +126,7 @@ run() { \"count\": 10, \"cpu\": 4, \"mem\": 2048, - \"kernel\": \"$fuchsia/out/x64/$multiboot_path\", + \"kernel\": \"$multiboot_path\", \"initrd\": \"$syz_deps_path/fuchsia-ssh.zbi\" } }" > "$workdir/fx-syz-manager-config.json" @@ -153,7 +157,8 @@ main() { while getopts "d" o; do case "$o" in d) - debug="--debug" + debug="--debug" ;; + *) ;; esac done shift $((OPTIND - 1)) @@ -180,4 +185,4 @@ main() { esac } -main $@ +main "$@" -- cgit mrf-deployment