From a64c538f7fa6b95f4a4bc8cabfd598d2ada149a0 Mon Sep 17 00:00:00 2001
From: Andreas Bleischwitz <ableisch@redhat.com>
Date: Tue, 28 Nov 2017 18:22:40 +0100
Subject: [PATCH] made <source>...</source> and it's sub-elements conditional
---
lib/vagrant-libvirt/templates/domain.xml.erb | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb
index 7fd991e..74b483c 100644
--- a/lib/vagrant-libvirt/templates/domain.xml.erb
+++ b/lib/vagrant-libvirt/templates/domain.xml.erb
@@ -112,11 +112,16 @@
<% @channels.each do |channel| %>
<channel type='<%= channel[:type] %>' >
- <source mode='<%= channel[:source_mode] %>'
+ <%if channel[:source_mode] or channel[:source_path] %>
+ <source
+ <% if channel[:source_mode] %>
+ mode='<%= channel[:source_mode] %>'
+ <% end %>
<% if channel[:source_path] %>
path="<%= channel[:source_path] %>"
<% end %>
/>
+ <% end %>
<target type='<%= channel[:target_type] %>'
<% if channel[:target_name] %>
name="<%= channel[:target_name] %>"