diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb
index ab0db55..995b328 100644
--- a/lib/vagrant-libvirt/action/create_domain.rb
+++ b/lib/vagrant-libvirt/action/create_domain.rb
@@ -79,6 +79,9 @@ module VagrantPlugins
# Input
@inputs = config.inputs
+ # Channels
+ @channels = config.channels
+
# PCI device passthrough
@pcis = config.pcis
@@ -205,6 +208,11 @@ module VagrantPlugins
env[:ui].info(" -- INPUT: type=#{input[:type]}, bus=#{input[:bus]}")
end
+ @channels.each do |channel|
+ env[:ui].info(" -- CHANNEL: type=#{channel[:type]}, mode=#{channel[:source_mode]}")
+ env[:ui].info(" -- CHANNEL: target_type=#{channel[:target_type]}, target_name=#{channel[:target_name]}")
+ end
+
@pcis.each do |pci|
env[:ui].info(" -- PCI passthrough: #{pci[:bus]}:#{pci[:slot]}.#{pci[:function]}")
end
diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb
index 21b95d7..84d7462 100644
--- a/lib/vagrant-libvirt/config.rb
+++ b/lib/vagrant-libvirt/config.rb
@@ -103,6 +103,9 @@ module VagrantPlugins
# Inputs
attr_accessor :inputs
+ # Channels
+ attr_accessor :channels
+
# PCI device passthrough
attr_accessor :pcis
@@ -177,6 +180,9 @@ module VagrantPlugins
# Inputs
@inputs = UNSET_VALUE
+ # Channels
+ @channels = UNSET_VALUE
+
# PCI device passthrough
@pcis = UNSET_VALUE
@@ -255,6 +261,32 @@ module VagrantPlugins
})
end
+ def channel(options={})
+ if options[:type].nil?
+ raise "Channel type must be specified."
+ elsif options[:type] == 'unix' && options[:target_type] == 'guestfwd'
+ # Guest forwarding requires a target (ip address) and a port
+ if options[:target_address].nil? || options[:target_port].nil? ||
+ options[:source_path].nil?
+ raise 'guestfwd requires target_address, target_port and source_path'
+ end
+ end
+
+ if @channels == UNSET_VALUE
+ @channels = []
+ end
+
+ @channels.push({
+ type: options[:type],
+ source_mode: options[:source_mode],
+ source_path: options[:source_path],
+ target_address: options[:target_address],
+ target_name: options[:target_name],
+ target_port: options[:target_port],
+ target_type: options[:target_type]
+ })
+ end
+
def pci(options={})
if options[:bus].nil? || options[:slot].nil? || options[:function].nil?
raise 'Bus AND slot AND function must be specified. Check `lspci` for that numbers.'
@@ -465,6 +497,9 @@ module VagrantPlugins
# Inputs
@inputs = [{:type => "mouse", :bus => "ps2"}] if @inputs == UNSET_VALUE
+ # Channels
+ @channels = [{:target => "unix", :source_mode => "bind"}] if @channels == UNSET_VALUE
+
# PCI device passthrough
@pcis = [] if @pcis == UNSET_VALUE
diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb
index 0594866..d35a595 100644
--- a/lib/vagrant-libvirt/templates/domain.xml.erb
+++ b/lib/vagrant-libvirt/templates/domain.xml.erb
@@ -96,6 +96,27 @@
+<% @channels.each do |channel| %>
+
+
+ path="<%= channel[:source_path] %>"
+ <% end %>
+ />
+
+ name="<%= channel[:target_name] %>"
+ <% end %>
+ <% if channel[:target_address] %>
+ address="<%= channel[:target_address] %>"
+ <% end %>
+ <% if channel[:target_port] %>
+ port="<%= channel[:target_port] %>"
+ <% end %>
+ />
+
+<% end %>
+
<% @inputs.each do |input| %>
<% end %>