Skip to content

Commit 6903ee5

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 24835a5 commit 6903ee5

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
@@ -810,15 +810,25 @@ update_rootfs_boot_kernel()
810810
sudo mkdir -p "$builddir/mnt/run-qemu-kernel/$kver"
811811
sudo cp "$builddir/mkosi.extra/boot/vmlinuz-$kver" "$builddir/mnt/run-qemu-kernel/$kver/vmlinuz"
812812

813+
local loader_timeout=4
814+
if [[ $_arg_kvm == "on" ]] && [[ $_arg_gdb == "on" ]]; then
815+
# KVM is not compatible with qemu -S, see
816+
# https://github.com/pmem/run_qemu/issues/11
817+
loader_timeout=301
818+
fi
819+
813820
defconf="$builddir/mnt/loader/loader.conf"
814821
if [ -f "$defconf" ]; then
815-
sudo sed -i -e 's/^#.*timeout.*/timeout 4/' "$defconf"
822+
# mkosi->"bootctl install ..." creates a stub loader.conf
823+
sudo sed -i -e 's/^#.*timeout.*/timeout '"$loader_timeout/" "$defconf"
816824
sudo sed -i -e '/default.*/d' "$defconf"
817825
else
818-
echo "timeout 4" | sudo tee "$defconf"
826+
echo "timeout $loader_timeout" | sudo tee "$defconf"
819827
fi
820828
echo "default run-qemu-kernel-$kver.conf" | sudo tee -a "$defconf"
821829

830+
generatedfrom_header 'update_rootfs_boot_kernel()' | sudo tee -a "$defconf" > /dev/null
831+
822832
# Fedora
823833
sudo cp "$ovmf_path"/Shell.efi "$builddir"/mnt/shellx64.efi ||
824834
# Arch Linux
@@ -1575,7 +1585,22 @@ prepare_qcmd()
15751585
fi
15761586

15771587
if [ "$_arg_gdb" == "on" ]; then
1578-
qcmd+=("-gdb" "tcp::10000" "-S")
1588+
qcmd+=("-gdb" "tcp::10000")
1589+
# -S seems to rely on a _software_ breakpoint which seems incompatible with KVM,
1590+
# see https://github.com/pmem/run_qemu/issues/11
1591+
if [[ "$_arg_kvm" == 'on' ]]; then
1592+
{
1593+
printf '\n\nWARNING: qemu "-S" option seems incompatible with KVM; not used.\n'
1594+
if [[ "$_arg_direct_kernel" == 'on' ]]; then
1595+
printf '\tOption --no-direct-kernel is recommended.\n\n'
1596+
else
1597+
printf '\tBoot loader will wait a few minutes.\n\n'
1598+
fi
1599+
} >&2
1600+
sleep 2
1601+
else
1602+
qcmd+=("-S")
1603+
fi
15791604
fi
15801605

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

0 commit comments

Comments
 (0)