diff --git a/lib/jeannie/cluster.sh b/lib/jeannie/cluster.sh index f067bdd..b2d01c3 100644 --- a/lib/jeannie/cluster.sh +++ b/lib/jeannie/cluster.sh @@ -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 diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index 23c073f..8d0250c 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -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