Skip to content

Commit 49acca1

Browse files
committed
run_qemu.sh: replace qemu -S + KVM with a long bootloader timeout
qemu -S does not seem compatible with KVM, see #11 For details. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent 89c80b7 commit 49acca1

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

run_qemu.sh

+28-3
Original file line numberDiff line numberDiff line change
@@ -862,15 +862,25 @@ update_rootfs_boot_kernel()
862862
sudo mkdir -p "$builddir/mnt/run-qemu-kernel/$kver"
863863
sudo cp "$builddir/mkosi.extra/boot/vmlinuz-$kver" "$builddir/mnt/run-qemu-kernel/$kver/vmlinuz"
864864

865+
local loader_timeout=4
866+
if [[ $_arg_kvm == "on" ]] && [[ $_arg_gdb == "on" ]]; then
867+
# KVM is not compatible with qemu -S, see
868+
# https://github.com/pmem/run_qemu/issues/11
869+
loader_timeout=301
870+
fi
871+
865872
defconf="$builddir/mnt/loader/loader.conf"
866873
if [ -f "$defconf" ]; then
867-
sudo sed -i -e 's/^#.*timeout.*/timeout 4/' "$defconf"
874+
# mkosi->"bootctl install ..." creates a stub loader.conf
875+
sudo sed -i -e 's/^#.*timeout.*/timeout '"$loader_timeout/" "$defconf"
868876
sudo sed -i -e '/default.*/d' "$defconf"
869877
else
870-
echo "timeout 4" | sudo tee "$defconf"
878+
echo "timeout $loader_timeout" | sudo tee "$defconf"
871879
fi
872880
echo "default run-qemu-kernel-$kver.conf" | sudo tee -a "$defconf"
873881

882+
generatedfrom_header 'update_rootfs_boot_kernel()' | sudo tee -a "$defconf" > /dev/null
883+
874884
[[ "$_arg_legacy_bios" == 'on' ]] || install_opt_efi_shell
875885

876886
umount_rootfs 1
@@ -1733,7 +1743,22 @@ prepare_qcmd()
17331743
fi
17341744

17351745
if [ "$_arg_gdb" == "on" ]; then
1736-
qcmd+=("-gdb" "tcp::10000" "-S")
1746+
qcmd+=("-gdb" "tcp::10000")
1747+
# -S seems to rely on a _software_ breakpoint which seems incompatible with KVM,
1748+
# see https://github.com/pmem/run_qemu/issues/11
1749+
if [[ "$_arg_kvm" == 'on' ]]; then
1750+
{
1751+
printf '\n\nWARNING: qemu "-S" option seems incompatible with KVM; not used.\n'
1752+
if [[ "$_arg_direct_kernel" == 'on' ]]; then
1753+
printf '\tOption --no-direct-kernel is recommended.\n\n'
1754+
else
1755+
printf '\tBoot loader will wait a few minutes.\n\n'
1756+
fi
1757+
} >&2
1758+
sleep 2
1759+
else
1760+
qcmd+=("-S")
1761+
fi
17371762
fi
17381763

17391764
# cpu + mem nodes (i.e. the --nodes option)

0 commit comments

Comments
 (0)