From 3ef2647b7126f4de0c16422eda13217d02082883 Mon Sep 17 00:00:00 2001 From: MickLesk <47820557+MickLesk@users.noreply.github.com> Date: Thu, 8 Oct 2026 11:00:29 +0200 Subject: [PATCH] Take the ISO storage from the disk pool when it can hold ISOs An installer VM asked for a storage twice: once for the disks, once for the ISO. When the pool chosen for the disks also offers ISO content it is used for the ISO as well, so the second question only comes where it must. The disk dialog now says what it is for. --- pve/vm-core.func | 10 +++++++++- tests/vm-iso-storage.sh | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) 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 \