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
9 changes: 5 additions & 4 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ Required parameters:
* x86
* x86_64

-k | --kbuild-folder:
The kernel build folder, as an absolute path or relative path
from wherever the script is being run. This is wherever the
compiled vmlinux image lives, not the architecture's boot folder.
-k | --kernel-location:
The kernel location, which can either be the kernel image itself or
the root of the kernel build output folder. Either option can be
passed as an absolute path or relative path from wherever the script
is being run.

Optional parameters:
-d | --debug:
Expand Down
25 changes: 15 additions & 10 deletions boot-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function parse_parameters() {
INTERACTIVE=true
;;

-k | --kbuild-folder)
shift && KBUILD_DIR=${1}
-k | --kernel-location)
shift && KERNEL_LOCATION=${1}
;;

-t | --timeout)
Expand All @@ -74,13 +74,10 @@ function parse_parameters() {
function sanity_check() {
# Kernel build folder and architecture are required paramters
[[ -z ${ARCH} ]] && die "Architecture ('-a') is required but not specified!"
[[ -z ${KBUILD_DIR} ]] && die "Kernel build folder ('-k') is required but not specified!"
[[ -z ${KERNEL_LOCATION} ]] && die "Kernel image or kernel build folder ('-k') is required but not specified!"

# KBUILD_DIR could be a relative path; turn it into an absolute one with readlink
KBUILD_DIR=$(readlink -f "${KBUILD_DIR}")

# Let the user know if the kernel build folder does not exist
[[ -d ${KBUILD_DIR} ]] || die "${KBUILD_DIR} does not exist!"
# KERNEL_LOCATION could be a relative path; turn it into an absolute one with readlink
KERNEL_LOCATION=$(readlink -f "${KERNEL_LOCATION}")

# Make sure zstd is install
checkbin zstd
Expand Down Expand Up @@ -223,8 +220,16 @@ function setup_qemu_args() {
esac
checkbin "${QEMU[*]}"

[[ ${KIMAGE:=zImage} == "vmlinux" ]] || BOOT_DIR=arch/${ARCH}/boot/
KERNEL=${KBUILD_DIR}/${BOOT_DIR}${KIMAGE}
# If '-k' is an path that ends in the kernel image, we can just use it directly
if [[ ${KERNEL_LOCATION##*/} = "${KIMAGE:=zImage}" ]]; then

@nickdesaulniers nickdesaulniers Jan 8, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is ##*/?


Do none of the existing arch's specify a KIMAGE of zImage? (I assume there's probably a list of possible image names, since the compression scheme is encoded in the name).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

##*/ is bash parameter substitution for basename essentially (remove the last / and everything before it): https://wiki.bash-hackers.org/syntax/pe#from_the_beginning

No, because zImage used to be the most common image name. All of ARCH=arm uses it and 32-bit PowerPC used it prior to 2a68826). I should probably just add KIMAGE to all of the arm32 switches to avoid that cryptic assignment but I do not feel strongly about it.

KERNEL=${KERNEL_LOCATION}
# If not though, we need to find it based on the kernel build directory
else
# If the image is an uncompressed vmlinux, it is in the root of the build folder
# Otherwise, it is in the architecture's boot directory
[[ ${KIMAGE} == "vmlinux" ]] || BOOT_DIR=arch/${ARCH}/boot/
KERNEL=${KERNEL_LOCATION}/${BOOT_DIR}${KIMAGE}
fi
[[ -f ${KERNEL} ]] || die "${KERNEL} does not exist!"
}

Expand Down