Relax Pimox showcmd validation
This commit is contained in:
parent
7b3b7a8d8a
commit
0226f04546
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck disable=SC2140
|
# shellcheck disable=SC2140,SC2154
|
||||||
|
|
||||||
pimox_ssh() {
|
pimox_ssh() {
|
||||||
local host="$1"
|
local host="$1"
|
||||||
|
|
@ -313,14 +313,19 @@ trap cleanup 0
|
||||||
|
|
||||||
sudo \"\$qm_bin\" showcmd \"\$vmid\" --pretty >\"\$start_script\"
|
sudo \"\$qm_bin\" showcmd \"\$vmid\" --pretty >\"\$start_script\"
|
||||||
if ! awk -v vmid=\"\$vmid\" '
|
if ! awk -v vmid=\"\$vmid\" '
|
||||||
NR == 1 && ($1 == "/usr/bin/kvm" || $1 ~ /qemu-system-aarch64$/) { kvm = 1 }
|
{
|
||||||
$1 == "-id" && $2 == vmid { id = 1 }
|
for (i = 1; i <= NF; i++) {
|
||||||
|
if ($i == "/usr/bin/kvm" || $i ~ /(^|/)qemu-system-aarch64$/) kvm = 1
|
||||||
|
if ($i == "-id" && (i + 1) <= NF && $(i + 1) == vmid) id = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
END { exit (kvm && id) ? 0 : 1 }
|
END { exit (kvm && id) ? 0 : 1 }
|
||||||
' \"\$start_script\"; then
|
' \"\$start_script\"; then
|
||||||
echo \"qm showcmd for VM \$vmid did not produce the expected KVM command\" >&2
|
echo \"qm showcmd for VM \$vmid did not produce the expected KVM command\" >&2
|
||||||
|
sed 's/^/ showcmd: /' \"\$start_script\" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
smp_count=\$(awk '$1 == "-smp" { count++ } END { print count + 0 }' \"\$start_script\")
|
smp_count=\$(awk '{ for (i = 1; i <= NF; i++) if ($i == "-smp") count++ } END { print count + 0 }' \"\$start_script\")
|
||||||
if [ \"\$smp_count\" -ne 1 ]; then
|
if [ \"\$smp_count\" -ne 1 ]; then
|
||||||
echo \"Expected one native -smp argument for VM \$vmid, found \$smp_count. Remove stale qm args before starting.\" >&2
|
echo \"Expected one native -smp argument for VM \$vmid, found \$smp_count. Remove stale qm args before starting.\" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -1553,14 +1553,19 @@ trap cleanup 0
|
||||||
|
|
||||||
sudo \"\$qm_bin\" showcmd \"\$vmid\" --pretty >\"\$start_script\"
|
sudo \"\$qm_bin\" showcmd \"\$vmid\" --pretty >\"\$start_script\"
|
||||||
if ! awk -v vmid=\"\$vmid\" '
|
if ! awk -v vmid=\"\$vmid\" '
|
||||||
NR == 1 && (\$1 == "/usr/bin/kvm" || \$1 ~ /qemu-system-aarch64$/) { kvm = 1 }
|
{
|
||||||
\$1 == "-id" && \$2 == vmid { id = 1 }
|
for (i = 1; i <= NF; i++) {
|
||||||
|
if (\$i == "/usr/bin/kvm" || \$i ~ /(^|/)qemu-system-aarch64$/) kvm = 1
|
||||||
|
if (\$i == "-id" && (i + 1) <= NF && \$(i + 1) == vmid) id = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
END { exit (kvm && id) ? 0 : 1 }
|
END { exit (kvm && id) ? 0 : 1 }
|
||||||
' \"\$start_script\"; then
|
' \"\$start_script\"; then
|
||||||
echo \"qm showcmd for VM \$vmid did not produce the expected KVM command\" >&2
|
echo \"qm showcmd for VM \$vmid did not produce the expected KVM command\" >&2
|
||||||
|
sed 's/^/ showcmd: /' \"\$start_script\" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
smp_count=\$(awk '\$1 == "-smp" { count++ } END { print count + 0 }' \"\$start_script\")
|
smp_count=\$(awk '{ for (i = 1; i <= NF; i++) if (\$i == "-smp") count++ } END { print count + 0 }' \"\$start_script\")
|
||||||
if [ \"\$smp_count\" -ne 1 ]; then
|
if [ \"\$smp_count\" -ne 1 ]; then
|
||||||
echo \"Expected one native -smp argument for VM \$vmid, found \$smp_count. Remove stale qm args before starting.\" >&2
|
echo \"Expected one native -smp argument for VM \$vmid, found \$smp_count. Remove stale qm args before starting.\" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue