update
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
action="${1:-}"
|
action="${1:-}"
|
||||||
FOLDER='/opt/idssys/ta-proxmenu'
|
FOLDER='/opt/idssys/ta-proxmenu'
|
||||||
VERS='2026.7.25-60'
|
VERS='2026.7.25-61'
|
||||||
|
|
||||||
noupdate=' '
|
noupdate=' '
|
||||||
|
|
||||||
|
|||||||
+33
-7
@@ -1218,17 +1218,43 @@ for guest in json.load(sys.stdin):
|
|||||||
|
|
||||||
TAPM_QEMU_CPU_MODEL() {
|
TAPM_QEMU_CPU_MODEL() {
|
||||||
local vmid="$1"
|
local vmid="$1"
|
||||||
|
local node="$2"
|
||||||
local config_output
|
local config_output
|
||||||
local cpu_model
|
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="$(
|
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'
|
[[ -n "$cpu_model" ]] || cpu_model='kvm64'
|
||||||
printf '%s\n' "$cpu_model"
|
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() {
|
DETECT_CPU() {
|
||||||
local answer
|
local answer
|
||||||
local cpu_model
|
local cpu_model
|
||||||
@@ -1243,7 +1269,7 @@ DETECT_CPU() {
|
|||||||
local -a failures=()
|
local -a failures=()
|
||||||
local -a successes=()
|
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
|
if ! command -v "$command" >/dev/null 2>&1; then
|
||||||
echo -e "${idsCL[LightRed]}${command} is required for CPU compatibility detection.${idsCL[Default]}"
|
echo -e "${idsCL[LightRed]}${command} is required for CPU compatibility detection.${idsCL[Default]}"
|
||||||
FINISH_FAILED_ACTION
|
FINISH_FAILED_ACTION
|
||||||
@@ -1283,7 +1309,7 @@ DETECT_CPU() {
|
|||||||
|
|
||||||
while IFS=$'\x1f' read -r vmid name node template; do
|
while IFS=$'\x1f' read -r vmid name node template; do
|
||||||
[[ -n "$vmid" ]] || continue
|
[[ -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]}"
|
echo -e "${idsCL[LightRed]}Could not read the CPU configuration for VMID ${vmid}.${idsCL[Default]}"
|
||||||
FINISH_FAILED_ACTION
|
FINISH_FAILED_ACTION
|
||||||
return
|
return
|
||||||
@@ -1319,8 +1345,8 @@ DETECT_CPU() {
|
|||||||
|
|
||||||
for guest in "${changes[@]}"; do
|
for guest in "${changes[@]}"; do
|
||||||
IFS=$'\x1f' read -r vmid name node template current_cpu <<< "$guest"
|
IFS=$'\x1f' read -r vmid name node template current_cpu <<< "$guest"
|
||||||
if qm set "$vmid" --cpu "$cpu_model" &&
|
if TAPM_SET_QEMU_CPU_MODEL "$vmid" "$node" "$cpu_model" &&
|
||||||
[[ "$(TAPM_QEMU_CPU_MODEL "$vmid")" == "$cpu_model" ]]; then
|
[[ "$(TAPM_QEMU_CPU_MODEL "$vmid" "$node")" == "$cpu_model" ]]; then
|
||||||
successes+=("$guest")
|
successes+=("$guest")
|
||||||
else
|
else
|
||||||
failures+=("$guest")
|
failures+=("$guest")
|
||||||
|
|||||||
Reference in New Issue
Block a user