diff --git a/README.md b/README.md
index 1d8e8e5..96205e9 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,7 @@ can help a lot :-)
- [CDROMs](#cdroms)
- [Input](#input)
- [PCI device passthrough](#pci-device-passthrough)
+- [Random number generator passthrough](#random-number-generator-passthrough)
- [CPU Features](#cpu-features)
- [No box and PXE boot](#no-box-and-pxe-boot)
- [SSH Access To VM](#ssh-access-to-vm)
@@ -701,6 +702,21 @@ Vagrant.configure("2") do |config|
end
```
+## Random number generator passthrough
+
+You can pass through `/dev/random` to your VM by configuring the domain like this:
+
+```ruby
+Vagrant.configure("2") do |config|
+ config.vm.provider :libvirt do |libvirt|
+ # Pass through /dev/random from the host to the VM
+ libvirt.random :model => 'random'
+ end
+end
+```
+
+At the moment only the `random` backend is supported.
+
## CPU features
You can specify CPU feature policies via `libvirt.cpu_feature`. Available
diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb
index 7039763..0cbb3b1 100644
--- a/lib/vagrant-libvirt/action/create_domain.rb
+++ b/lib/vagrant-libvirt/action/create_domain.rb
@@ -89,6 +89,9 @@ module VagrantPlugins
# USB device passthrough
@usbs = config.usbs
+ # RNG device passthrough
+ @rng =config.rng
+
config = env[:machine].provider_config
@domain_type = config.driver
@@ -219,6 +222,10 @@ module VagrantPlugins
env[:ui].info(" -- PCI passthrough: #{pci[:bus]}:#{pci[:slot]}.#{pci[:function]}")
end
+ if !@rng[:model].nil?
+ env[:ui].info(" -- RNG device model: #{@rng[:model]}")
+ end
+
@usbs.each do |usb|
usb_dev = []
usb_dev.push("bus=#{usb[:bus]}") if usb[:bus]
diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb
index 2b56bfb..eafdae8 100644
--- a/lib/vagrant-libvirt/config.rb
+++ b/lib/vagrant-libvirt/config.rb
@@ -111,6 +111,9 @@ module VagrantPlugins
# PCI device passthrough
attr_accessor :pcis
+ # Random number device passthrough
+ attr_accessor :rng
+
# USB device passthrough
attr_accessor :usbs
@@ -189,6 +192,9 @@ module VagrantPlugins
# PCI device passthrough
@pcis = UNSET_VALUE
+ # Random number device passthrough
+ @rng = UNSET_VALUE
+
# USB device passthrough
@usbs = UNSET_VALUE
@@ -317,6 +323,18 @@ module VagrantPlugins
})
end
+ def random(options={})
+ if !options[:model].nil? && options[:model] != "random"
+ raise 'The only supported rng backend is "random".'
+ end
+
+ if @rng == UNSET_VALUE
+ @rng = {}
+ end
+
+ @rng[:model] = options[:model]
+ 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.'
@@ -535,6 +553,9 @@ module VagrantPlugins
# PCI device passthrough
@pcis = [] if @pcis == UNSET_VALUE
+ # Random number generator passthrough
+ @rng = {} if @rng == UNSET_VALUE
+
# USB device passthrough
@usbs = [] if @usbs == UNSET_VALUE
diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb
index 01b9c8c..7a83c65 100644
--- a/lib/vagrant-libvirt/templates/domain.xml.erb
+++ b/lib/vagrant-libvirt/templates/domain.xml.erb
@@ -140,6 +140,11 @@
<%#End Video -%>
<% end %>
+ <% if @rng[:model] == "random"%>
+
+ /dev/random
+
+ <% end %>
<% @pcis.each do |pci| %>