From 65735c9c8d6fda0884a0619191a49fddbbc4d151 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Fri, 20 Mar 2020 18:35:29 +0000 Subject: [PATCH] Add --status-quo option to preserve the existing disk state Starting a VM with `--status-quo` will prevent any changes being committed to the disk image. However, while the VM is boot you can make changes but on next boot none will have been preserved. --- README.md | 1 + quickemu | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a94ae99..ed71886 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ You can also pass optional parameters --snapshot create : Create a snapshot. --snapshot delete : Delete a snapshot. --snapshot info : Show disk/snapshot info. + --status-quo : Do not commit any changes to disk/snapshot. ``` ## TODO diff --git a/quickemu b/quickemu index 79a1c24..fc83e31 100755 --- a/quickemu +++ b/quickemu @@ -143,6 +143,11 @@ function vm_boot() { fi fi + # Has the status quo been requested? + if [ "${STATUSQUO}" == "-snapshot" ] && [ -z "${iso}" ]; then + echo " Existing disk state will be preserved, no writes will be committed." + fi + local cores="1" local allcores=$(nproc --all) if [ ${allcores} -ge 8 ]; then @@ -228,7 +233,7 @@ function vm_boot() { -object rng-random,id=rng0,filename=/dev/urandom \ -device virtio-rng-pci,rng=rng0 \ -device virtio-vga,virgl=${VIRGL},xres=${xres},yres=${yres} \ - ${display} \ + ${display} ${STATUSQUO}\ "$@" } @@ -244,6 +249,7 @@ function usage() { echo " --snapshot create : Create a snapshot." echo " --snapshot delete : Delete a snapshot." echo " --snapshot info : Show disk/snapshot info." + echo " --status-quo : Do not commit any changes to disk/snapshot." exit 1 } @@ -254,6 +260,7 @@ readonly QEMU_IMG="/snap/bin/qemu-virgil.qemu-img" readonly LAUNCHER=$(basename $0) SNAPSHOT_ACTION="" SNAPSHOT_TAG="" +STATUSQUO="" VM="" while [ $# -gt 0 ]; do @@ -278,6 +285,9 @@ while [ $# -gt 0 ]; do fi shift shift;; + -status-quo|--status-quo) + STATUSQUO="-snapshot" + shift;; -vm|--vm) VM="$2" shift