It seems like I will need to write a scriptlet so I can override the kernel arguments to have incus achieve something analogous to:
APPEND_ARGS="root=PARTUUID=13d8cd4e-02 rw rootwait console=ttyS0,115200 earlyprintk=ttyS0,115200 init=/bin/sh /mnt/bootstrap.sh"
qemu-system-x86_64 \
-enable-kvm -cpu host -m 2048 -L "$BIOS_DIR" \
-kernel "$KERNEL_PATH" \
-append "$APPEND_ARGS" \
-drive file="$DISK_PATH",format=raw,if=virtio \
-virtfs local,path="$HOST_SCRIPT_DIR",mount_tag=host_share,security_model=none,id=host_share \
-chardev socket,id=char0,path="$SERIAL_SOCK",server=on,wait=off,logfile="$DEBUG_LOG" \
-serial chardev:char0 \
-display none
Trying to hack via setting raw.qemu has been a dead end for me.
I don’t care about exactly replicating the above qemu-system-x86_64: really looking for the ability to set up a socket that can be accessed from the host and run bootstrap.sh instead of the usual init. host_share would be a plus!
The VM is for a custom openwrt x86-64 build, so $KERNEL_PATH and $DISK_PATH does require a legacy BIOS boot and are incompatible with UEFI
I’ve been searching for scriptlet examples and wasn’t able to arrive at anything that remotely works without looking horrendous and unmaintainable - are there samples for me to iterate from using Incus 6.20?
The latest “clean” iteration I arrived at before I ended up with something I’m ashamed to put online (error was Failed running QEMU scriptlet at config stage: Failed to run: Addition or deletion of -bios or -kernel is unsupported from incus/internal/server/scriptlet/qemu.go at 112678ceca4673d01d23332ab666138e1adad1c4 · lxc/incus · GitHub ):
def qemu_hook(instance, stage):
# seems like only the 'config' stage allows us to modify the command line
if stage == "config":
log_info("Scriptlet: Accessing QEMU command line at config stage")
# Capture the original command line
args = get_qemu_cmdline()
log_info("BEFORE: " + str(args))
# Inject our legacy boot parameters
args.extend(["-kernel", "$KERNEL_PATH"])
args.extend(["-append", "$APPEND_ARGS"])
# etc
# Log the modified state
log_info("AFTER: " + str(args))
# Commit the changes
set_qemu_cmdline(args)
log_info("set_qemu_cmdline applied successfully in config stage")
If on the other hand, this is expected behavior, what’s the workflow if I wanted to experiment with kernels and tuning their parameters using Incus 6.20 VM?
Now I’m using a OpenWRT VM to achieve all of this so if this detail matters or is relevant, let me know as well, but so far it feels like the protections are from Incus