Use grep for Pimox showcmd validation
This commit is contained in:
parent
c60413e2e2
commit
3c10516ab7
|
|
@ -312,21 +312,13 @@ cleanup() {
|
|||
trap cleanup 0
|
||||
|
||||
sudo \"\$qm_bin\" showcmd \"\$vmid\" --pretty >\"\$start_script\"
|
||||
if ! awk -v vmid=\"\$vmid\" '
|
||||
{
|
||||
for (i = 1; i <= NF; i++) {
|
||||
qemu_suffix = \"qemu-system-aarch64\"
|
||||
if ($i == "/usr/bin/kvm" || $i == "qemu-system-aarch64" || substr($i, length($i) - length(qemu_suffix) + 1) == qemu_suffix) kvm = 1
|
||||
if ($i == "-id" && (i + 1) <= NF && $(i + 1) == vmid) id = 1
|
||||
}
|
||||
}
|
||||
END { exit (kvm && id) ? 0 : 1 }
|
||||
' \"\$start_script\"; then
|
||||
if ! { grep -Fq -- '/usr/bin/kvm' \"\$start_script\" || grep -Fq -- 'qemu-system-aarch64' \"\$start_script\"; } ||
|
||||
! grep -Fq -- \"-id \$vmid\" \"\$start_script\"; then
|
||||
echo \"qm showcmd for VM \$vmid did not produce the expected KVM command\" >&2
|
||||
sed 's/^/ showcmd: /' \"\$start_script\" >&2
|
||||
exit 1
|
||||
fi
|
||||
smp_count=\$(awk '{ for (i = 1; i <= NF; i++) if ($i == "-smp") count++ } END { print count + 0 }' \"\$start_script\")
|
||||
smp_count=\$(grep -c '^[[:space:]]*-smp[[:space:]]' \"\$start_script\" || true)
|
||||
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
|
||||
exit 1
|
||||
|
|
|
|||
|
|
@ -1552,21 +1552,13 @@ cleanup() {
|
|||
trap cleanup 0
|
||||
|
||||
sudo \"\$qm_bin\" showcmd \"\$vmid\" --pretty >\"\$start_script\"
|
||||
if ! awk -v vmid=\"\$vmid\" '
|
||||
{
|
||||
for (i = 1; i <= NF; i++) {
|
||||
qemu_suffix = \"qemu-system-aarch64\"
|
||||
if (\$i == "/usr/bin/kvm" || \$i == "qemu-system-aarch64" || substr(\$i, length(\$i) - length(qemu_suffix) + 1) == qemu_suffix) kvm = 1
|
||||
if (\$i == "-id" && (i + 1) <= NF && \$(i + 1) == vmid) id = 1
|
||||
}
|
||||
}
|
||||
END { exit (kvm && id) ? 0 : 1 }
|
||||
' \"\$start_script\"; then
|
||||
if ! { grep -Fq -- '/usr/bin/kvm' \"\$start_script\" || grep -Fq -- 'qemu-system-aarch64' \"\$start_script\"; } ||
|
||||
! grep -Fq -- \"-id \$vmid\" \"\$start_script\"; then
|
||||
echo \"qm showcmd for VM \$vmid did not produce the expected KVM command\" >&2
|
||||
sed 's/^/ showcmd: /' \"\$start_script\" >&2
|
||||
exit 1
|
||||
fi
|
||||
smp_count=\$(awk '{ for (i = 1; i <= NF; i++) if (\$i == "-smp") count++ } END { print count + 0 }' \"\$start_script\")
|
||||
smp_count=\$(grep -c '^[[:space:]]*-smp[[:space:]]' \"\$start_script\" || true)
|
||||
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
|
||||
exit 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue