From e0f898d623a61d591a99cd2fa99f77d02f49fd7a Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 15 Apr 2022 00:05:11 +0200 Subject: vm/guest: add support for virtiofs --- roles/vm/guest/base/tasks/Debian.yml | 12 ++++++++++++ roles/vm/guest/create/templates/libvirt-domain.xml.j2 | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'roles/vm/guest') 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 @@ {{ inventory_hostname }} {{ ((install.vm.memory | human_to_bytes) / 1024) | int }} {{ ((install.vm.memory | human_to_bytes) / 1024) | int }} +{% if 'virtiofs' in install.vm %} + + + + +{% endif %} {{ install.vm.numcpus }} hvm @@ -72,6 +78,16 @@ {% endfor %} {% endfor %} +{% endif %} +{% if 'virtiofs' in install.vm %} +{% for tag,fs in install.vm.virtiofs.items() %} + + + + + +{% endfor %} + {% endif %} {% if install.interfaces %} {% for if in install.interfaces %} -- cgit v1.2.3