Compare commits

..

No commits in common. "bcf45c6e8bcd60e2d805087b5c6147667dd86214" and "3c10516ab7db0cfb6c0b824b9ae2cfbd72b38f62" have entirely different histories.

1 changed files with 17 additions and 16 deletions

View File

@ -133,18 +133,17 @@ resource "null_resource" "pimox_template_vm_create" {
pimox_user = var.pimox_user pimox_user = var.pimox_user
ssh_key_path = var.pimox_ssh_key_path ssh_key_path = var.pimox_ssh_key_path
qm_bin = var.pimox_qm_bin qm_bin = var.pimox_qm_bin
builder_version = "7" builder_version = "6"
config_hash = local.config_hash config_hash = local.config_hash
replace_existing = tostring(var.pimox_template_replace_existing) vmid = tostring(var.pimox_template_vmid)
vmid = tostring(var.pimox_template_vmid) name = var.pimox_template_name
name = var.pimox_template_name cores = tostring(var.pimox_template_cores)
cores = tostring(var.pimox_template_cores) memory = tostring(var.pimox_template_memory)
memory = tostring(var.pimox_template_memory) bridge = var.pimox_template_bridge
bridge = var.pimox_template_bridge net0 = local.pimox_template_net0
net0 = local.pimox_template_net0 kvm_cpuset = var.pimox_template_kvm_cpuset
kvm_cpuset = var.pimox_template_kvm_cpuset scsi0 = var.pimox_template_scsi0
scsi0 = var.pimox_template_scsi0 efidisk0 = var.pimox_template_efidisk0
efidisk0 = var.pimox_template_efidisk0
} }
connection { connection {
@ -196,13 +195,15 @@ start_vm() {
trap 'rm -f "$start_script"' 0 trap 'rm -f "$start_script"' 0
sudo "$qm_cmd" showcmd "$vmid" --pretty >"$start_script" sudo "$qm_cmd" showcmd "$vmid" --pretty >"$start_script"
if ! { grep -Fq -- '/usr/bin/kvm' "$start_script" || grep -Fq -- 'qemu-system-aarch64' "$start_script"; } || if ! awk -v vmid="$vmid" '
! grep -Fq -- "-id $vmid" "$start_script"; then NR == 1 && ($1 == "/usr/bin/kvm" || $1 ~ /qemu-system-aarch64$/) { kvm = 1 }
$1 == "-id" && $2 == vmid { id = 1 }
END { exit (kvm && id) ? 0 : 1 }
' "$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="$(grep -c '^[[:space:]]*-smp[[:space:]]' "$start_script" || true)" smp_count="$(awk '$1 == "-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