Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pve/vm-core.func
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]}"
Expand Down
10 changes: 9 additions & 1 deletion tests/vm-iso-storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 \
Expand Down
Loading