summaryrefslogtreecommitdiff
path: root/roles/vm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-04-15 00:05:11 +0200
committerChristian Pointner <equinox@spreadspace.org>2022-04-15 00:05:11 +0200
commite0f898d623a61d591a99cd2fa99f77d02f49fd7a (patch)
treef298fa185815f9d283fc15e6922d5638f6169d32 /roles/vm
parentadd 2 jitsi instances for glt 2022 (diff)
vm/guest: add support for virtiofs
Diffstat (limited to 'roles/vm')
-rw-r--r--roles/vm/guest/base/tasks/Debian.yml12
-rw-r--r--roles/vm/guest/create/templates/libvirt-domain.xml.j216
2 files changed, 28 insertions, 0 deletions
diff --git a/roles/vm/guest/base/tasks/Debian.yml b/roles/vm/guest/base/tasks/Debian.yml
index 74778d8e..1dfc4168 100644
--- a/roles/vm/guest/base/tasks/Debian.yml
+++ b/roles/vm/guest/base/tasks/Debian.yml
@@ -59,3 +59,15 @@
regexp: "^{{ item.key }}="
line: "{{ item.key }}={{ item.value }}"
notify: update grub
+
+
+- name: mount virtiofs shares from host
+ loop: "{{ install.vm.virtiofs | default({}) | dict2items }}"
+ loop_control:
+ label: "{{ item.key }} -> {{ item.value.dest }}"
+ mount:
+ src: "{{ item.key }}"
+ path: "{{ item.value.dest }}"
+ fstype: "virtiofs"
+ opts: "{{ item.value.mnt_opts | default(omit) }}"
+ state: mounted
diff --git a/roles/vm/guest/create/templates/libvirt-domain.xml.j2 b/roles/vm/guest/create/templates/libvirt-domain.xml.j2
index 96b12a74..a7d584dc 100644
--- a/roles/vm/guest/create/templates/libvirt-domain.xml.j2
+++ b/roles/vm/guest/create/templates/libvirt-domain.xml.j2
@@ -2,6 +2,12 @@
<name>{{ inventory_hostname }}</name>
<memory>{{ ((install.vm.memory | human_to_bytes) / 1024) | int }}</memory>
<currentMemory>{{ ((install.vm.memory | human_to_bytes) / 1024) | int }}</currentMemory>
+{% if 'virtiofs' in install.vm %}
+ <memoryBacking>
+ <source type='memfd'/>
+ <access mode='shared'/>
+ </memoryBacking>
+{% endif %}
<vcpu>{{ install.vm.numcpus }}</vcpu>
<os>
<type arch='x86_64' machine='q35'>hvm</type>
@@ -73,6 +79,16 @@
{% endfor %}
{% endif %}
+{% if 'virtiofs' in install.vm %}
+{% for tag,fs in install.vm.virtiofs.items() %}
+ <filesystem type='mount' accessmode='passthrough'>
+ <driver type='virtiofs'/>
+ <source dir='{{ fs.src }}'/>
+ <target dir='{{ tag }}'/>
+ </filesystem>
+{% endfor %}
+
+{% endif %}
{% if install.interfaces %}
{% for if in install.interfaces %}
<interface type='bridge'>