From 70f5c09cecf6268aabb7ca549b8882bf03706e3e Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 25 Jul 2026 23:29:44 -0500 Subject: [PATCH] update --- defaults.inc | 2 +- proxmenu-scripts.sh | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/defaults.inc b/defaults.inc index 220c5b2..83b56fd 100755 --- a/defaults.inc +++ b/defaults.inc @@ -3,7 +3,7 @@ action="${1:-}" FOLDER='/opt/idssys/ta-proxmenu' -VERS='2026.7.25-60' +VERS='2026.7.25-61' noupdate=' ' diff --git a/proxmenu-scripts.sh b/proxmenu-scripts.sh index 35c3f12..3777f0a 100755 --- a/proxmenu-scripts.sh +++ b/proxmenu-scripts.sh @@ -1218,17 +1218,43 @@ for guest in json.load(sys.stdin): TAPM_QEMU_CPU_MODEL() { local vmid="$1" + local node="$2" local config_output local cpu_model - config_output="$(qm config "$vmid" 2>/dev/null)" || return 1 + [[ "$vmid" =~ ^[1-9][0-9]{2,8}$ ]] || return 1 + [[ "$node" =~ ^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$ ]] || return 1 + config_output="$( + pvesh get "/nodes/${node}/qemu/${vmid}/config" \ + --output-format json 2>/dev/null + )" || return 1 cpu_model="$( - awk -F': ' '$1 == "cpu" { print $2; exit }' <<< "$config_output" - )" + QEMU_CONFIG_JSON="$config_output" python3 -c ' +import json, os +try: + config = json.loads(os.environ["QEMU_CONFIG_JSON"]) +except (TypeError, ValueError): + raise SystemExit(1) +cpu = config.get("cpu", "kvm64") +print(cpu if isinstance(cpu, str) and cpu.strip() else "kvm64") +' 2>/dev/null + )" || return 1 [[ -n "$cpu_model" ]] || cpu_model='kvm64' printf '%s\n' "$cpu_model" } +TAPM_SET_QEMU_CPU_MODEL() { + local vmid="$1" + local node="$2" + local cpu_model="$3" + + [[ "$vmid" =~ ^[1-9][0-9]{2,8}$ ]] || return 1 + [[ "$node" =~ ^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$ ]] || return 1 + [[ "$cpu_model" =~ ^x86-64-v(1|2-AES|3|4)$ ]] || return 1 + pvesh set "/nodes/${node}/qemu/${vmid}/config" \ + --cpu "$cpu_model" +} + DETECT_CPU() { local answer local cpu_model @@ -1243,7 +1269,7 @@ DETECT_CPU() { local -a failures=() local -a successes=() - for command in apt-get curl gpg install pvesh python3 qm; do + for command in apt-get curl gpg install pvesh python3; do if ! command -v "$command" >/dev/null 2>&1; then echo -e "${idsCL[LightRed]}${command} is required for CPU compatibility detection.${idsCL[Default]}" FINISH_FAILED_ACTION @@ -1283,7 +1309,7 @@ DETECT_CPU() { while IFS=$'\x1f' read -r vmid name node template; do [[ -n "$vmid" ]] || continue - current_cpu="$(TAPM_QEMU_CPU_MODEL "$vmid")" || { + current_cpu="$(TAPM_QEMU_CPU_MODEL "$vmid" "$node")" || { echo -e "${idsCL[LightRed]}Could not read the CPU configuration for VMID ${vmid}.${idsCL[Default]}" FINISH_FAILED_ACTION return @@ -1319,8 +1345,8 @@ DETECT_CPU() { for guest in "${changes[@]}"; do IFS=$'\x1f' read -r vmid name node template current_cpu <<< "$guest" - if qm set "$vmid" --cpu "$cpu_model" && - [[ "$(TAPM_QEMU_CPU_MODEL "$vmid")" == "$cpu_model" ]]; then + if TAPM_SET_QEMU_CPU_MODEL "$vmid" "$node" "$cpu_model" && + [[ "$(TAPM_QEMU_CPU_MODEL "$vmid" "$node")" == "$cpu_model" ]]; then successes+=("$guest") else failures+=("$guest")