diff --git a/pve/vm-core.func b/pve/vm-core.func index e0e79d2..79bd9dd 100644 --- a/pve/vm-core.func +++ b/pve/vm-core.func @@ -2394,7 +2394,7 @@ vm_select_storage() { while [ -z "${STORAGE:+x}" ]; do # Without an exit-code check STORAGE stayed empty and this spun forever. if vm_dialog radiolist "Storage Pools" \ - "Which storage pool would you like to use for ${hostname}?\nTo make a selection, use the Spacebar.\n" \ + "Which storage pool should hold the disks of ${hostname}?\nTo make a selection, use the Spacebar.\n" \ 16 "$menu_width" 6 \ "${storage_menu[@]}"; then STORAGE="$VM_DIALOG_RESULT" @@ -2436,6 +2436,14 @@ vm_select_iso_storage() { return 119 fi + # The pool already chosen for the disks also takes the ISO when it can, so + # the question is only asked where it has to be. + if [[ -z "$selected" && -n "${STORAGE:-}" ]]; then + for ((i = 0; i < ${#storage_menu[@]}; i += 3)); do + [[ "$STORAGE" == "${storage_menu[i]}" ]] && selected="$STORAGE" + done + fi + if [[ -z "$selected" ]]; then if ((${#storage_menu[@]} == 3)); then selected="${storage_menu[0]}" diff --git a/tests/vm-iso-storage.sh b/tests/vm-iso-storage.sh index 0676546..f87588b 100644 --- a/tests/vm-iso-storage.sh +++ b/tests/vm-iso-storage.sh @@ -80,6 +80,14 @@ local_storage() { assert_equal "$ISO_PATH" "$MOCK_PATH" } +disk_pool_reused() { + MOCK_STATUS+=$'\nlocal dir active 1000 100 900 10' + STORAGE="local" + MOCK_DIALOG_RC=2 + vm_select_iso_storage "archlinux-x86_64.iso" || exit 1 + assert_equal "$ISO_STORAGE" "local" +} + multiple_storage() { MOCK_STATUS+=$'\nsecond-store dir active 1000 100 900 10' MOCK_CHOICE="second-store" @@ -179,7 +187,7 @@ incus_unsupported() { expect_failure "archlinux-x86_64.iso" "not supported on Incus" } -for test in single_storage local_storage multiple_storage explicit_storage \ +for test in single_storage local_storage disk_pool_reused multiple_storage explicit_storage \ preselected_storage unattended_single unattended_multiple inactive_storage \ no_storage invalid_preset inactive_preset status_error path_error relative_path \ empty_path multiline_path invalid_filename missing_filename invalid_selection \