# VM Template vztmpl Format Issue

**Date**: 2025-12-11  
**Issue**: vztmpl templates cannot be used for QEMU VMs

---

## Problem

The provider code attempts to use `vztmpl` templates (LXC container templates) for QEMU VMs, which is incorrect.

**Template Format**: `local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst`

**Provider Behavior** (Line 297 in `client.go`):
```go
diskConfig = fmt.Sprintf("%s,format=qcow2", imageVolid)
// Results in: local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst,format=qcow2
```

**Problem**: Proxmox cannot use a `vztmpl` template as a QEMU VM disk. This format is for LXC containers only.

---

## Root Cause

1. **vztmpl templates** are for LXC containers
2. **QEMU VMs** need either:
   - Cloud images (`.img`, `.qcow2`) - requires `importdisk`
   - QEMU templates (VM templates converted from VMs)

3. The provider code doesn't distinguish between container templates and VM templates

---

## Solutions

### Option 1: Use Cloud Image (Current)
```yaml
image: "local:iso/ubuntu-22.04-cloud.img"
```

**Pros**:
- ✅ Works with current provider code
- ✅ Cloud-init ready
- ✅ Available in storage

**Cons**:
- ⚠️ Requires `importdisk` API (can cause locks)
- ⚠️ Slower VM creation
- ⚠️ Needs provider code fix for proper task monitoring

### Option 2: Create QEMU Template (Recommended Long-term)
1. Create VM from cloud image
2. Configure and customize
3. Convert to template: `qm template <vmid>`
4. Use template ID in image field

**Pros**:
- ✅ Fast cloning
- ✅ No import needed
- ✅ Pre-configured

**Cons**:
- ❌ Requires manual setup
- ❌ Need to maintain templates

### Option 3: Fix Provider Code (Best Long-term)
- Detect `vztmpl` format and reject for VMs
- Add proper task monitoring for `importdisk`
- Wait for import completion before config updates
- Better error handling

---

## Current Status

**VM 100**: Reverted to use cloud image format
- `image: "local:iso/ubuntu-22.04-cloud.img"`
- Will use `importdisk` API
- May experience lock issues until provider code is fixed

**All Other Templates**: Still using `vztmpl` format
- ⚠️ **Will fail** when deployed
- Need to be updated to cloud image format or QEMU template

---

## Next Steps

1. **Immediate**: Update all templates to use cloud image format
2. **Short-term**: Monitor VM 100 creation with cloud image
3. **Long-term**: Fix provider code for proper template handling
4. **Long-term**: Create QEMU templates for faster deployment

---

## Template Update Required

All 29 templates need to be updated from:
```yaml
image: "local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst"
```

To:
```yaml
image: "local:iso/ubuntu-22.04-cloud.img"
```

Or use QEMU template ID if available.

---

**Status**: ⚠️ **ISSUE IDENTIFIED - TEMPLATES NEED UPDATE**

