From 8c10b20fb72b5d224106fb61ceea7bc68982d7df Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Sun, 30 Jun 2024 12:05:46 +0100 Subject: [PATCH] fix: correctly run VMs when PWD is not relative to the VM directory --- quickemu | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/quickemu b/quickemu index 2a56c18..817974e 100755 --- a/quickemu +++ b/quickemu @@ -52,9 +52,7 @@ function delete_disk() { rm "${disk_img}" >/dev/null 2>&1 # Remove any EFI vars, but not for macOS rm "${VMDIR}"/OVMF_VARS*.fd >/dev/null 2>&1 - rm "${VMPATH}/${VMDIR}"/OVMF_VARS*.fd >/dev/null 2>&1 rm "${VMDIR}/${VMNAME}-vars.fd" >/dev/null 2>&1 - rm "${VMPATH}/${VMDIR}/${VMNAME}-vars.fd" >/dev/null 2>&1 echo " - Deleted ${disk_img}" delete_shortcut else @@ -2058,6 +2056,12 @@ if [ -n "${VM}" ] && [ -e "${VM}" ]; then disk_img="${VMDIR}/disk.${disk_format}" fi + # Fixes running VMs when PWD is not relative to the VM directory + # https://github.com/quickemu-project/quickemu/pull/875 + if [ ! -f "${disk_img}" ]; then + pushd "${VMPATH}" >/dev/null || exit + fi + # Iterate over any actions and exit. if [ ${#ACTIONS[@]} -ge 1 ]; then for ACTION in "${ACTIONS[@]}"; do @@ -2113,13 +2117,6 @@ if [ -r "${VMDIR}/${VMNAME}.pid" ]; then fi if [ -z "${VM_PID}" ]; then - #TODO: double quote the args array to prevent word splitting and this can be removed - # Fix failing to start VM with spaces in the path - # https://github.com/quickemu-project/quickemu/pull/875 - if [ ! -f "${disk_img}" ]; then - pushd "${VMPATH}" || exit - fi - vm_boot # If the VM being started is an uninstalled Windows VM then auto-skip the press-any key prompt. if [ -n "${iso}" ] && [ "${guest_os}" == "windows" ]; then