Skip to content

Commit 6140738

Browse files
committed
Default to software emulation if target architecture != host_architecture
The qemu-kvm binary only supports the host architecture. We must therefore use the qemu-system-<architecture> binaries when the target architecture is not the same as the host architecture. Although it may be possible that the host CPU may support acceleration for a foreign architecture, I do not currently know of any chips that support this functionality. For this reason, we default to software emulation.
1 parent 435ea81 commit 6140738

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tasks/autodetect.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@
1414

1515
- name: Set a fact containing the virtualisation engine
1616
set_fact:
17-
libvirt_vm_engine: "{% if stat_kvm.stat.exists %}kvm{% else %}qemu{% endif %}"
17+
libvirt_vm_engine: >-
18+
{%- if ansible_architecture != libvirt_vm_arch -%}
19+
{# Virtualisation instructions are generally available only for the host
20+
architecture. Ideally we would test for virtualisation instructions, eg. vt-d
21+
as it is possible that another architecture could support these even
22+
if the emulated cpu architecture is not the same. #}
23+
qemu
24+
{%- elif stat_kvm.stat.exists -%}
25+
kvm
26+
{%- else -%}
27+
qemu
28+
{%- endif -%}
1829
when: libvirt_vm_engine is none
1930

2031
- name: Detect the virtualisation emulator

0 commit comments

Comments
 (0)