Skip to content

Commit

Permalink
Add initial efidisk support (#732)
Browse files Browse the repository at this point in the history
* Add efidisk support

* Add documentation
  • Loading branch information
riverar authored Dec 6, 2023
1 parent 22bf42e commit 4a60273
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/resources/vm_qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,29 @@ See the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_h
| `slot` | `int` | | _(not sure what this is for, seems to be deprecated, do not use)_. |
| `storage_type` | `str` | | The type of pool that `storage` is backed by. You shouldn't need to specify this, use the `storage` parameter instead. |

### EFI Disk Block

The `efidisk` block is used to configure the disk used for EFI data storage. There may only be one EFI disk block.
The EFI disk will be automatically pre-loaded with distribution-specific and Microsoft Standard Secure Boot keys.

```hcl
resource "proxmox_vm_qemu" "resource-name" {
// ...
efidisk {
efitype = "4m"
storage = "local-lvm"
}
}
```

See the [docs about EFI disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_bios_and_uefi) for more details.

| Argument | Type | Default Value | Description |
|----------------|-------|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `efitype` | `str` | `"4m"` | The type of efi disk device to add. Options: `2m`, `4m` |
| `storage` | `str` | | **Required** The name of the storage pool on which to store the disk. |

### Serial Block

Create a serial device inside the VM (up to a maximum of 4 can be specified), and either pass through a host serial
Expand Down
29 changes: 29 additions & 0 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,29 @@ func resourceVmQemu() *schema.Resource {
},
},
},
"efidisk": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"storage": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"efitype": {
Type: schema.TypeString,
Optional: true,
Default: "4m",
ValidateFunc: validation.StringInSlice([]string{
"2m",
"4m",
}, false),
ForceNew: true,
},
},
},
},
"disk": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -935,6 +958,7 @@ func resourceVmQemuCreate(ctx context.Context, d *schema.ResourceData, meta inte

qemuNetworks, _ := ExpandDevicesList(d.Get("network").([]interface{}))
qemuDisks, _ := ExpandDevicesList(d.Get("disk").([]interface{}))
qemuEfiDisks, _ := ExpandDevicesList(d.Get("efidisk").([]interface{}))

serials := d.Get("serial").(*schema.Set)
qemuSerials, _ := DevicesSetToMap(serials)
Expand Down Expand Up @@ -995,6 +1019,11 @@ func resourceVmQemuCreate(ctx context.Context, d *schema.ResourceData, meta inte
if len(qemuVgaList) > 0 {
config.QemuVga = qemuVgaList[0].(map[string]interface{})
}

if len(qemuEfiDisks) > 0 {
config.EFIDisk = qemuEfiDisks[0]
}

log.Printf("[DEBUG][QemuVmCreate] checking for duplicate name: %s", vmName)
dupVmr, _ := client.GetVmRefByName(vmName)

Expand Down

0 comments on commit 4a60273

Please sign in to comment.