Skip to content

Commit bb347e1

Browse files
committed
run_qemu.sh: fix --rw option just broken by switch to -blockdev
Use a qcow2 overlay to fix the --rw regression just added by commit dfa1d3f ("run_qemu.sh: replace -drive rootfs with -blockdev + -device") The QEMU -snapshot option is silently ignored by -blockdev (this is documented in the qemu-system man page) Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent b5dda0c commit bb347e1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

parser_generator.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ exit 11 #)Created by argbash-init v2.9.0
3838
# ARG_OPTIONAL_BOOLEAN([gdb], , [Wait for gdb to connect for kernel debug (port 10000)], )
3939
# ARG_OPTIONAL_BOOLEAN([gdb-qemu], , [Start qemu with gdb], )
4040
# ARG_OPTIONAL_BOOLEAN([qmp], , [Invokes QEMU with -qmp which opens a QMP control socket at unix:/tmp/run_qemu_qmp. Using that socket requires the 'qmp-shell' script.\nWhen needed, run_qemu.sh can find qmp-shell either in the PATH, or in scripts/qmp/ in the qemu source when using --git-qemu.\nThe official qemu.qmp package is available on PyPI.], )
41-
# ARG_OPTIONAL_BOOLEAN([rw], , [Make guest image writeable (remove -snapshot)\n (Note that an image rebuild will lose any changes made via --rw)], )
41+
# ARG_OPTIONAL_BOOLEAN([rw], , [Persist run-time image changes for the next cold boot.\nA reboot does not lose changes; for persistency a reboot is a non-event.\nNote that an image rebuild will always reset any changes made via --rw]\n, )
4242
# ARG_OPTIONAL_BOOLEAN([curses], , [Default display is -nographic. switch to -curses instead with this option.\n Use Esc+1, Esc+2, etc. to switch between the different screens.\n 'q' in the monitor screen to quit], )
4343
# ARG_OPTIONAL_BOOLEAN([git-qemu], [g], [Use a qemu tree at '~/git/qemu/' for qemu binaries.\n This overrides any qemu=<foo> setting from the env.], )
4444
# ARG_OPTIONAL_BOOLEAN([nfit-test], , [Setup an environment for unit tests\n - include libnvdimm 'extra' modules\n - add some memmap reserved memory\n Note: --rebuild=img or higher required when switching either to or away from nfit-test.\n This overrides any supplied 'preset' or topology options and forces preset=med], )

run_qemu.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,18 @@ prepare_qcmd()
18621862
;;
18631863
esac
18641864

1865-
qcmd+=("-blockdev" "driver=file,node-name=maindisk,filename=$_arg_rootfs")
1865+
if [[ $_arg_rw == 'on' ]]; then
1866+
qcmd+=("-blockdev" "driver=file,node-name=maindisk,filename=${_arg_rootfs}")
1867+
else
1868+
local _overlay=${_arg_rootfs}-overlay.qcow2
1869+
rm -f "${_overlay}"
1870+
qemu-img create -F raw -b "${_arg_rootfs}" -f qcow2 "${_overlay}"
1871+
# "Finding your way through the QEMU parameter jungle"
1872+
# -- Thomas Huth
1873+
qcmd+=("-blockdev" "file,node-name=mainoverlay,filename=${_overlay}")
1874+
qcmd+=("-blockdev" "qcow2,node-name=maindisk,file=mainoverlay")
1875+
fi
1876+
18661877
qcmd+=("-device" "virtio-blk,bus=pcie.0,drive=maindisk")
18671878

18681879
if [ $_arg_direct_kernel = "on" ] && [ -n "$vmlinuz" ] && [ -n "$initrd" ]; then
@@ -1903,6 +1914,7 @@ prepare_qcmd()
19031914
fi
19041915

19051916
if [[ $_arg_rw == "off" ]]; then
1917+
# Note this is only for the (deprecated) -drive and ignored by -blockdev
19061918
qcmd+=("-snapshot")
19071919
fi
19081920

0 commit comments

Comments
 (0)