first implementation of UEFI support
This commit is contained in:
@@ -4,6 +4,26 @@ resource "libvirt_domain" "domain" {
|
||||
memory = var.memory
|
||||
vcpu = var.vcpu
|
||||
cloudinit = libvirt_cloudinit_disk.commoninit.id
|
||||
|
||||
# ---- optional UEFI support ------------------------------------
|
||||
# Firmware – only add the string when a path is supplied
|
||||
firmware = can(var.uefi_firmware) && length(var.uefi_firmware) > 0 ? var.uefi_firmware : null
|
||||
|
||||
# NVRAM block – dynamic block that is evaluated once per VM
|
||||
dynamic "nvram" {
|
||||
# create the block once if a firmware path *and* a template were given
|
||||
for_each = (can(var.uefi_firmware) && length(var.uefi_firmware) > 0
|
||||
&& can(var.uefi_nvram_template) && length(var.uefi_nvram_template) > 0
|
||||
) ? [1] : []
|
||||
|
||||
content {
|
||||
# The NVRAM filename is per‑VM, but we can honour an optional suffix
|
||||
file = "/var/lib/libvirt/qemu/nvram/${var.vm_name}-${count.index}${var.uefi_nvram_file_suffix}_VARS.fd"
|
||||
template = var.uefi_nvram_template
|
||||
}
|
||||
}
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
cpu {
|
||||
mode = "host-passthrough"
|
||||
}
|
||||
|
@@ -101,4 +101,34 @@ variable "dns_local_only" {
|
||||
description = "DNS requests only resolved by virtual network's DNS server"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "uefi_firmware" {
|
||||
description = <<EOT
|
||||
Path to the UEFI firmware binary (OVMF_CODE.fd, QEMU_CODE.fd, …).
|
||||
Leave empty (or omit on the module call) to create a plain BIOS VM.
|
||||
EOT
|
||||
type = string
|
||||
default = "" # “BIOS only” when empty
|
||||
}
|
||||
|
||||
variable "uefi_nvram_template" {
|
||||
description = <<EOT
|
||||
Path to an NV‑RAM template that backs the UEFI NVRAM.
|
||||
If you specify a template, the VM will get a writable NVRAM block.
|
||||
Leave empty for a plain BIOS VM or if you don’t need UEFI NVRAM.
|
||||
EOT
|
||||
type = string
|
||||
default = "" # no NVRAM when empty
|
||||
}
|
||||
|
||||
variable "uefi_nvram_file_suffix" {
|
||||
description = <<EOT
|
||||
Optional file‑suffix fragment that is appended to the
|
||||
generated NVRAM file name. Useful when you want to put the
|
||||
files under a dedicated directory (`/var/lib/libvirt/qemu/uefi/nvram/…`).
|
||||
Empty string means “no suffix” (default behaviour).
|
||||
EOT
|
||||
type = string
|
||||
default = ""
|
||||
}
|
Reference in New Issue
Block a user