mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-25 08:56:21 +00:00
update switch_gpu_mode.sh
This commit is contained in:
@@ -413,9 +413,7 @@ ensure_selected_gpu_not_already_in_target_vm() {
|
|||||||
local pci label
|
local pci label
|
||||||
pci="${ALL_GPU_PCIS[$i]}"
|
pci="${ALL_GPU_PCIS[$i]}"
|
||||||
_is_pci_slot_assigned_to_vm "$pci" "$SELECTED_VMID" && continue
|
_is_pci_slot_assigned_to_vm "$pci" "$SELECTED_VMID" && continue
|
||||||
label="${ALL_GPU_NAMES[$i]}"
|
label="${ALL_GPU_NAMES[$i]} [${ALL_GPU_DRIVERS[$i]}] — ${pci}"
|
||||||
[[ "${ALL_GPU_DRIVERS[$i]}" == "vfio-pci" ]] && label+=" [VFIO]"
|
|
||||||
label+=" — ${pci}"
|
|
||||||
menu_items+=("$i" "$label")
|
menu_items+=("$i" "$label")
|
||||||
available=$((available + 1))
|
available=$((available + 1))
|
||||||
done
|
done
|
||||||
@@ -429,12 +427,21 @@ ensure_selected_gpu_not_already_in_target_vm() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local choice
|
local choice
|
||||||
choice=$(dialog --backtitle "ProxMenux" \
|
if [[ "$WIZARD_CALL" == "true" ]]; then
|
||||||
--title "$(translate 'GPU Already Assigned to This VM')" \
|
choice=$(whiptail --backtitle "ProxMenux" \
|
||||||
--menu "\n$(translate 'The selected GPU is already present in this VM. Select another GPU to continue:')" \
|
--title "$(translate 'GPU Already Assigned to This VM')" \
|
||||||
18 82 10 \
|
--menu "\n$(translate 'The selected GPU is already present in this VM. Select another GPU to continue:')" \
|
||||||
"${menu_items[@]}" \
|
18 82 10 \
|
||||||
2>&1 >/dev/tty) || exit 0
|
"${menu_items[@]}" \
|
||||||
|
3>&1 1>&2 2>&3) || exit 0
|
||||||
|
else
|
||||||
|
choice=$(dialog --backtitle "ProxMenux" \
|
||||||
|
--title "$(translate 'GPU Already Assigned to This VM')" \
|
||||||
|
--menu "\n$(translate 'The selected GPU is already present in this VM. Select another GPU to continue:')" \
|
||||||
|
18 82 10 \
|
||||||
|
"${menu_items[@]}" \
|
||||||
|
2>&1 >/dev/tty) || exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
SELECTED_GPU="${ALL_GPU_TYPES[$choice]}"
|
SELECTED_GPU="${ALL_GPU_TYPES[$choice]}"
|
||||||
SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}"
|
SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}"
|
||||||
@@ -448,12 +455,16 @@ ensure_selected_gpu_not_already_in_target_vm() {
|
|||||||
# ==========================================================
|
# ==========================================================
|
||||||
detect_host_gpus() {
|
detect_host_gpus() {
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
local pci_short pci_full name type driver
|
local pci_short pci_full name type driver pci_info
|
||||||
pci_short=$(echo "$line" | awk '{print $1}')
|
pci_short=$(echo "$line" | awk '{print $1}')
|
||||||
pci_full="0000:${pci_short}"
|
pci_full="0000:${pci_short}"
|
||||||
|
|
||||||
# Human-readable name: between first ":" and first "["
|
# Prefer full vendor/model descriptor for clearer menus.
|
||||||
name=$(echo "$line" | sed 's/^[^:]*[^:]: //' | sed 's/ \[.*//' | cut -c1-62)
|
pci_info=$(lspci -nn -s "${pci_short}" 2>/dev/null | sed 's/^[^ ]* //')
|
||||||
|
name="${pci_info#*: }"
|
||||||
|
[[ "$name" == "$pci_info" ]] && name="$pci_info"
|
||||||
|
name=$(echo "$name" | sed -E 's/ \(rev [^)]+\)$//' | cut -c1-72)
|
||||||
|
[[ -z "$name" ]] && name="$(translate 'Unknown GPU')"
|
||||||
|
|
||||||
if echo "$line" | grep -qi "Intel"; then
|
if echo "$line" | grep -qi "Intel"; then
|
||||||
type="intel"
|
type="intel"
|
||||||
@@ -614,19 +625,26 @@ select_gpu() {
|
|||||||
local menu_items=()
|
local menu_items=()
|
||||||
local i
|
local i
|
||||||
for i in "${!ALL_GPU_PCIS[@]}"; do
|
for i in "${!ALL_GPU_PCIS[@]}"; do
|
||||||
local label="${ALL_GPU_NAMES[$i]}"
|
local label="${ALL_GPU_NAMES[$i]} [${ALL_GPU_DRIVERS[$i]}] — ${ALL_GPU_PCIS[$i]}"
|
||||||
[[ "${ALL_GPU_DRIVERS[$i]}" == "vfio-pci" ]] && label+=" [VFIO]"
|
|
||||||
label+=" — ${ALL_GPU_PCIS[$i]}"
|
|
||||||
menu_items+=("$i" "$label")
|
menu_items+=("$i" "$label")
|
||||||
done
|
done
|
||||||
|
|
||||||
local choice
|
local choice
|
||||||
choice=$(dialog --backtitle "ProxMenux" \
|
if [[ "$WIZARD_CALL" == "true" ]]; then
|
||||||
--title "$(translate 'Select GPU for VM Passthrough')" \
|
choice=$(whiptail --backtitle "ProxMenux" \
|
||||||
--menu "\n$(translate 'Select the GPU to pass through to the VM:')" \
|
--title "$(translate 'Select GPU for VM Passthrough')" \
|
||||||
18 82 10 \
|
--menu "\n$(translate 'Select the GPU to pass through to the VM:')" \
|
||||||
"${menu_items[@]}" \
|
18 82 10 \
|
||||||
2>&1 >/dev/tty) || exit 0
|
"${menu_items[@]}" \
|
||||||
|
3>&1 1>&2 2>&3) || exit 0
|
||||||
|
else
|
||||||
|
choice=$(dialog --backtitle "ProxMenux" \
|
||||||
|
--title "$(translate 'Select GPU for VM Passthrough')" \
|
||||||
|
--menu "\n$(translate 'Select the GPU to pass through to the VM:')" \
|
||||||
|
18 82 10 \
|
||||||
|
"${menu_items[@]}" \
|
||||||
|
2>&1 >/dev/tty) || exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
SELECTED_GPU="${ALL_GPU_TYPES[$choice]}"
|
SELECTED_GPU="${ALL_GPU_TYPES[$choice]}"
|
||||||
SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}"
|
SELECTED_GPU_PCI="${ALL_GPU_PCIS[$choice]}"
|
||||||
|
|||||||
@@ -404,10 +404,14 @@ detect_host_gpus() {
|
|||||||
ALL_GPU_VIDDID=()
|
ALL_GPU_VIDDID=()
|
||||||
|
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
local pci_short pci_full name type driver viddid
|
local pci_short pci_full name type driver viddid pci_info
|
||||||
pci_short=$(echo "$line" | awk '{print $1}')
|
pci_short=$(echo "$line" | awk '{print $1}')
|
||||||
pci_full="0000:${pci_short}"
|
pci_full="0000:${pci_short}"
|
||||||
name=$(echo "$line" | sed 's/^[^:]*[^:]: //' | sed 's/ \[.*//' | cut -c1-62)
|
pci_info=$(lspci -nn -s "${pci_short}" 2>/dev/null | sed 's/^[^ ]* //')
|
||||||
|
name="${pci_info#*: }"
|
||||||
|
[[ "$name" == "$pci_info" ]] && name="$pci_info"
|
||||||
|
name=$(echo "$name" | sed -E 's/ \(rev [^)]+\)$//' | cut -c1-72)
|
||||||
|
[[ -z "$name" ]] && name="$(translate 'Unknown GPU')"
|
||||||
if echo "$line" | grep -qi "Intel"; then
|
if echo "$line" | grep -qi "Intel"; then
|
||||||
type="intel"
|
type="intel"
|
||||||
elif echo "$line" | grep -qiE "AMD|Advanced Micro|Radeon"; then
|
elif echo "$line" | grep -qiE "AMD|Advanced Micro|Radeon"; then
|
||||||
|
|||||||
@@ -262,15 +262,7 @@ select_controller_nvme() {
|
|||||||
|
|
||||||
if [[ ${#blocked_reasons[@]} -gt 0 ]]; then
|
if [[ ${#blocked_reasons[@]} -gt 0 ]]; then
|
||||||
blocked_count=$((blocked_count + 1))
|
blocked_count=$((blocked_count + 1))
|
||||||
blocked_report+="------------------------------------------------------------\n"
|
blocked_report+=" • ${pci_full} — $(_shorten_text "$name" 56)\n"
|
||||||
blocked_report+="PCI: ${pci_full}\n"
|
|
||||||
blocked_report+="Name: ${name}\n"
|
|
||||||
blocked_report+="$(translate "Blocked because protected or in-use disks are attached"):\n"
|
|
||||||
local reason
|
|
||||||
for reason in "${blocked_reasons[@]}"; do
|
|
||||||
blocked_report+=" - ${reason}\n"
|
|
||||||
done
|
|
||||||
blocked_report+="\n"
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -282,12 +274,7 @@ select_controller_nvme() {
|
|||||||
assigned_suffix=" | $(translate "Assigned to VM")"
|
assigned_suffix=" | $(translate "Assigned to VM")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${#controller_disks[@]} -gt 0 ]]; then
|
controller_desc="${short_name}${assigned_suffix}"
|
||||||
controller_desc="$(printf "%-42s [%s: %d]" "$short_name" "$(translate "attached disks")" "${#controller_disks[@]}")"
|
|
||||||
else
|
|
||||||
controller_desc="$(printf "%-42s [%s]" "$short_name" "$(translate "No attached disks")")"
|
|
||||||
fi
|
|
||||||
controller_desc+="${assigned_suffix}"
|
|
||||||
|
|
||||||
state="off"
|
state="off"
|
||||||
menu_items+=("$pci_full" "$controller_desc" "$state")
|
menu_items+=("$pci_full" "$controller_desc" "$state")
|
||||||
@@ -299,10 +286,10 @@ select_controller_nvme() {
|
|||||||
if [[ "$hidden_target_count" -gt 0 && "$blocked_count" -eq 0 ]]; then
|
if [[ "$hidden_target_count" -gt 0 && "$blocked_count" -eq 0 ]]; then
|
||||||
msg="$(translate "All detected controllers/NVMe are already present in the selected VM.")\n\n$(translate "No additional device needs to be added.")"
|
msg="$(translate "All detected controllers/NVMe are already present in the selected VM.")\n\n$(translate "No additional device needs to be added.")"
|
||||||
else
|
else
|
||||||
msg="$(translate "No safe controllers/NVMe devices are available for passthrough.")\n\n"
|
msg="$(translate "No available Controllers/NVMe devices were found.")\n\n"
|
||||||
fi
|
fi
|
||||||
if [[ "$blocked_count" -gt 0 ]]; then
|
if [[ "$blocked_count" -gt 0 ]]; then
|
||||||
msg+="$(translate "Detected controllers blocked for safety:")\n\n${blocked_report}"
|
msg+="$(translate "Hidden for safety"):\n${blocked_report}"
|
||||||
fi
|
fi
|
||||||
dialog --backtitle "ProxMenux" \
|
dialog --backtitle "ProxMenux" \
|
||||||
--title "$(translate "Controller + NVMe")" \
|
--title "$(translate "Controller + NVMe")" \
|
||||||
@@ -310,16 +297,10 @@ select_controller_nvme() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$blocked_count" -gt 0 ]]; then
|
|
||||||
dialog --backtitle "ProxMenux" \
|
|
||||||
--title "$(translate "Controller + NVMe")" \
|
|
||||||
--msgbox "$(translate "Some controllers were hidden because they have host system disks attached.")\n\n${blocked_report}" 22 100
|
|
||||||
fi
|
|
||||||
|
|
||||||
local raw selected
|
local raw selected
|
||||||
raw=$(dialog --backtitle "ProxMenux" \
|
raw=$(dialog --backtitle "ProxMenux" \
|
||||||
--title "$(translate "Controller + NVMe")" \
|
--title "$(translate "Controller + NVMe")" \
|
||||||
--checklist "\n$(translate "Select controllers/NVMe to passthrough (safe devices only):")\n\n$(translate "Only safe devices are shown in this list.")" 20 96 12 \
|
--checklist "\n$(translate "Select available Controllers/NVMe to add:")" 20 96 12 \
|
||||||
"${menu_items[@]}" \
|
"${menu_items[@]}" \
|
||||||
2>&1 >/dev/tty) || return 1
|
2>&1 >/dev/tty) || return 1
|
||||||
|
|
||||||
|
|||||||
@@ -325,15 +325,7 @@ function select_controller_nvme() {
|
|||||||
|
|
||||||
if [[ ${#blocked_reasons[@]} -gt 0 ]]; then
|
if [[ ${#blocked_reasons[@]} -gt 0 ]]; then
|
||||||
blocked_count=$((blocked_count + 1))
|
blocked_count=$((blocked_count + 1))
|
||||||
blocked_report+="------------------------------------------------------------\n"
|
blocked_report+=" • ${pci_full} — $(_shorten_text "$name" 56)\n"
|
||||||
blocked_report+="PCI: ${pci_full}\n"
|
|
||||||
blocked_report+="Name: ${name}\n"
|
|
||||||
blocked_report+="$(translate "Blocked because protected/in-use disks are attached"):\n"
|
|
||||||
local reason
|
|
||||||
for reason in "${blocked_reasons[@]}"; do
|
|
||||||
blocked_report+=" - ${reason}\n"
|
|
||||||
done
|
|
||||||
blocked_report+="\n"
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -345,12 +337,7 @@ function select_controller_nvme() {
|
|||||||
assigned_suffix=" | $(translate "Assigned to VM")"
|
assigned_suffix=" | $(translate "Assigned to VM")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${#controller_disks[@]} -gt 0 ]]; then
|
controller_desc="${short_name}${assigned_suffix}"
|
||||||
controller_desc="$(printf "%-42s [%s: %d]" "$short_name" "$(translate "attached disks")" "${#controller_disks[@]}")"
|
|
||||||
else
|
|
||||||
controller_desc="$(printf "%-42s [%s]" "$short_name" "$(translate "No attached disks")")"
|
|
||||||
fi
|
|
||||||
controller_desc+="${assigned_suffix}"
|
|
||||||
|
|
||||||
if _array_contains "$pci_full" "${CONTROLLER_NVME_PCIS[@]}"; then
|
if _array_contains "$pci_full" "${CONTROLLER_NVME_PCIS[@]}"; then
|
||||||
state="ON"
|
state="ON"
|
||||||
@@ -368,22 +355,18 @@ function select_controller_nvme() {
|
|||||||
if [[ "$hidden_target_count" -gt 0 && "$blocked_count" -eq 0 ]]; then
|
if [[ "$hidden_target_count" -gt 0 && "$blocked_count" -eq 0 ]]; then
|
||||||
msg="$(translate "All detected controllers/NVMe are already present in the selected VM.")\n\n$(translate "No additional device needs to be added.")"
|
msg="$(translate "All detected controllers/NVMe are already present in the selected VM.")\n\n$(translate "No additional device needs to be added.")"
|
||||||
else
|
else
|
||||||
msg="$(translate "No safe controllers/NVMe devices are available for passthrough.")\n\n"
|
msg="$(translate "No available Controllers/NVMe devices were found.")\n\n"
|
||||||
fi
|
fi
|
||||||
if [[ $blocked_count -gt 0 ]]; then
|
if [[ $blocked_count -gt 0 ]]; then
|
||||||
msg+="$(translate "Detected controllers blocked for safety:")\n\n${blocked_report}"
|
msg+="$(translate "Hidden for safety"):\n${blocked_report}"
|
||||||
fi
|
fi
|
||||||
whiptail --title "Controller + NVMe" --msgbox "$msg" 22 100
|
whiptail --title "Controller + NVMe" --msgbox "$msg" 22 100
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $blocked_count -gt 0 ]]; then
|
|
||||||
whiptail --title "Controller + NVMe" --msgbox "$(translate "Some controllers were hidden because they have host system disks attached.")\n\n${blocked_report}" 22 100
|
|
||||||
fi
|
|
||||||
|
|
||||||
local selected
|
local selected
|
||||||
selected=$(whiptail --title "Controller + NVMe" --checklist \
|
selected=$(whiptail --title "Controller + NVMe" --checklist \
|
||||||
"$(translate "Select controllers/NVMe to passthrough (safe devices only):")\n\n$(translate "Only safe devices are shown in this list.")" 20 96 10 \
|
"$(translate "Select available Controllers/NVMe to add:")" 20 96 10 \
|
||||||
"${menu_items[@]}" 3>&1 1>&2 2>&3)
|
"${menu_items[@]}" 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
[[ $? -ne 0 ]] && return 1
|
[[ $? -ne 0 ]] && return 1
|
||||||
|
|||||||
@@ -676,15 +676,7 @@ function select_controller_nvme() {
|
|||||||
|
|
||||||
if [[ ${#blocked_reasons[@]} -gt 0 ]]; then
|
if [[ ${#blocked_reasons[@]} -gt 0 ]]; then
|
||||||
blocked_count=$((blocked_count + 1))
|
blocked_count=$((blocked_count + 1))
|
||||||
blocked_report+="------------------------------------------------------------\n"
|
blocked_report+=" • ${pci_full} — $(_shorten_text "$name" 56)\n"
|
||||||
blocked_report+="PCI: ${pci_full}\n"
|
|
||||||
blocked_report+="Name: ${name}\n"
|
|
||||||
blocked_report+="$(translate "Blocked because protected/in-use disks are attached"):\n"
|
|
||||||
local reason
|
|
||||||
for reason in "${blocked_reasons[@]}"; do
|
|
||||||
blocked_report+=" - ${reason}\n"
|
|
||||||
done
|
|
||||||
blocked_report+="\n"
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -696,12 +688,7 @@ function select_controller_nvme() {
|
|||||||
assigned_suffix=" | $(translate "Assigned to VM")"
|
assigned_suffix=" | $(translate "Assigned to VM")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${#controller_disks[@]} -gt 0 ]]; then
|
controller_desc="${short_name}${assigned_suffix}"
|
||||||
controller_desc="$(printf "%-42s [%s: %d]" "$short_name" "$(translate "attached disks")" "${#controller_disks[@]}")"
|
|
||||||
else
|
|
||||||
controller_desc="$(printf "%-42s [%s]" "$short_name" "$(translate "No attached disks")")"
|
|
||||||
fi
|
|
||||||
controller_desc+="${assigned_suffix}"
|
|
||||||
|
|
||||||
if _array_contains "$pci_full" "${CONTROLLER_NVME_PCIS[@]}"; then
|
if _array_contains "$pci_full" "${CONTROLLER_NVME_PCIS[@]}"; then
|
||||||
state="ON"
|
state="ON"
|
||||||
@@ -719,19 +706,18 @@ function select_controller_nvme() {
|
|||||||
if [[ "$hidden_target_count" -gt 0 && "$blocked_count" -eq 0 ]]; then
|
if [[ "$hidden_target_count" -gt 0 && "$blocked_count" -eq 0 ]]; then
|
||||||
msg="$(translate "All detected controllers/NVMe are already present in the selected VM.")\n\n$(translate "No additional device needs to be added.")"
|
msg="$(translate "All detected controllers/NVMe are already present in the selected VM.")\n\n$(translate "No additional device needs to be added.")"
|
||||||
else
|
else
|
||||||
msg="$(translate "No safe controllers/NVMe devices are available for passthrough.")\n\n${blocked_report}"
|
msg="$(translate "No available Controllers/NVMe devices were found.")\n\n"
|
||||||
|
if [[ $blocked_count -gt 0 ]]; then
|
||||||
|
msg+="$(translate "Hidden for safety"):\n${blocked_report}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
whiptail --title "Controller + NVMe" --msgbox "$msg" 22 100
|
whiptail --title "Controller + NVMe" --msgbox "$msg" 22 100
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $blocked_count -gt 0 ]]; then
|
|
||||||
whiptail --title "Controller + NVMe" --msgbox "$(translate "Some controllers were hidden because they have host system disks attached.")\n\n${blocked_report}" 22 100
|
|
||||||
fi
|
|
||||||
|
|
||||||
local selected
|
local selected
|
||||||
selected=$(whiptail --title "Controller + NVMe" --checklist \
|
selected=$(whiptail --title "Controller + NVMe" --checklist \
|
||||||
"$(translate "Select controllers/NVMe to passthrough (safe devices only):")\n\n$(translate "Only safe devices are shown in this list.")" 20 96 10 \
|
"$(translate "Select available Controllers/NVMe to add:")" 20 96 10 \
|
||||||
"${menu_items[@]}" 3>&1 1>&2 2>&3) || return 1
|
"${menu_items[@]}" 3>&1 1>&2 2>&3) || return 1
|
||||||
|
|
||||||
CONTROLLER_NVME_PCIS=()
|
CONTROLLER_NVME_PCIS=()
|
||||||
|
|||||||
@@ -690,15 +690,7 @@ function select_controller_nvme() {
|
|||||||
|
|
||||||
if [[ ${#blocked_reasons[@]} -gt 0 ]]; then
|
if [[ ${#blocked_reasons[@]} -gt 0 ]]; then
|
||||||
blocked_count=$((blocked_count + 1))
|
blocked_count=$((blocked_count + 1))
|
||||||
blocked_report+="------------------------------------------------------------\n"
|
blocked_report+=" • ${pci_full} — $(_shorten_text "$name" 56)\n"
|
||||||
blocked_report+="PCI: ${pci_full}\n"
|
|
||||||
blocked_report+="Name: ${name}\n"
|
|
||||||
blocked_report+="$(translate "Blocked because protected/in-use disks are attached"):\n"
|
|
||||||
local reason
|
|
||||||
for reason in "${blocked_reasons[@]}"; do
|
|
||||||
blocked_report+=" - ${reason}\n"
|
|
||||||
done
|
|
||||||
blocked_report+="\n"
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -710,12 +702,7 @@ function select_controller_nvme() {
|
|||||||
assigned_suffix=" | $(translate "Assigned to VM")"
|
assigned_suffix=" | $(translate "Assigned to VM")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${#controller_disks[@]} -gt 0 ]]; then
|
controller_desc="${short_name}${assigned_suffix}"
|
||||||
controller_desc="$(printf "%-42s [%s: %d]" "$short_name" "$(translate "attached disks")" "${#controller_disks[@]}")"
|
|
||||||
else
|
|
||||||
controller_desc="$(printf "%-42s [%s]" "$short_name" "$(translate "No attached disks")")"
|
|
||||||
fi
|
|
||||||
controller_desc+="${assigned_suffix}"
|
|
||||||
|
|
||||||
if _array_contains "$pci_full" "${CONTROLLER_NVME_PCIS[@]}"; then
|
if _array_contains "$pci_full" "${CONTROLLER_NVME_PCIS[@]}"; then
|
||||||
state="ON"
|
state="ON"
|
||||||
@@ -733,19 +720,18 @@ function select_controller_nvme() {
|
|||||||
if [[ "$hidden_target_count" -gt 0 && "$blocked_count" -eq 0 ]]; then
|
if [[ "$hidden_target_count" -gt 0 && "$blocked_count" -eq 0 ]]; then
|
||||||
msg="$(translate "All detected controllers/NVMe are already present in the selected VM.")\n\n$(translate "No additional device needs to be added.")"
|
msg="$(translate "All detected controllers/NVMe are already present in the selected VM.")\n\n$(translate "No additional device needs to be added.")"
|
||||||
else
|
else
|
||||||
msg="$(translate "No safe controllers/NVMe devices are available for passthrough.")\n\n${blocked_report}"
|
msg="$(translate "No available Controllers/NVMe devices were found.")\n\n"
|
||||||
|
if [[ $blocked_count -gt 0 ]]; then
|
||||||
|
msg+="$(translate "Hidden for safety"):\n${blocked_report}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
whiptail --title "Controller + NVMe" --msgbox "$msg" 22 100
|
whiptail --title "Controller + NVMe" --msgbox "$msg" 22 100
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $blocked_count -gt 0 ]]; then
|
|
||||||
whiptail --title "Controller + NVMe" --msgbox "$(translate "Some controllers were hidden because they have host system disks attached.")\n\n${blocked_report}" 22 100
|
|
||||||
fi
|
|
||||||
|
|
||||||
local selected
|
local selected
|
||||||
selected=$(whiptail --title "Controller + NVMe" --checklist \
|
selected=$(whiptail --title "Controller + NVMe" --checklist \
|
||||||
"$(translate "Select controllers/NVMe to passthrough (safe devices only):")\n\n$(translate "Only safe devices are shown in this list.")" 20 96 10 \
|
"$(translate "Select available Controllers/NVMe to add:")" 20 96 10 \
|
||||||
"${menu_items[@]}" 3>&1 1>&2 2>&3) || return 1
|
"${menu_items[@]}" 3>&1 1>&2 2>&3) || return 1
|
||||||
|
|
||||||
CONTROLLER_NVME_PCIS=()
|
CONTROLLER_NVME_PCIS=()
|
||||||
|
|||||||
Reference in New Issue
Block a user