Update create VM

This commit is contained in:
MacRimi 2025-05-02 14:25:11 +02:00
parent 9533b7a664
commit c0ea774104
3 changed files with 37 additions and 0 deletions

View File

@ -173,6 +173,7 @@ function select_linux_custom_iso() {
done < <(find "$ISO_DIR" -type f -iname "*.iso" | sort) done < <(find "$ISO_DIR" -type f -iname "*.iso" | sort)
if [[ ${#ISO_LIST[@]} -eq 0 ]]; then if [[ ${#ISO_LIST[@]} -eq 0 ]]; then
header_info
msg_error "$(translate "No ISO images found in $ISO_DIR.")" msg_error "$(translate "No ISO images found in $ISO_DIR.")"
sleep 2 sleep 2
return 1 return 1
@ -183,6 +184,7 @@ function select_linux_custom_iso() {
"${ISO_LIST[@]}" 3>&1 1>&2 2>&3) "${ISO_LIST[@]}" 3>&1 1>&2 2>&3)
if [[ -z "$ISO_FILE" ]]; then if [[ -z "$ISO_FILE" ]]; then
header_info
msg_warn "$(translate "No ISO selected.")" msg_warn "$(translate "No ISO selected.")"
return 1 return 1
fi fi

View File

@ -70,6 +70,8 @@ function select_existing_iso() {
ISO_NAME="$ISO_FILE" ISO_NAME="$ISO_FILE"
export ISO_PATH ISO_FILE ISO_NAME export ISO_PATH ISO_FILE ISO_NAME
export OS_TYPE="windows"
return 0 return 0
} }
@ -86,5 +88,7 @@ function detect_latest_iso_created() {
ISO_PATH="$ISO_FILE" ISO_PATH="$ISO_FILE"
export ISO_PATH ISO_FILE ISO_NAME export ISO_PATH ISO_FILE ISO_NAME
export OS_TYPE="windows"
return 0 return 0
} }

View File

@ -173,6 +173,37 @@ function create_vm() {
# Añadir TPM si es Windows
if [[ "$OS_TYPE" == "windows" ]]; then
msg_info "$(translate "Configuring TPM device")"
TPM_STORAGE=$(select_efi_storage "$VMID")
TPM_NAME="vm-${VMID}-tpmstate"
STORAGE_TYPE=$(pvesm status -storage "$TPM_STORAGE" | awk 'NR>1 {print $2}')
case "$STORAGE_TYPE" in
nfs | dir)
TPM_EXT=".raw"
TPM_REF="$VMID/"
;;
*)
TPM_EXT=""
TPM_REF=""
;;
esac
if pvesm alloc "$TPM_STORAGE" "$VMID" "$TPM_NAME$TPM_EXT" 4M >/dev/null 2>&1; then
qm set "$VMID" -tpmstate0 "$TPM_STORAGE:${TPM_REF}${TPM_NAME}${TPM_EXT},version=2.0" >/dev/null 2>&1
qm set "$VMID" -tpmdev "tpm-tis" >/dev/null 2>&1
msg_ok "$(translate "TPM device added to VM")"
else
msg_warn "$(translate "Failed to add TPM device.")"
fi
fi
# ========================================================== # ==========================================================
# Crear discos virtuales o físicos con interfaz seleccionada # Crear discos virtuales o físicos con interfaz seleccionada
# ========================================================== # ==========================================================