mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Add support for RNG passthrough
Allow passing through /dev/random from the host to the VM. This speeds up pretty much everything which needs entropy inside the VM.
This commit is contained in:
16
README.md
16
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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -140,6 +140,11 @@
|
||||
</video>
|
||||
<%#End Video -%>
|
||||
<% end %>
|
||||
<% if @rng[:model] == "random"%>
|
||||
<rng model='virtio'>
|
||||
<backend model='random'>/dev/random</backend>
|
||||
</rng>
|
||||
<% end %>
|
||||
<% @pcis.each do |pci| %>
|
||||
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||
<source>
|
||||
|
||||
Reference in New Issue
Block a user