Files
football/vm/template.xml
reachableceo 88d670efbe fix: graceful TPM fallback in VM creation, fix vm_destroy cleanup
vm_create() now handles swtpm initialization gracefully:
- Pre-initializes swtpm state dir if /var/lib/libvirt/swtpm/ is writable
- Falls back to VM without TPM if swtpm setup fails (with clear warnings)
- Uses PID-suffixed paths for disk and ISO to avoid stale file conflicts
- Removed unused VM_DISK_PATH/VM_ISO_PATH globals (now local vars)

vm_destroy() cleanup:
- No longer references undefined local variables from vm_create
- Uses glob patterns to clean all VM files in /tmp/
- Explicitly preserves ISO in output/

Template changes:
- TPM is now @TPM_SECTION@ placeholder (injected based on swtpm availability)
- Allows same template to work with or without TPM

AGENTS.md additions:
- VM testing & swtpm setup documentation
- Direct QEMU alternative when libvirt has issues
- Session lessons: never delete ISO, never remove TPM, always test E2E

All 523 unit tests pass, 0 lint warnings.

💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
2026-05-07 12:39:47 -05:00

53 lines
1.5 KiB
XML

<domain type='kvm'>
<name>@VM_NAME@</name>
<uuid>@VM_UUID@</uuid>
<memory unit='MiB'>@VM_RAM@</memory>
<currentMemory unit='MiB'>@VM_RAM@</currentMemory>
<vcpu placement='static'>@VM_CPUS@</vcpu>
<os>
<type arch='x86_64' machine='q35'>hvm</type>
<loader readonly='yes' secure='@SECURE_BOOT@' type='pflash'>@UEFI_CODE@</loader>
<nvram template='@UEFI_VARS_TEMPLATE@'/>
<boot dev='cdrom'/>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<smm state='on'/>
</features>
<cpu mode='host-passthrough' check='none'/>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
</clock>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
@TPM_SECTION@
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='@VM_DISK@'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='@ISO_PATH@'/>
<target dev='sda' bus='sata'/>
<readonly/>
</disk>
<interface type='user'>
<model type='virtio'/>
</interface>
<graphics type='vnc' port='-1' autoport='yes'>
<listen type='address' address='127.0.0.1'/>
</graphics>
<video>
<model type='virtio' heads='1' primary='yes'/>
</video>
<console type='pty'>
<target type='serial' port='0'/>
</console>
</devices>
</domain>