Last active
November 8, 2025 16:37
-
-
Save daemonhorn/a3a3d271a7e3f4528975cdcbcfc06c71 to your computer and use it in GitHub Desktop.
Revisions
-
dhorn revised this gist
Nov 8, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ usage() { echo " [-u <USBDevice String>] (host-to-guest mapping)" echo "" echo " -a will select an architecture arm64|riscv64|amd64 (required)" echo -e " -r will select the latest BETA|ALPHA|${GREEN}RELEASE${NO_COLOR} version available for download" echo -e " -t will select a ${GREEN}VM_IMAGE (Default)${NO_COLOR} or ISO (Install from scratch) for download" echo " -T will optionally enable tmux serial console and qemu-monitor in foreground" echo " -u will optionally enable passthrough of specific USB device from HOST to GUEST" -
dhorn revised this gist
Nov 8, 2025 . 1 changed file with 31 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,12 @@ set -o errexit # Downloads images/ISOs from FreeBSD master site # Maps in usb devices as desired to guest #UI color/bold consts RED="\\033[31m" GREEN="\\033[32m" BLUE="\\033[34m" NO_COLOR="\\033[39m" # Global constants dl_uri="https://download.freebsd.org/releases/" work_dir="." @@ -16,21 +22,26 @@ cpus="4" usage() { echo "Usage:" echo " $0 [-a <arm64|riscv64|amd64>] (required)" echo -e " [-r <BETA|ALPHA|${GREEN}RELEASE${NO_COLOR}>]" echo -e " [-t <ISO|${GREEN}VM${NO_COLOR}>]" echo " [-T] (start tmux on vm launch)" echo " [-u <USBDevice String>] (host-to-guest mapping)" echo "" echo " -a will select an architecture arm64|riscv64|amd64 (required)" echo " -r will select the latest BETA|ALPHA|${GREEN}RELEASE${NO_COLOR} version available for download" echo -e " -t will select a ${GREEN}VM_IMAGE (Default)${NO_COLOR} or ISO (Install from scratch) for download" echo " -T will optionally enable tmux serial console and qemu-monitor in foreground" echo " -u will optionally enable passthrough of specific USB device from HOST to GUEST" echo "" exit 1 } # If variable not defined, define default. r="RELEASE" t="VM" while getopts ":a:r:u:t:T" opt; do case "${opt}" in a) a=${OPTARG} @@ -49,6 +60,10 @@ while getopts ":a:r:u:t:" opt; do # Only support VM and ISO at the moment. [ ${t} = "VM" -o ${t} = "ISO" ] || t="VM" ;; T) T="YES" pkg info tmux >/dev/null || pkg install -y tmux ;; *) usage ;; @@ -172,14 +187,20 @@ setup-usb-passthrough() { echo "command, or delete the usb device mapping with \"device_del ${u}\"" } start-tmux() { tmux new-session -d -s qemu-monitor 'telnet localhost 4445' tmux new-session -d -s ${image_file} 'telnet localhost 4444' tmux attach } [ ${t} = "VM" ] && fetch-image [ ${t} = "ISO" ] && fetch-iso [ ! -z "${u}" ] && setup-usb-passthrough # Safety check. set +o errexit ps -aux | grep -v grep | grep -cq qemu-system && \ echo "Qemu is already running. Shutdown the guest, then retry. (telnet localhost 4445)" && exit 1 # Cleanup tap0 interfaces that are not in use anymore. ifconfig tap0 2>/dev/null | grep -cq -e "Opened by PID" || ifconfig tap0 destroy 2>/dev/null || true @@ -201,6 +222,8 @@ ${qemu_bin} -m ${memory} -cpu max -smp cpus=${cpus} -M ${machine} \ ${usb_qemu_cli} \ -daemonize echo "Connect to guest console (telnet localhost 4444), or qemu monitor (telnet localhost 4445)" if [ "${t}" = "ISO" -a -z "${T}" ] ; then telnet localhost 4444 elif [ "${T}" ] ; then start-tmux fi -
dhorn revised this gist
Nov 3, 2025 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,10 @@ set -o errexit dl_uri="https://download.freebsd.org/releases/" work_dir="." # Qemu hardware config (adjust as desired) memory="4096M" cpus="4" usage() { echo "Usage:" @@ -182,7 +186,7 @@ ifconfig tap0 2>/dev/null | grep -cq -e "Opened by PID" || ifconfig tap0 destroy set -o errexit echo "Starting Qemu in background..." ${qemu_bin} -m ${memory} -cpu max -smp cpus=${cpus} -M ${machine} \ ${bios} \ ${iso_boot_cli} \ -serial telnet:localhost:4444,mux=on,server,wait=off \ -
dhorn revised this gist
Nov 3, 2025 . 1 changed file with 159 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,159 @@ #!/bin/sh set -o errexit # Helper script for running FreeBSD under bhyve # Downloads images/ISOs from FreeBSD master site # Maps in usb devices as desired to guest # Global constants dl_uri="https://download.freebsd.org/releases/" work_dir="." cpus="4" memory="4096M" # -E makes UEFI mode active in vmrun.sh bios="-E" usage() { echo "Usage:" echo " $0 [-r <BETA|ALPHA|RELEASE>] [-u <USBDevice String>]" echo " [-t <VM|ISO>]" echo "" echo " -r will select the latest BETA/ALPHA/RELEASE version available for download" echo " -t will select a VM_IMAGE (Default) or ISO (Install from scratch) for download" echo " -u will optionally enable passthrough of specific USB device from HOST to GUEST" exit 1 } # If variable not defined, define default. r="RELEASE" t="VM" while getopts ":a:r:u:t:" opt; do case "${opt}" in r) r=${OPTARG} # If it does not match BETA or ALPHA set to RELEASE [ ${r} = "BETA" -o ${r} = "ALPHA" ] || r="RELEASE" ;; u) u=${OPTARG} ;; t) t=${OPTARG} # Only support VM and ISO at the moment. [ ${t} = "VM" -o ${t} = "ISO" ] || t="VM" ;; *) usage ;; esac done shift $((OPTIND-1)) # Handle the architecture specific variables and arguments arch="$(sysctl -n hw.machine_arch)" archvariant="${arch}" kldload -n vmm pkg info edk2-bhyve || pkg install -y edk2-bhyve validate-sha512() { set +o errexit [ -z "${1}" -o ! -s ${1} ] && echo "No file ${1} for hash verification" && exit 1 echo "Validating SHA512 CHECKSUM..." # We are cheating a bit and just using file globs so we don't need to pass in exact CHECKSUM filename expect_hash=$(grep ${1} CHECKSUM.SHA512* | cut -d "=" -f 2 | tr -d ' ') #echo "expect_hash: ${expect_hash}" actual_hash=$(sha512sum --quiet ${1} | tr -d ' ') #echo "actual_hash: ${actual_hash}" if [ "${expect_hash}" != "${actual_hash}" ] ; then printf "Failure validating hash on ${1}. \nExpect: ${expect_hash} \nActual: ${actual_hash}\n" exit 1 fi set -o errexit } fetch-image() { latest_version=$(curl -s ${dl_uri}VM-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | head -1 | tr -d '/') image_file="FreeBSD-${latest_version}-${archvariant}-ufs.raw" echo "Getting ready to fetch and/or start ${image_file}" if [ ! -s ${image_file} ] ; then fetch "${dl_uri}VM-IMAGES/${latest_version}/${arch}/Latest/${image_file}.xz" "${dl_uri}VM-IMAGES/${latest_version}/${arch}/Latest/CHECKSUM.SHA512" validate-sha512 ${image_file}.xz unxz ${image_file}.xz qemu-img resize ${image_file} +45G fi } fetch-iso() { toplevel_version=$(curl -s ${dl_uri}VM-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | \ head -1 | tr -d '/' | sed s/-${r}[0-9]*//1) #echo "toplevel_version: ${toplevel_version}" latest_version=$(curl -s ${dl_uri}ISO-IMAGES/${toplevel_version}/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*" | uniq | sort -gr | head -1 | tr -d '/') #echo "latest_version: ${latest_version}" iso_file="FreeBSD-${latest_version}-${archvariant}-bootonly.iso" echo "Getting ready to fetch and/or start ${iso_file}" iso_boot_cli="-i -I ${iso_file}" image_file="FreeBSD-${latest_version}-${archvariant}-ufs.raw" iso_dl_uri="${dl_uri}ISO-IMAGES/${toplevel_version}/${iso_file}" checksum_dl_uri="${dl_uri}ISO-IMAGES/${toplevel_version}/CHECKSUM.SHA512-FreeBSD-${latest_version}-${archvariant}" if [ ! -s ${iso_file} ] ; then fetch "${iso_dl_uri}.xz" "${checksum_dl_uri}" validate-sha512 ${iso_file}.xz unxz ${iso_file}.xz fi if [ ! -s ${image_file} ] ; then truncate -s 45G ${image_file} else read -p "You selected ISO Install with an existing disk image ${image_file}. Do you wish to remove the existing file and recreate a blank disk file ? (y/n): " overwrite if [ "${overwrite}" = "y" -o "${overwrite}" = "Y" ] ; then rm ${image_file} truncate -s 45G ${image_file} fi fi } setup-usb-passthrough() { echo "Attempting to passthrough usb host device based on query string: ${u}" usb_map_count=$(usbconfig | grep -cie ${u}) [ ${usb_map_count} -ne 1 ] && \ echo "Total devices matched: ${usb_map_count} is not equal to 1, please refine." && \ usbconfig && exit 1 usb_map=$(usbconfig | grep -ie ${u} | grep -E -o -e "[0-9]+\.[0-9]+") #echo "usb_map: ${usb_map}" usb_map_bus=$(echo ${usb_map} | grep -E -o -e "^[0-9]+") usb_map_addr=$(echo ${usb_map} | grep -E -o -e "[0-9]+$") usb_qemu_cli="-device usb-host,hostbus=${usb_map_bus},hostaddr=${usb_map_addr},id=${u}" echo "Mapping usb device $(usbconfig | grep -ie ${u}) into the guest." #echo "usb_qemu_cli = ${usb_qemu_cli}" echo -n "In qemu monitor, you can inspect attached usb guest devices with \"info usb\" " echo "command, or delete the usb device mapping with \"device_del ${u}\"" } [ ${t} = "VM" ] && fetch-image [ ${t} = "ISO" ] && fetch-iso [ ! -z "${u}" ] && setup-usb-passthrough # Safety check. set +o errexit ps -aux | grep -v -e grep -e start_bhyve | grep -cq bhyve && \ echo "Bhyve is already running. Shutdown the guest, then retry." && exit 1 # Cleanup tap0 interfaces that are not in use anymore. ifconfig tap0 2>/dev/null | grep -cq -e "Opened by PID" || ifconfig tap0 destroy 2>/dev/null || true set -o errexit echo "Starting Bhyve using vmrun.sh in background..." vmrun.sh -m ${memory} -c ${cpus} \ ${bios} \ ${iso_boot_cli} \ -d ${work_dir}/${image_file} \ -t tap0 \ ${image_file} echo "Connect to guest console (telnet localhost 4444), or qemu monitor (telnet localhost 4445)" if [ ${t} = "ISO" ] ; then #telnet localhost 4444 fi -
dhorn revised this gist
Nov 2, 2025 . 1 changed file with 9 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -127,19 +127,24 @@ fetch-iso() { #echo "latest_version: ${latest_version}" iso_file="FreeBSD-${latest_version}-${archvariant}-bootonly.iso" echo "Getting ready to fetch and/or start ${iso_file}" iso_boot_cli="-boot order=d -cdrom ${iso_file}" image_file="FreeBSD-${latest_version}-${archvariant}-ufs.qcow2" iso_dl_uri="${dl_uri}ISO-IMAGES/${toplevel_version}/${iso_file}" checksum_dl_uri="${dl_uri}ISO-IMAGES/${toplevel_version}/CHECKSUM.SHA512-FreeBSD-${latest_version}-${archvariant}" # The bootindex variable and other bootorder only works with x86_64 (amd64) as of 10.1.x #iso_boot_cli="-boot once=d -drive file=${iso_dl_uri},if=none,id=cdrom0,media=cdrom -device virtio-blk-pci,drive=cdrom0,bootindex=1" if [ ! -s ${iso_file} ] ; then fetch "${iso_dl_uri}.xz" "${checksum_dl_uri}" validate-sha512 ${iso_file}.xz unxz ${iso_file}.xz fi if [ ! -s ${image_file} ] ; then qemu-img create -f qcow2 ${image_file} 45G else read -p "You selected ISO Install with an existing disk image ${image_file}. Do you wish to remove the existing file and recreate a blank disk file ? (y/n): " overwrite if [ "${overwrite}" = "y" -o "${overwrite}" = "Y" ] ; then rm ${image_file} qemu-img create -f qcow2 ${image_file} 45G fi -
dhorn revised this gist
Nov 2, 2025 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -192,3 +192,6 @@ ${qemu_bin} -m 4096M -cpu max -smp cpus=4 -M ${machine} \ ${usb_qemu_cli} \ -daemonize echo "Connect to guest console (telnet localhost 4444), or qemu monitor (telnet localhost 4445)" if [ ${t} = "ISO" ] ; then telnet localhost 4444 fi -
dhorn revised this gist
Nov 1, 2025 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -91,6 +91,7 @@ esac validate-sha512() { set +o errexit [ -z "${1}" -o ! -s ${1} ] && echo "No file ${1} for hash verification" && exit 1 echo "Validating SHA512 CHECKSUM..." # We are cheating a bit and just using file globs so we don't need to pass in exact CHECKSUM filename expect_hash=$(grep ${1} CHECKSUM.SHA512* | cut -d "=" -f 2 | tr -d ' ') #echo "expect_hash: ${expect_hash}" @@ -107,6 +108,7 @@ fetch-image() { latest_version=$(curl -s ${dl_uri}VM-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | head -1 | tr -d '/') image_file="FreeBSD-${latest_version}-${archvariant}-ufs.qcow2" echo "Getting ready to fetch and/or start ${image_file}" if [ ! -s ${image_file} ] ; then fetch "${dl_uri}VM-IMAGES/${latest_version}/${arch}/Latest/${image_file}.xz" "${dl_uri}VM-IMAGES/${latest_version}/${arch}/Latest/CHECKSUM.SHA512" validate-sha512 ${image_file}.xz @@ -119,11 +121,12 @@ fetch-iso() { toplevel_version=$(curl -s ${dl_uri}VM-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | \ head -1 | tr -d '/' | sed s/-${r}[0-9]*//1) #echo "toplevel_version: ${toplevel_version}" latest_version=$(curl -s ${dl_uri}ISO-IMAGES/${toplevel_version}/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*" | uniq | sort -gr | head -1 | tr -d '/') #echo "latest_version: ${latest_version}" iso_file="FreeBSD-${latest_version}-${archvariant}-bootonly.iso" echo "Getting ready to fetch and/or start ${iso_file}" iso_boot_cli="-boot d -cdrom ${iso_file}" image_file="FreeBSD-${latest_version}-${archvariant}-ufs.qcow2" if [ ! -s ${iso_file} ] ; then -
dhorn revised this gist
Nov 1, 2025 . 1 changed file with 8 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -116,16 +116,19 @@ fetch-image() { } fetch-iso() { toplevel_version=$(curl -s ${dl_uri}VM-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | \ head -1 | tr -d '/' | sed s/-${r}[0-9]*//1) echo "toplevel_version: ${toplevel_version}" latest_version=$(curl -s ${dl_uri}ISO-IMAGES/${toplevel_version}/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*" | uniq | sort -gr | head -1 | tr -d '/') echo "latest_version: ${latest_version}" iso_file="FreeBSD-${latest_version}-${archvariant}-bootonly.iso" iso_boot_cli="-boot d -cdrom ${iso_file}" image_file="FreeBSD-${latest_version}-${archvariant}-ufs.qcow2" if [ ! -s ${iso_file} ] ; then fetch "${dl_uri}ISO-IMAGES/${toplevel_version}/${iso_file}.xz" \ "${dl_uri}ISO-IMAGES/${toplevel_version}/CHECKSUM.SHA512-FreeBSD-${latest_version}-${archvariant}" validate-sha512 ${iso_file}.xz unxz ${iso_file}.xz fi -
dhorn revised this gist
Nov 1, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -118,7 +118,7 @@ fetch-image() { fetch-iso() { toplevel_version=$(curl -s ${dl_uri}ISO-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}/" | uniq | sort -gr | head -1 | tr -d '/') latest_version=$(curl -s ${dl_uri}VM-IMAGES/${toplevel_version}/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | head -1 | tr -d '/') iso_file="FreeBSD-${latest_version}-${archvariant}-bootonly.iso" iso_boot_cli="-boot d -cdrom ${iso_file}" -
dhorn revised this gist
Nov 1, 2025 . 1 changed file with 77 additions and 77 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,55 +11,52 @@ work_dir="." usage() { echo "Usage:" echo " $0 [-a <arm64|riscv64|amd64>] [-r <BETA|ALPHA|RELEASE>] [-u <USBDevice String>]" echo " [-t <VM|ISO>]" echo "" echo " -a will select an architecture (REQUIRED)" echo " -r will select the latest BETA/ALPHA/RELEASE version available for download" echo " -t will select a VM_IMAGE (Default) or ISO (Install from scratch) for download" echo " -u will optionally enable passthrough of specific USB device from HOST to GUEST" exit 1 } # If variable not defined, define default. r="RELEASE" t="VM" while getopts ":a:r:u:t:" opt; do case "${opt}" in a) a=${OPTARG} [ ${a} = "arm64" -o ${a} = "riscv64" -o ${a} = "amd64" ] || usage ;; r) r=${OPTARG} # If it does not match BETA or ALPHA set to RELEASE [ ${r} = "BETA" -o ${r} = "ALPHA" ] || r="RELEASE" ;; u) u=${OPTARG} ;; t) t=${OPTARG} # Only support VM and ISO at the moment. [ ${t} = "VM" -o ${t} = "ISO" ] || t="VM" ;; *) usage ;; esac done shift $((OPTIND-1)) # Check for REQUIRED args if [ -z "${a}" ]; then usage fi # Check to make sure qemu is installed which qemu-system-x86_64 >/dev/null 2>&1 || pkg install -y qemu-nox11 @@ -100,15 +97,15 @@ validate-sha512() { actual_hash=$(sha512sum --quiet ${1} | tr -d ' ') #echo "actual_hash: ${actual_hash}" if [ "${expect_hash}" != "${actual_hash}" ] ; then printf "Failure validating hash on ${1}. \nExpect: ${expect_hash} \nActual: ${actual_hash}\n" exit 1 fi set -o errexit } fetch-image() { latest_version=$(curl -s ${dl_uri}VM-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | head -1 | tr -d '/') image_file="FreeBSD-${latest_version}-${archvariant}-ufs.qcow2" if [ ! -s ${image_file} ] ; then fetch "${dl_uri}VM-IMAGES/${latest_version}/${arch}/Latest/${image_file}.xz" "${dl_uri}VM-IMAGES/${latest_version}/${arch}/Latest/CHECKSUM.SHA512" @@ -120,69 +117,72 @@ fetch-image() { fetch-iso() { toplevel_version=$(curl -s ${dl_uri}ISO-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}/" | uniq | sort -gr | head -1 | tr -d '/') latest_version=$(curl -s ${dl_uri}VM-IMAGES/${loplevel_version}/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | head -1 | tr -d '/') iso_file="FreeBSD-${latest_version}-${archvariant}-bootonly.iso" iso_boot_cli="-boot d -cdrom ${iso_file}" image_file="FreeBSD-${latest_version}-${archvariant}-ufs.qcow2" if [ ! -s ${iso_file} ] ; then fetch "${dl_uri}ISO-IMAGES/${toplevel_version}/${iso_file}.xz" \ "${dl_uri}ISO-IMAGES/${toplevel_version}/CHECKSUM.SHA512-FreeBSD-${latest_version}-${archvariant}" validate-sha512 ${iso_file}.xz unxz ${iso_file}.xz fi if [ ! -s ${image_file} ] ; then qemu-img create -f qcow2 ${image_file} 45G else read -p "You selected ISO Install with an existing disk image ${image_file}. Do you wish to remove the existing file and recreate a blank disk file ? (y/n): " overwrite if [ ${overwrite} = "y" -o ${overwrite} = "Y" ] ; then rm ${image_file} qemu-img create -f qcow2 ${image_file} 45G fi fi } setup-usb-passthrough() { echo "Attempting to passthrough usb host device based on query string: ${u}" usb_map_count=$(usbconfig | grep -cie ${u}) [ ${usb_map_count} -ne 1 ] && \ echo "Total devices matched: ${usb_map_count} is not equal to 1, please refine." && \ usbconfig && exit 1 usb_map=$(usbconfig | grep -ie ${u} | grep -E -o -e "[0-9]+\.[0-9]+") #echo "usb_map: ${usb_map}" usb_map_bus=$(echo ${usb_map} | grep -E -o -e "^[0-9]+") usb_map_addr=$(echo ${usb_map} | grep -E -o -e "[0-9]+$") usb_qemu_cli="-device usb-host,hostbus=${usb_map_bus},hostaddr=${usb_map_addr},id=${u}" echo "Mapping usb device $(usbconfig | grep -ie ${u}) into the guest." #echo "usb_qemu_cli = ${usb_qemu_cli}" echo -n "In qemu monitor, you can inspect attached usb guest devices with \"info usb\" " echo "command, or delete the usb device mapping with \"device_del ${u}\"" } [ ${t} = "VM" ] && fetch-image [ ${t} = "ISO" ] && fetch-iso [ ! -z "${u}" ] && setup-usb-passthrough # Safety check. set +o errexit ps -aux | grep -v grep | grep -cq qemu-system && \ echo "Qemu is already running. Shutdown the guest, then retry." && exit 1 # Cleanup tap0 interfaces that are not in use anymore. ifconfig tap0 2>/dev/null | grep -cq -e "Opened by PID" || ifconfig tap0 destroy 2>/dev/null || true set -o errexit echo "Starting Qemu in background..." ${qemu_bin} -m 4096M -cpu max -smp cpus=4 -M ${machine} \ ${bios} \ ${iso_boot_cli} \ -serial telnet:localhost:4444,mux=on,server,wait=off \ -monitor telnet:localhost:4445,mux=on,server,wait=off \ -display none \ -drive if=none,file=${work_dir}/${image_file},id=hd0 \ -device virtio-blk-pci,drive=hd0 \ -device virtio-net-pci,netdev=net0 \ -netdev tap,id=net0 \ -usb \ -device qemu-xhci,id=xhci \ ${usb_qemu_cli} \ -daemonize echo "Connect to guest console (telnet localhost 4444), or qemu monitor (telnet localhost 4445)" -
dhorn revised this gist
Nov 1, 2025 . 1 changed file with 93 additions and 28 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,30 @@ #!/bin/sh set -o errexit # Helper script for running FreeBSD under Qemu (multi-arch) # Downloads images/ISOs from FreeBSD master site # Maps in usb devices as desired to guest # Global constants dl_uri="https://download.freebsd.org/releases/" work_dir="." usage() { echo "Usage:" echo " $0 [-a <arm64|riscv64|amd64>] [-r <BETA|ALPHA|RELEASE>] [-u <USBDevice String>]" echo " [-t <VM|ISO>]" echo "" echo " -a will select an architecture (REQUIRED)" echo " -r will select the latest BETA/ALPHA/RELEASE version available for download" echo " -t will select a VM_IMAGE (Default) or ISO (Install from scratch) for download" echo " -u will optionally enable passthrough of specific USB device from HOST to GUEST" exit 1 } # If variable not defined, define default. r="RELEASE" t="VM" while getopts ":a:r:u:t:" opt; do case "${opt}" in a) a=${OPTARG} @@ -24,21 +38,32 @@ while getopts ":a:r:u:" opt; do u) u=${OPTARG} ;; t) t=${OPTARG} # Only support VM and ISO at the moment. [ ${t} = "VM" -o ${t} = "ISO" ] || t="VM" ;; *) usage ;; esac done shift $((OPTIND-1)) # Check for REQUIRED args if [ -z "${a}" ]; then usage fi #echo "a = ${a}" #echo "r = ${r}" #echo "u = ${u}" #echo "t = ${t}" # Check to make sure qemu is installed which qemu-system-x86_64 >/dev/null 2>&1 || pkg install -y qemu-nox11 # Handle the architecture specific variables and arguments case "${a}" in amd64) arch="amd64" @@ -64,31 +89,61 @@ case "${a}" in pkg info opensbi >/dev/null || pkg install -y opensbi pkg info u-boot-qemu-riscv64 >/dev/null || pkg install -y u-boot-qemu-riscv64 ;; esac validate-sha512() { set +o errexit [ -z "${1}" -o ! -s ${1} ] && echo "No file ${1} for hash verification" && exit 1 # We are cheating a bit and just using file globs so we don't need to pass in exact CHECKSUM filename expect_hash=$(grep ${1} CHECKSUM.SHA512* | cut -d "=" -f 2 | tr -d ' ') #echo "expect_hash: ${expect_hash}" actual_hash=$(sha512sum --quiet ${1} | tr -d ' ') #echo "actual_hash: ${actual_hash}" if [ "${expect_hash}" != "${actual_hash}" ] ; then printf "Failure validating hash on ${1}. \nExpect: ${expect_hash} \nActual: ${actual_hash}\n" exit 1 fi set -o errexit } fetch-image() { latest_version=$(curl -s ${dl_uri}VM-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | head -1 | tr -d '/') image_file="FreeBSD-${latest_version}-${archvariant}-ufs.qcow2" if [ ! -s ${image_file} ] ; then fetch "${dl_uri}VM-IMAGES/${latest_version}/${arch}/Latest/${image_file}.xz" "${dl_uri}VM-IMAGES/${latest_version}/${arch}/Latest/CHECKSUM.SHA512" validate-sha512 ${image_file}.xz unxz ${image_file}.xz qemu-img resize ${image_file} +45G fi } fetch-iso() { toplevel_version=$(curl -s ${dl_uri}ISO-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}/" | uniq | sort -gr | head -1 | tr -d '/') latest_version=$(curl -s ${dl_uri}VM-IMAGES/${loplevel_version}/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | head -1 | tr -d '/') iso_file="FreeBSD-${latest_version}-${archvariant}-bootonly.iso" iso_boot_cli="-boot d -cdrom ${iso_file}" image_file="FreeBSD-${latest_version}-${archvariant}-ufs.qcow2" if [ ! -s ${iso_file} ] ; then fetch "${dl_uri}ISO-IMAGES/${toplevel_version}/${iso_file}.xz" \ "${dl_uri}ISO-IMAGES/${toplevel_version}/CHECKSUM.SHA512-FreeBSD-${latest_version}-${archvariant}" validate-sha512 ${iso_file}.xz unxz ${iso_file}.xz fi if [ ! -s ${image_file} ] ; then qemu-img create -f qcow2 ${image_file} 45G else read -p "You selected ISO Install with an existing disk image ${image_file}. Do you wish to remove the existing file and recreate a blank disk file ? (y/n): " overwrite if [ ${overwrite} = "y" -o ${overwrite} = "Y" ] ; then rm ${image_file} qemu-img create -f qcow2 ${image_file} 45G fi fi } setup-usb-passthrough() { echo "Attempting to passthrough usb host device based on query string: ${u}" usb_map_count=$(usbconfig | grep -cie ${u}) [ ${usb_map_count} -ne 1 ] && \ @@ -103,21 +158,31 @@ if [ ! -z ${u} ] ; then #echo "usb_qemu_cli = ${usb_qemu_cli}" echo -n "In qemu monitor, you can inspect attached usb guest devices with \"info usb\" " echo "command, or delete the usb device mapping with \"device_del ${u}\"" } [ ${t} = "VM" ] && fetch-image [ ${t} = "ISO" ] && fetch-iso [ ! -z "${u}" ] && setup-usb-passthrough # Safety check. set +o errexit ps -aux | grep -v grep | grep -cq qemu-system && \ echo "Qemu is already running. Shutdown the guest, then retry." && exit 1 # Cleanup tap0 interfaces that are not in use anymore. ifconfig tap0 2>/dev/null | grep -cq -e "Opened by PID" || ifconfig tap0 destroy 2>/dev/null || true set -o errexit echo "Starting Qemu in background..." ${qemu_bin} -m 4096M -cpu max -smp cpus=4 -M ${machine} \ ${bios} \ ${iso_boot_cli} \ -serial telnet:localhost:4444,mux=on,server,wait=off \ -monitor telnet:localhost:4445,mux=on,server,wait=off \ -display none \ -drive if=none,file=${work_dir}/${image_file},id=hd0 \ -device virtio-blk-pci,drive=hd0 \ -device virtio-net-pci,netdev=net0 \ -netdev tap,id=net0 \ -usb \ -device qemu-xhci,id=xhci \ ${usb_qemu_cli} \ -daemonize echo "Connect to guest console (telnet localhost 4444), or qemu monitor (telnet localhost 4445)" -
daemonhorn revised this gist
Oct 31, 2025 . No changes.There are no files selected for viewing
-
daemonhorn revised this gist
Oct 31, 2025 . 1 changed file with 123 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,123 @@ #!/bin/sh set -o errexit mkdir -p /qemu-data cd /qemu-data usage() { echo "Usage: $0 [-a <arm64|riscv64|amd64>] [-r <BETA|ALPHA|RELEASE>] [-u <USBDevice String>]" \ 1>&2 exit 1 } # If release variable not defined, default to RELEASE r="RELEASE" while getopts ":a:r:u:" opt; do case "${opt}" in a) a=${OPTARG} [ ${a} = "arm64" -o ${a} = "riscv64" -o ${a} = "amd64" ] || usage ;; r) r=${OPTARG} # If it does not match BETA or ALPHA set to RELEASE [ ${r} = "BETA" -o ${r} = "ALPHA" ] || r="RELEASE" ;; u) u=${OPTARG} ;; *) usage ;; esac done shift $((OPTIND-1)) if [ -z "${a}" ]; then usage fi #echo "a = ${a}" #echo "r = ${r}" #echo "u = ${u}" case "${a}" in amd64) arch="amd64" archvariant="amd64" bios="-bios /usr/local/share/edk2-qemu/QEMU_UEFI-x86_64.fd" qemu_bin="qemu-system-x86_64" machine="q35" pkg info edk2-qemu-x64 >/dev/null || pkg install -y edk2-qemu-x64 ;; arm64) arch="aarch64" archvariant="arm64-${arch}" bios="-bios edk2-aarch64-code.fd" qemu_bin="qemu-system-aarch64" machine="virt" ;; riscv64) arch="riscv64" archvariant="riscv-${arch}" bios="-bios /usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf -kernel /usr/local/share/u-boot/u-boot-qemu-riscv64/u-boot.bin" qemu_bin="qemu-system-riscv64" machine="virt" pkg info opensbi >/dev/null || pkg install -y opensbi pkg info u-boot-qemu-riscv64 >/dev/null || pkg install -y u-boot-qemu-riscv64 ;; *) usage ;; esac fetch-image() { latest_version=$(curl -s https://download.freebsd.org/releases/VM-IMAGES/ \ | grep -E -o -e "[0-9.]{3}[0-9]{1}-${r}[0-9]*/" | uniq | sort -gr | head -1 | tr -d '/') image_file="FreeBSD-${latest_version}-${archvariant}-ufs.qcow2" if [ ! -s ${image_file} ] ; then fetch "https://download.freebsd.org/releases/VM-IMAGES/${latest_version}/${arch}/Latest/${image_file}.xz" unxz ${image_file}.xz qemu-img resize ${image_file} +45G fi } fetch-image # Safety check. ps -aux | grep -v grep | grep -cq qemu-system && \ echo "Qemu is already running. Shutdown the guest(s), then retry." && exit 1 # if ${u} is set, use it as a string to match on for usb passthrough to guest. if [ ! -z ${u} ] ; then echo "Attempting to passthrough usb host device based on query string: ${u}" usb_map_count=$(usbconfig | grep -cie ${u}) [ ${usb_map_count} -ne 1 ] && \ echo "Total devices matched: ${usb_map_count} is not equal to 1, please refine." && \ usbconfig && exit 1 usb_map=$(usbconfig | grep -ie ${u} | grep -E -o -e "[0-9]+\.[0-9]+") #echo "usb_map: ${usb_map}" usb_map_bus=$(echo ${usb_map} | grep -E -o -e "^[0-9]+") usb_map_addr=$(echo ${usb_map} | grep -E -o -e "[0-9]+$") usb_qemu_cli="-device usb-host,hostbus=${usb_map_bus},hostaddr=${usb_map_addr},id=${u}" echo "Mapping usb device $(usbconfig | grep -ie ${u}) into the guest." #echo "usb_qemu_cli = ${usb_qemu_cli}" echo -n "In qemu monitor, you can inspect attached usb guest devices with \"info usb\" " echo "command, or delete the usb device mapping with \"device_del ${u}\"" fi # Cleanup tap0 interfaces that are not in use anymore. ifconfig tap0 2>/dev/null | grep -cq -e "Opened by PID" || ifconfig tap0 destroy 2>/dev/null || true echo "Starting Qemu in background..." ${qemu_bin} -m 4096M -cpu max -smp cpus=4 -M ${machine} \ ${bios} \ -serial telnet:localhost:4444,mux=on,server,wait=off \ -monitor telnet:localhost:4445,mux=on,server,wait=off \ -display none \ -drive if=none,file=/qemu-data/${image_file},id=hd0 \ -device virtio-blk-pci,drive=hd0 \ -device virtio-net-pci,netdev=net0 \ -netdev tap,id=net0 \ -usb \ -device qemu-xhci,id=xhci \ ${usb_qemu_cli} \ -daemonize echo "Connect to guest console (telnet localhost 4444), or qemu monitor (telnet localhost 4445)" -
daemonhorn revised this gist
Oct 29, 2025 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,9 +15,10 @@ This Quickstart receipe for Qemu assumes a recent FreeBSD release (stable/13 or ``` mkdir /qemu-data cd /qemu-data latest_version=$(curl -s https://download.freebsd.org/releases/VM-IMAGES/ | grep -E -o -e '[0-9.]{3}[0-9]{1}-RELEASE' | uniq | sort -gr | head -1) fetch https://download.freebsd.org/releases/VM-IMAGES/${latest_version}/aarch64/Latest/${latest_version}-arm64-aarch64.qcow2.xz unxz ${latest_version}-arm64-aarch64.qcow2.xz qemu-img resize ${latest_version}-arm64-aarch64.qcow2 +40G ``` 2. Configure networking bridge for use by Qemu guests (replace `vmx0` with host network interface name). *Note: 802.11 Wireless (Wi-Fi) host NICs usually will have issues with bridging, so stick with wired ethernet* ``` -
daemonhorn revised this gist
Sep 16, 2025 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,7 +53,9 @@ qemu-system-riscv64 -machine virt -smp 4 -m 4096 -nographic \ -bios /usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf \ -kernel /usr/local/share/u-boot/u-boot-qemu-riscv64/u-boot.bin \ -drive file=/qemu-data/FreeBSD-15.0-PRERELEASE-riscv-riscv64-ufs.qcow2,format=qcow2,id=hd0,if=none \ -device virtio-blk-device,drive=hd0 \ -device virtio-net-device,netdev=net0 \ -netdev tap,id=net0 ``` 5. Login as `root` with no password, immediately set new password using `passwd`. (See below for accessing guest console via telnet) 6. Create users using `adduser`, start sshd using `service sshd enable && service sshd start` -
daemonhorn renamed this gist
Sep 14, 2025 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
daemonhorn revised this gist
Sep 14, 2025 . 1 changed file with 194 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,194 @@ # Intro This Quickstart receipe for Qemu assumes a recent FreeBSD release (stable/14 or newer), and provides an example configuration for running **riscv64 FreeBSD guest** on an **amd64 FreeBSD Host**. Concepts can be applied to other architectures as desired, but syntax and capabilities will vary. - [Dependancies](#Dependancies) - [Getting Started](#Getting-Started) - [Example Qemu guest startup script](#Example-qemu-startup-script) <!-- toc --> ## Dependancies * Install qemu `pkg install qemu` or `pkg instal qemu-nox11`. Latest pre-built package release as of this writeup is 10.0.x * Sufficient disk space (50+GB) on a mounted FreeBSD Host disk (e.g.: `/qemu-data` in this example) * Install `opensbi` and `u-boot-qemu-riscv64` ``` pkg install opensbi u-boot-qemu-riscv64 ``` * Network environment that allows for multiple mac addresses on one switch port (or vswitch port configuration) for bridging mode ## Getting Started 1. Download desired qcow2 image from FreeBSD site, decompress, and resize (to increase by desired size. Example shows adding 40GB): ``` mkdir /qemu-data cd /qemu-data fetch https://download.freebsd.org/snapshots/VM-IMAGES/15.0-PRERELEASE/riscv64/Latest/FreeBSD-15.0-PRERELEASE-riscv-riscv64-ufs.qcow2.xz unxz FreeBSD-15*.xz qemu-img resize FreeBSD-15.0-PRERELEASE-riscv-riscv64-ufs.qcow2 +40G ``` 2. Configure networking bridge for use by Qemu guests (replace `vmx0` with host network interface name). *Note: 802.11 Wireless (Wi-Fi) host NICs usually will have issues with bridging, so stick with wired ethernet* ``` ifconfig bridge0 create ifconfig bridge0 addm vmx0 edge vmx0 up ``` Make permanant in `/etc/rc.conf` by adding: ``` ifconfig_bridge0="addm vmx0 edge vmx0 up" cloned_interfaces="bridge0" ``` 3. Modify Qemu network ifup/ifdown scripts `/usr/local/etc/qemu-if[up|down]` * Example shown is designed to handle bridge and tap devices automatically as the guest is started/stopped.<br> `vi /usr/local/etc/qemu-ifup` ``` #!/bin/sh ifconfig bridge0 addm $1 up ifconfig $1 up ``` `vi /usr/local/etc/qemu-ifdown` ``` #!/bin/sh ifconfig $1 down ifconfig bridge0 deletem $1 ``` 4. Boot Qemu with the pre-installed qcow2 image (text mode). Alternatively, see shell script example below. ``` qemu-system-riscv64 -machine virt -smp 4 -m 4096 -nographic \ -bios /usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf \ -kernel /usr/local/share/u-boot/u-boot-qemu-riscv64/u-boot.bin \ -drive file=/qemu-data/FreeBSD-15.0-PRERELEASE-riscv-riscv64-ufs.qcow2,format=qcow2,id=hd0,if=none \ -device virtio-blk-device,drive=hd0 ``` 5. Login as `root` with no password, immediately set new password using `passwd`. (See below for accessing guest console via telnet) 6. Create users using `adduser`, start sshd using `service sshd enable && service sshd start` 7. Edit configuration file in `/etc/rc.conf` and give a hostname. Verify other settings. 8. Use the new guest VM of Arm64(aarch64). Since this is now a higher tier variant, there will be pre-built packages for use with `pkg` utility as well as all of the other normal FreeBSD base things. Package builds for betas may lag ISO releases. ## Example Qemu startup script This example `sh` script provides an arm64/aarch64 qemu guest launch(`/qemu-data/start_guest.sh`): * Command line parameter(optional) to perform qemu **host->guest USB passthrough** based upon usb device string * Supports any USB device mapping from the Host to Guest based upon detected device seen by `usbconfig list` * Supports USB mapping via nested virtualization/emulation (VMWare VM of FreeBSD amd64 hosting Qemu VM of FreeBSD aarch64) * e.g.: `sh /qemu-data/start_guest.sh fido` will check the usb device list for a FIDO USB device, and passthrough that device to the guest on startup. Any device string that matches a substring of `usbconfig` output should work (e.g. `ugen0.4` or `fido` or `Mouse` or `Yubikey`) * EFI firmware image from qemu-aarch64 `-bios edk2-aarch64-code.fd` (loads from `/usr/local/share/qemu/` by default) * Simple Example telnet console for **guest** (localhost port **4444**) and **qemu monitor** (localhost port **4445**) * tap device cleanup (if not in use) * Error checking to ensure that qemu is not already running. * Machine Configuration: CPU = 4, RAM = 4GB (Customize as desired) * Adjust `FreeBSD-14.0-BETA4-arm64-aarch64.qcow2` disk image name to match applicable qcow2 image desired. ```shell #!/bin/sh # Safety check. ps -aux | grep -v grep | grep -cq qemu-system && \ echo "Qemu is already running. Shutdown the guest(s), then retry." && exit 1 # if arg(1) is set, use it as a string to match on for usb passthrough to guest. if [ ! -z ${1} ] ; then echo "Attempting to passthrough usb host device based on query string: ${1}" usb_map_count=$(usbconfig | grep -cie ${1}) [ ${usb_map_count} -ne 1 ] && \ echo "Total devices matched: ${usb_map_count} is not equal to 1, please refine." && \ usbconfig && exit 1 usb_map=$(usbconfig | grep -ie ${1} | grep -o -e [0-9]\.[0-9]) usb_map_bus=$(echo ${usb_map} | grep -o -e ^[0-9]) usb_map_addr=$(echo ${usb_map} | grep -o -e [0-9]$) usb_qemu_cli="-device usb-host,hostbus=${usb_map_bus},hostaddr=${usb_map_addr},id=${1}" echo "Mapping usb device $(usbconfig | grep -ie ${1}) into the guest." echo -n "In qemu monitor, you can inspect attached usb guest devices with \"info usb\" " echo "command, or delete the usb device mapping with \"device_del ${1}\"" fi # Cleanup tap0 interfaces that are not in use anymore. ifconfig tap0 2>/dev/null | grep -cq -e "Opened by PID" || ifconfig tap0 destroy 2>/dev/null echo "Starting Qemu in background..." qemu-system-aarch64 -m 4096M -cpu max -smp cpus=4 -M virt \ -bios edk2-aarch64-code.fd \ -serial telnet:localhost:4444,mux=on,server,wait=off \ -monitor telnet:localhost:4445,mux=on,server,wait=off \ -display none \ -drive if=none,file=/qemu-data/FreeBSD-14.0-BETA4-arm64-aarch64.qcow2,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -device virtio-net-device,netdev=net0 \ -netdev tap,id=net0 \ -usb \ -device qemu-xhci,id=xhci \ ${usb_qemu_cli} \ -daemonize echo "Connect to guest console (telnet localhost 4444), or qemu monitor (telnet localhost 4445)" ``` ### Access Qemu guest console Connect over telnet protocol from localhost to the **guest console**. *Note: Use Ctrl+] to get a telnet prompt, then quit to exit telnet* ``` telnet localhost 4444 ``` ### Access Qemu monitor console Connect over telnet protocol from localhost to the **qemu monitor**. *Note: Use Ctrl+] to get a telnet prompt, then `quit` to exit telnet. Typing `quit` at monitor `(qemu)` prompt non-gracefully kills qemu guest.* ``` telnet localhost 4445 ``` #### Example monitor commands See https://qemu-project.gitlab.io/qemu/system/monitor.html for complete details. * `system_reset` - Reboot the vm * `system_pwerdown` - Send Powerdown event (may require qemu-guestd) * `device_add` `usb-host,hostbus=xxx,hostaddr=yyy,id=friendlyname` * `device_del` `id` (where `id`=friendlyname) * `info status` to see if the vm is running/paused * `info cpu` to check how many cpus are running/pids * `info usb` or `info usbhost` for information on usb guest/host devices respectively. * `info network` for network configuration and mac address * `info chardev` for serial/character device configuration. #### Example Fresh Install from ISO 1. Prepare to install: * Download iso file (example is 13.2-RELEASE-AARCH64-bootonly variant ) ``` fetch https://download.freebsd.org/releases/ISO-IMAGES/13.2/FreeBSD-13.2-RELEASE-arm64-aarch64-bootonly.iso ``` * Create new blank drive image using `qemu-img create` ``` qemu-img create -f qcow2 FreeBSD-13.2-Release.qcow2 50G ``` * Make modifications to qemu command line (change/addition from example above) to attach new qcow2 disk and virtual cdrom for ISO ``` -cdrom /qemu-data/FreeBSD-13.2-RELEASE-arm64-aarch64-bootonly.iso \ -drive if=none,file=/qemu-data/FreeBSD-13.2-Release.qcow2,id=hd0 \ ``` * Start new amd64 aarch64 13.2 guest and start installation by following the prompts. ``` sh /qemu-data/start_guest.sh telnet localhost 4444 ``` * After installation is complete and system reboots, you can remove the `-cdrom...` line from the shell script as desired. ### Yubikey usb host->guest passthrough with hidraw(4) usb driver - Untested if only guest has hidraw(4) kernel module loaded. (*should* work) - Seems to require `qemu-xhci` virtual usb device, ehci variant was problematic for unknown reason. - Works if both host and guest have enabled hidraw kernel module and sysctl. Usually second device `/dev/hidraw1` is correct, depends on `kldstat -v` including `hkbd` or not. Example `/boot/loader.conf`: ``` hidraw_load="YES" hkbd_load="YES" hw.usb.usbhid.enable="1" ``` - Requires patches to libfido (included in 14.0-RELEASE, and stable after 9/23/23) - libfido2 1.13 for automatic detection - Manual workaround for older OS code is to pass device entry explicitly `ssh-keygen -v -K -O device=/dev/hidraw1` - Using string `fido` or `yubikey` for device selection and passthrough and above script works. ## TODO - [X] Write a detection script to check if there is a pid attached, and destroy if not: `ifconfig tap0 | grep -cq -e "Opened by PID" || ifconfig tap0 destroy` - [X] Document USB Yubikey passthrough from ESXi->FreeBSD VM(amd64)->FreeBSD QEMU(aarch64) - [X] Document ISO mapping syntax for install media - [X] Document Fresh aarch64 install via 13.2 bootonly ISO - [ ] Document qemu-guest-agent install and configuration - [ ] Document u2f virtual device (emulated and passthrough) - ? - needs investigation - [ ] Look into porting https://github.com/Agnoctopus/libu2f-emu into FreeBSD to enable in Qemu - [ ] Look into other qemu feature build dependancies and meson build flags - [ ] Determine why attempting to destroy tapX interface using `ifconfig tap0 destroy` format hangs instead of erroring out when there is still a pid associated with the interface. ### References * Alternate aarch64 UEFI Firmware: * Works: * https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4989/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd (9/22/23) * https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4480/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd (older) * FreeBSD emulators/qemu 8.1 port firmware: `edk2-aarch64-code.fd` automatically loaded from `/usr/local/share/qemu/`. * Does *NOT* work: * https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd * https://bugs.launchpad.net/qemu/+bug/1849644 * https://www.qemu.org/docs/master/system/devices/usb.html#connecting-usb-devices * https://unix.stackexchange.com/questions/452934/can-i-pass-through-a-usb-port-via-qemu-command-line * https://getlabsdone.com/4-easy-step-to-install-centos-on-kvm/ * http://cdn.kernel.org/pub/linux/kernel/people/will/docs/qemu/qemu-arm64-howto.html -
daemonhorn revised this gist
Oct 3, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -63,11 +63,11 @@ This example `sh` script provides an arm64/aarch64 qemu guest launch(`/qemu-data * Supports any USB device mapping from the Host to Guest based upon detected device seen by `usbconfig list` * Supports USB mapping via nested virtualization/emulation (VMWare VM of FreeBSD amd64 hosting Qemu VM of FreeBSD aarch64) * e.g.: `sh /qemu-data/start_guest.sh fido` will check the usb device list for a FIDO USB device, and passthrough that device to the guest on startup. Any device string that matches a substring of `usbconfig` output should work (e.g. `ugen0.4` or `fido` or `Mouse` or `Yubikey`) * EFI firmware image from qemu-aarch64 `-bios edk2-aarch64-code.fd` (loads from `/usr/local/share/qemu/` by default) * Simple Example telnet console for **guest** (localhost port **4444**) and **qemu monitor** (localhost port **4445**) * tap device cleanup (if not in use) * Error checking to ensure that qemu is not already running. * Machine Configuration: CPU = 4, RAM = 4GB (Customize as desired) * Adjust `FreeBSD-14.0-BETA4-arm64-aarch64.qcow2` disk image name to match applicable qcow2 image desired. ```shell #!/bin/sh -
daemonhorn revised this gist
Oct 3, 2023 . 1 changed file with 8 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ This Quickstart receipe for Qemu assumes a recent FreeBSD release (stable/13 or <!-- toc --> ## Dependancies * Install qemu `pkg install qemu` or `pkg instal qemu-nox11`. Latest pre-built package release as of this writeup is 8.1.0 * Sufficient disk space (50+GB) on a mounted FreeBSD Host disk (e.g.: `/qemu-data` in this example) * Network environment that allows for multiple mac addresses on one switch port (or vswitch port configuration) for bridging mode @@ -19,11 +19,7 @@ fetch https://download.freebsd.org/releases/VM-IMAGES/14.0-BETA4/aarch64/Latest/ unxz FreeBSD-14.0-BETA4-arm64-aarch64.qcow2.xz qemu-img resize FreeBSD-14.0-BETA4-arm64-aarch64.qcow2 +40G ``` 2. Configure networking bridge for use by Qemu guests (replace `vmx0` with host network interface name). *Note: 802.11 Wireless (Wi-Fi) host NICs usually will have issues with bridging, so stick with wired ethernet* ``` ifconfig bridge0 create ifconfig bridge0 addm vmx0 edge vmx0 up @@ -33,7 +29,7 @@ Make permanant in `/etc/rc.conf` by adding: ifconfig_bridge0="addm vmx0 edge vmx0 up" cloned_interfaces="bridge0" ``` 3. Modify Qemu network ifup/ifdown scripts `/usr/local/etc/qemu-if[up|down]` * Example shown is designed to handle bridge and tap devices automatically as the guest is started/stopped.<br> `vi /usr/local/etc/qemu-ifup` ``` @@ -47,11 +43,7 @@ ifconfig $1 up ifconfig $1 down ifconfig bridge0 deletem $1 ``` 4. Boot Qemu with the pre-installed qcow2 image (text mode). Alternatively, see shell script example below. ``` qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt \ -bios edk2-aarch64-code.fd -serial telnet:localhost:4444,mux=on,server,wait=off -vnc :0,websocket=on \ @@ -60,10 +52,10 @@ qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt \ -device virtio-net-device,netdev=net0 \ -netdev tap,id=net0 ``` 5. Login as `root` with no password, immediately set new password using `passwd`. (See below for accessing guest console via telnet) 6. Create users using `adduser`, start sshd using `service sshd enable && service sshd start` 7. Edit configuration file in `/etc/rc.conf` and give a hostname. Verify other settings. 8. Use the new guest VM of Arm64(aarch64). Since this is now a higher tier variant, there will be pre-built packages for use with `pkg` utility as well as all of the other normal FreeBSD base things. Package builds for betas may lag ISO releases. ## Example Qemu startup script This example `sh` script provides an arm64/aarch64 qemu guest launch(`/qemu-data/start_guest.sh`): -
daemonhorn revised this gist
Oct 2, 2023 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,9 +15,9 @@ This Quickstart receipe for Qemu assumes a recent FreeBSD release (stable/13 or ``` mkdir /qemu-data cd /qemu-data fetch https://download.freebsd.org/releases/VM-IMAGES/14.0-BETA4/aarch64/Latest/FreeBSD-14.0-BETA4-arm64-aarch64.qcow2.xz unxz FreeBSD-14.0-BETA4-arm64-aarch64.qcow2.xz qemu-img resize FreeBSD-14.0-BETA4-arm64-aarch64.qcow2 +40G ``` 2. Install qemu (or qemu-nox11 as desired) ``` @@ -55,7 +55,7 @@ chmod +x /usr/local/etc/qemu_if* ``` qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt \ -bios edk2-aarch64-code.fd -serial telnet:localhost:4444,mux=on,server,wait=off -vnc :0,websocket=on \ -drive if=none,file=/qemu_data/FreeBSD-14.0-BETA4-arm64-aarch64.qcow2,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -device virtio-net-device,netdev=net0 \ -netdev tap,id=net0 @@ -76,7 +76,7 @@ This example `sh` script provides an arm64/aarch64 qemu guest launch(`/qemu-data * tap device cleanup (if not in use) * Error checking to ensure that qemu is not already running. * Machine Configuration: CPU = 4, RAM = 4GB * Adjust `FreeBSD-14.0-BETA4-arm64-aarch64.qcow2` disk image name to match applicable qcow2 image desired. ```shell #!/bin/sh # Safety check. @@ -105,7 +105,7 @@ qemu-system-aarch64 -m 4096M -cpu max -smp cpus=4 -M virt \ -serial telnet:localhost:4444,mux=on,server,wait=off \ -monitor telnet:localhost:4445,mux=on,server,wait=off \ -display none \ -drive if=none,file=/qemu-data/FreeBSD-14.0-BETA4-arm64-aarch64.qcow2,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -device virtio-net-device,netdev=net0 \ -netdev tap,id=net0 \ -
daemonhorn revised this gist
Sep 28, 2023 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,11 +19,11 @@ fetch https://download.freebsd.org/releases/VM-IMAGES/14.0-BETA3/aarch64/Latest/ unxz FreeBSD-14.0-BETA3-arm64-aarch64.qcow2.xz qemu-img resize FreeBSD-14.0-BETA3-arm64-aarch64.qcow2 +40G ``` 2. Install qemu (or qemu-nox11 as desired) ``` pkg install qemu ``` 3. Configure networking bridge for use by Qemu guests (replace `vmx0` with host network interface name). *Note: 802.11 Wireless (Wi-Fi) host NICs usually will have issues with bridging, so stick with wired ethernet* ``` ifconfig bridge0 create ifconfig bridge0 addm vmx0 edge vmx0 up @@ -124,7 +124,7 @@ telnet localhost 4444 ``` ### Access Qemu monitor console Connect over telnet protocol from localhost to the **qemu monitor**. *Note: Use Ctrl+] to get a telnet prompt, then `quit` to exit telnet. Typing `quit` at monitor `(qemu)` prompt non-gracefully kills qemu guest.* ``` telnet localhost 4445 ``` @@ -179,8 +179,10 @@ hw.usb.usbhid.enable="1" - [X] Document ISO mapping syntax for install media - [X] Document Fresh aarch64 install via 13.2 bootonly ISO - [ ] Document qemu-guest-agent install and configuration - [ ] Document u2f virtual device (emulated and passthrough) - ? - needs investigation - [ ] Look into porting https://github.com/Agnoctopus/libu2f-emu into FreeBSD to enable in Qemu - [ ] Look into other qemu feature build dependancies and meson build flags - [ ] Determine why attempting to destroy tapX interface using `ifconfig tap0 destroy` format hangs instead of erroring out when there is still a pid associated with the interface. ### References * Alternate aarch64 UEFI Firmware: -
daemonhorn revised this gist
Sep 28, 2023 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -105,7 +105,7 @@ qemu-system-aarch64 -m 4096M -cpu max -smp cpus=4 -M virt \ -serial telnet:localhost:4444,mux=on,server,wait=off \ -monitor telnet:localhost:4445,mux=on,server,wait=off \ -display none \ -drive if=none,file=/qemu-data/FreeBSD-14.0-BETA3-arm64-aarch64.qcow2,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -device virtio-net-device,netdev=net0 \ -netdev tap,id=net0 \ @@ -152,12 +152,12 @@ qemu-img create -f qcow2 FreeBSD-13.2-Release.qcow2 50G ``` * Make modifications to qemu command line (change/addition from example above) to attach new qcow2 disk and virtual cdrom for ISO ``` -cdrom /qemu-data/FreeBSD-13.2-RELEASE-arm64-aarch64-bootonly.iso \ -drive if=none,file=/qemu-data/FreeBSD-13.2-Release.qcow2,id=hd0 \ ``` * Start new amd64 aarch64 13.2 guest and start installation by following the prompts. ``` sh /qemu-data/start_guest.sh telnet localhost 4444 ``` * After installation is complete and system reboots, you can remove the `-cdrom...` line from the shell script as desired. -
daemonhorn revised this gist
Sep 24, 2023 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -193,4 +193,5 @@ hw.usb.usbhid.enable="1" * https://bugs.launchpad.net/qemu/+bug/1849644 * https://www.qemu.org/docs/master/system/devices/usb.html#connecting-usb-devices * https://unix.stackexchange.com/questions/452934/can-i-pass-through-a-usb-port-via-qemu-command-line * https://getlabsdone.com/4-easy-step-to-install-centos-on-kvm/ * http://cdn.kernel.org/pub/linux/kernel/people/will/docs/qemu/qemu-arm64-howto.html -
daemonhorn revised this gist
Sep 24, 2023 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -183,10 +183,13 @@ hw.usb.usbhid.enable="1" - [ ] Determine why attempting to destroy tapX interface using `ifconfig tap0 destroy` format hangs instead of erroring out when there is still a pid associated with the interrface. ### References * Alternate aarch64 UEFI Firmware: * Works: * https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4989/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd (9/22/23) * https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4480/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd (older) * FreeBSD emulators/qemu 8.1 port firmware: `edk2-aarch64-code.fd` automatically loaded from `/usr/local/share/qemu/`. * Does *NOT* work: * https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd * https://bugs.launchpad.net/qemu/+bug/1849644 * https://www.qemu.org/docs/master/system/devices/usb.html#connecting-usb-devices * https://unix.stackexchange.com/questions/452934/can-i-pass-through-a-usb-port-via-qemu-command-line -
daemonhorn revised this gist
Sep 24, 2023 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,23 +33,23 @@ Make permanant in `/etc/rc.conf` by adding: ifconfig_bridge0="addm vmx0 edge vmx0 up" cloned_interfaces="bridge0" ``` 4. Create Qemu network ifup/ifdown scripts `/usr/local/etc/qemu-if[up|down]` * Example shown is designed to handle bridge and tap devices automatically as the guest is started/stopped.<br> `vi /usr/local/etc/qemu-ifup` ``` #!/bin/sh ifconfig bridge0 addm $1 up ifconfig $1 up ``` `vi /usr/local/etc/qemu-ifdown` ``` #!/bin/sh ifconfig $1 down ifconfig bridge0 deletem $1 ``` 5. Enable the scripts to be directly executed by root user from qemu using: ``` chmod +x /usr/local/etc/qemu_if* ``` 6. Boot Qemu with the pre-installed qcow2 image (text mode) ``` @@ -58,7 +58,7 @@ qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt \ -drive if=none,file=/qemu_data/FreeBSD-14.0-BETA3-arm64-aarch64.qcow2,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -device virtio-net-device,netdev=net0 \ -netdev tap,id=net0 ``` 7. Login as `root` with no password, immediately set new password using `passwd`. (See below for accessing guest console via telnet) 8. Create users using `adduser`, start sshd using `service sshd enable && service sshd start` @@ -72,7 +72,7 @@ This example `sh` script provides an arm64/aarch64 qemu guest launch(`/qemu-data * Supports USB mapping via nested virtualization/emulation (VMWare VM of FreeBSD amd64 hosting Qemu VM of FreeBSD aarch64) * e.g.: `sh /qemu-data/start_guest.sh fido` will check the usb device list for a FIDO USB device, and passthrough that device to the guest on startup. Any device string that matches a substring of `usbconfig` output should work (e.g. `ugen0.4` or `fido` or `Mouse` or `Yubikey`) * EFI firmware image from qemu-aarch64 `-bios edk2-aarch64-code.fd` * Simple Example telnet console for **guest** (localhost port **4444**) and **qemu monitor** (localhost port **4445**) * tap device cleanup (if not in use) * Error checking to ensure that qemu is not already running. * Machine Configuration: CPU = 4, RAM = 4GB @@ -108,7 +108,7 @@ qemu-system-aarch64 -m 4096M -cpu max -smp cpus=4 -M virt \ -drive if=none,file=/data/FreeBSD-14.0-BETA3-arm64-aarch64.qcow2,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -device virtio-net-device,netdev=net0 \ -netdev tap,id=net0 \ -usb \ -device qemu-xhci,id=xhci \ ${usb_qemu_cli} \ -
daemonhorn revised this gist
Sep 24, 2023 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -164,7 +164,12 @@ telnet localhost 4444 ### Yubikey usb host->guest passthrough with hidraw(4) usb driver - Untested if only guest has hidraw(4) kernel module loaded. (*should* work) - Seems to require `qemu-xhci` virtual usb device, ehci variant was problematic for unknown reason. - Works if both host and guest have enabled hidraw kernel module and sysctl. Usually second device `/dev/hidraw1` is correct, depends on `kldstat -v` including `hkbd` or not. Example `/boot/loader.conf`: ``` hidraw_load="YES" hkbd_load="YES" hw.usb.usbhid.enable="1" ``` - Requires patches to libfido (included in 14.0-RELEASE, and stable after 9/23/23) - libfido2 1.13 for automatic detection - Manual workaround for older OS code is to pass device entry explicitly `ssh-keygen -v -K -O device=/dev/hidraw1` - Using string `fido` or `yubikey` for device selection and passthrough and above script works. @@ -184,4 +189,5 @@ telnet localhost 4444 * FreeBSD emulators/qemu 8.1 port firmware: `edk2-aarch64-code.fd` automatically loaded from `/usr/local/share/qemu/`. * https://bugs.launchpad.net/qemu/+bug/1849644 * https://www.qemu.org/docs/master/system/devices/usb.html#connecting-usb-devices * https://unix.stackexchange.com/questions/452934/can-i-pass-through-a-usb-port-via-qemu-command-line * https://getlabsdone.com/4-easy-step-to-install-centos-on-kvm/ -
daemonhorn revised this gist
Sep 24, 2023 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -161,7 +161,14 @@ sh /data/start_guest.sh telnet localhost 4444 ``` * After installation is complete and system reboots, you can remove the `-cdrom...` line from the shell script as desired. ### Yubikey usb host->guest passthrough with hidraw(4) usb driver - Untested if only guest has hidraw(4) kernel module loaded. (*should* work) - Seems to require `qemu-xhci` virtual usb device, ehci variant was problematic for unknown reason. - Works if both host and guest have enabled. Usually second device `/dev/hidraw1` is correct, depends on `kldstat -v` including `hkbd` or not. - Requires patches to libfido (included in 14.0-RELEASE, and stable after 9/23/23) - libfido2 1.13 for automatic detection - Manual workaround for older OS code is to pass device entry explicitly `ssh-keygen -v -K -O device=/dev/hidraw1` - Using string `fido` or `yubikey` for device selection and passthrough and above script works. ## TODO - [X] Write a detection script to check if there is a pid attached, and destroy if not: `ifconfig tap0 | grep -cq -e "Opened by PID" || ifconfig tap0 destroy` - [X] Document USB Yubikey passthrough from ESXi->FreeBSD VM(amd64)->FreeBSD QEMU(aarch64) - [X] Document ISO mapping syntax for install media @@ -174,7 +181,7 @@ telnet localhost 4444 * Alternate aarch64 UEFI Firmware (works): * https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4989/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd (9/22/23) * https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4480/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd (older) * FreeBSD emulators/qemu 8.1 port firmware: `edk2-aarch64-code.fd` automatically loaded from `/usr/local/share/qemu/`. * https://bugs.launchpad.net/qemu/+bug/1849644 * https://www.qemu.org/docs/master/system/devices/usb.html#connecting-usb-devices * https://unix.stackexchange.com/questions/452934/can-i-pass-through-a-usb-port-via-qemu-command-line -
daemonhorn revised this gist
Sep 24, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -124,7 +124,7 @@ telnet localhost 4444 ``` ### Access Qemu monitor console Connect over telnet protocol from localhost to the **qemu monitor**. *Note: Use Ctrl+] to get a telnet prompt, then `quit` to exit telnet. Typing `quit` at monitor `(qemu)` prompt kills qemu guest.* ``` telnet localhost 4445 ``` -
daemonhorn revised this gist
Sep 24, 2023 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -171,7 +171,10 @@ telnet localhost 4444 - [ ] Determine why attempting to destroy tapX interface using `ifconfig tap0 destroy` format hangs instead of erroring out when there is still a pid associated with the interrface. ### References * Alternate aarch64 UEFI Firmware (works): * https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4989/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd (9/22/23) * https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4480/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd (older) * FreeBSD emulators/qemu 8.1 port firmware: `edk2-aarch64-code.fd` automatically loaded from `/usr/local/share/qemu/ * https://bugs.launchpad.net/qemu/+bug/1849644 * https://www.qemu.org/docs/master/system/devices/usb.html#connecting-usb-devices * https://unix.stackexchange.com/questions/452934/can-i-pass-through-a-usb-port-via-qemu-command-line -
daemonhorn revised this gist
Sep 24, 2023 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -162,13 +162,13 @@ telnet localhost 4444 ``` * After installation is complete and system reboots, you can remove the `-cdrom...` line from the shell script as desired. ### TODO - [X] Write a detection script to check if there is a pid attached, and destroy if not: `ifconfig tap0 | grep -cq -e "Opened by PID" || ifconfig tap0 destroy` - [X] Document USB Yubikey passthrough from ESXi->FreeBSD VM(amd64)->FreeBSD QEMU(aarch64) - [X] Document ISO mapping syntax for install media - [X] Document Fresh aarch64 install via 13.2 bootonly ISO - [ ] Document qemu-guest-agent install and configuration - [ ] Document u2f virtual device (emulated and passthrough) - amd64 guest only ? - needs investigation - [ ] Determine why attempting to destroy tapX interface using `ifconfig tap0 destroy` format hangs instead of erroring out when there is still a pid associated with the interrface. ### References * Alternate UEFI Firmware (works): https://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/4989/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd
NewerOlder