From 749e3f9c3a237736b8c7c5080c547215981232af Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 27 Nov 2025 10:16:34 -0700 Subject: [PATCH] boot-qemu.py: Allow user to supply their own ramdisk The user may want to supply a modified cpio archive for testing (such as one that contains modules like from the proposed modules-cpio-pkg [1] target in kbuild). Make it easier to do so with a command line argument. Link: https://lore.kernel.org/20251125-cpio-modules-pkg-v2-0-aa8277d89682@pengutronix.de/ [1] Signed-off-by: Nathan Chancellor --- boot-qemu.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/boot-qemu.py b/boot-qemu.py index 1426933..4833875 100755 --- a/boot-qemu.py +++ b/boot-qemu.py @@ -47,6 +47,7 @@ def __init__(self): self.gdb = False self.gdb_bin = '' self.gh_json_file = None + self.initrd = None self.interactive = False self.kernel = None self.kernel_dir = None @@ -167,6 +168,8 @@ def _have_dev_kvm_access(self): return os.access('/dev/kvm', os.R_OK | os.W_OK) def _prepare_initrd(self): + if self.initrd: + return self.initrd if not self._initrd_arch: raise RuntimeError('No initrd architecture specified?') return utils.prepare_initrd(self._initrd_arch, @@ -821,6 +824,12 @@ def parse_arguments(): help= 'Use file for downloading rootfs images, instead of querying GitHub API directly' ) + parser.add_argument( + '-I', + '--initrd', + help= + 'Initial ramdisk to use (default: Download ramdisk from ClangBuiltLinux/boot-utils releases)' + ) parser.add_argument( '-k', '--kernel-location', @@ -919,6 +928,12 @@ def parse_arguments(): if args.gh_json_file: runner.gh_json_file = Path(args.gh_json_file).resolve() + if args.initrd: + if not (initrd := Path(args.initrd).resolve()).exists(): + raise FileNotFoundError( + f"Supplied initrd ('{initrd}') does not exist?") + runner.initrd = initrd + if args.memory: runner.memory = args.memory