Skip to content

Commit 3702892

Browse files
authored
Merge pull request #83 from stackhpc/efi
Add efi support
2 parents 19fa75b + acf6079 commit 3702892

File tree

7 files changed

+34
-1
lines changed

7 files changed

+34
-1
lines changed

Diff for: README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ Role Variables
166166
- `autostart`: Whether to start the VM when the host starts up. Default is
167167
`true`.
168168

169+
- `boot_firmware`: Can be one of: `bios`, or `efi`. Defaults to `bios`.
170+
169171
- `xml_file`: Optionally supply a modified XML template. Base customisation
170172
off the default `vm.xml.j2` template so as to include the expected jinja
171173
expressions the role uses.
@@ -226,7 +228,7 @@ Example Playbook
226228
- type: 'block'
227229
format: 'raw'
228230
dev: '/dev/sda'
229-
231+
230232
interfaces:
231233
- network: 'br-datacentre'
232234

Diff for: defaults/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ libvirt_vms:
8686
# XML template file to source domain definition
8787
xml_file: vm.xml.j2
8888

89+
# May be one of: bios, or efi.
90+
boot_firmware: bios
91+
8992
# Variables to add to the enviroment that is used to execute virsh commands
9093
libvirt_vm_virsh_default_env: "{{ { 'LIBVIRT_DEFAULT_URI': libvirt_vm_uri } if libvirt_vm_uri else {} }}"
9194

Diff for: tasks/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
autostart: "{{ vm.autostart | default(true) }}"
4646
enable_vnc: "{{ vm.enable_vnc | default(false) }}"
4747
enable_spice: "{{ vm.enable_spice | default(false) }}"
48+
boot_firmware: "{{ vm.boot_firmware | default('bios', true) | lower }}"
4849
with_items: "{{ libvirt_vms }}"
4950
loop_control:
5051
loop_var: vm

Diff for: templates/vm.xml.j2

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
<boot dev='cdrom'/>
2323
<boot dev='network'/>
2424
<bios useserial='yes'/>
25+
{% if boot_firmware == "efi" %}
26+
{# NOTE: pflash requires qemu 1.6 or newer. There are alternatives for older versions, but
27+
they do not work with secure boot. See OVMF readme for an overview #}
28+
<loader readonly='yes' type='pflash'>{{ libvirt_vm_ovmf_efi_firmware_path }}</loader>
29+
<nvram template='{{ libvirt_vm_ovmf_efi_variable_store_path }}'/>
30+
{% endif %}
2531
</os>
2632
<features>
2733
<acpi/>

Diff for: vars/Archlinux.yml

+7
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ libvirt_vm_script_env: >-
1010
1111
# Archlinux qemu comes with kvm support compiled in
1212
libvirt_vm_emulator: /usr/bin/qemu-system-x86_64
13+
14+
# Path to template OVMF efi variable store. A copy will be created
15+
# for each VM created.
16+
libvirt_vm_ovmf_efi_variable_store_path: /usr/share/OVMF/OVMF_VARS.fd
17+
18+
# Path to OVMF efi firmware
19+
libvirt_vm_ovmf_efi_firmware_path: /usr/share/OVMF/OVMF_CODE.fd

Diff for: vars/Debian.yml

+7
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ libvirt_vm_script_env_debian:
1010

1111
libvirt_vm_script_env: >-
1212
{{ libvirt_vm_script_env_debian | combine(libvirt_vm_virsh_default_env) }}
13+
14+
# Path to template OVMF efi variable store. A copy will be created
15+
# for each VM created.
16+
libvirt_vm_ovmf_efi_variable_store_path: /usr/share/OVMF/OVMF_VARS.fd
17+
18+
# Path to OVMF efi firmware
19+
libvirt_vm_ovmf_efi_firmware_path: /usr/share/OVMF/OVMF_CODE.fd

Diff for: vars/RedHat.yml

+7
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ libvirt_vm_script_env_redhat:
1010

1111
libvirt_vm_script_env: >-
1212
{{ libvirt_vm_script_env_redhat | combine(libvirt_vm_virsh_default_env) }}
13+
14+
# Path to template OVMF efi variable store. A copy will be created
15+
# for each VM created.
16+
libvirt_vm_ovmf_efi_variable_store_path: /usr/share/edk2/ovmf/OVMF_VARS.fd
17+
18+
# Path to OVMF efi firmware
19+
libvirt_vm_ovmf_efi_firmware_path: /usr/share/edk2/ovmf/OVMF_CODE.cc.fd

0 commit comments

Comments
 (0)