mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Add memory backing configuration
This commit is contained in:
18
README.md
18
README.md
@@ -974,6 +974,24 @@ Vagrant.configure("2") do |config|
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Memory Backing
|
||||||
|
|
||||||
|
You can specify memoryBacking options via `libvirt.memorybacking`. Available options are shown below. Full documentation is available at the [libvirt _memoryBacking_ section](https://libvirt.org/formatdomain.html#elementsMemoryBacking).
|
||||||
|
|
||||||
|
NOTE: The hugepages `<page>` element is not yet supported
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.provider :libvirt do |libvirt|
|
||||||
|
libvirt.memorybacking :hugepages
|
||||||
|
libvirt.memorybacking :nosharepages
|
||||||
|
libvirt.memorybacking :locked
|
||||||
|
libvirt.memorybacking :source, :type => 'file'
|
||||||
|
libvirt.memorybacking :access, :mode => 'shared'
|
||||||
|
libvirt.memorybacking :allocation, :mode => 'immediate'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
## USB device passthrough
|
## USB device passthrough
|
||||||
|
|
||||||
You can specify multiple USB devices to passthrough to the VM via
|
You can specify multiple USB devices to passthrough to the VM via
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ module VagrantPlugins
|
|||||||
@disk_device = config.disk_device
|
@disk_device = config.disk_device
|
||||||
@nested = config.nested
|
@nested = config.nested
|
||||||
@memory_size = config.memory.to_i * 1024
|
@memory_size = config.memory.to_i * 1024
|
||||||
|
@memory_backing = config.memory_backing
|
||||||
@management_network_mac = config.management_network_mac
|
@management_network_mac = config.management_network_mac
|
||||||
@domain_volume_cache = config.volume_cache
|
@domain_volume_cache = config.volume_cache
|
||||||
@kernel = config.kernel
|
@kernel = config.kernel
|
||||||
@@ -182,6 +183,9 @@ module VagrantPlugins
|
|||||||
env[:ui].info(" -- Feature: #{feature}")
|
env[:ui].info(" -- Feature: #{feature}")
|
||||||
end
|
end
|
||||||
env[:ui].info(" -- Memory: #{@memory_size / 1024}M")
|
env[:ui].info(" -- Memory: #{@memory_size / 1024}M")
|
||||||
|
@memory_backing.each do |backing|
|
||||||
|
env[:ui].info(" -- Memory Backing: #{backing[:name]}: #{backing[:config].map { |k,v| "#{k}='#{v}'"}.join(' ')}")
|
||||||
|
end
|
||||||
env[:ui].info(" -- Management MAC: #{@management_network_mac}")
|
env[:ui].info(" -- Management MAC: #{@management_network_mac}")
|
||||||
env[:ui].info(" -- Loader: #{@loader}")
|
env[:ui].info(" -- Loader: #{@loader}")
|
||||||
if env[:machine].config.vm.box
|
if env[:machine].config.vm.box
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ module VagrantPlugins
|
|||||||
# Domain specific settings used while creating new domain.
|
# Domain specific settings used while creating new domain.
|
||||||
attr_accessor :uuid
|
attr_accessor :uuid
|
||||||
attr_accessor :memory
|
attr_accessor :memory
|
||||||
|
attr_accessor :memory_backing
|
||||||
attr_accessor :channel
|
attr_accessor :channel
|
||||||
attr_accessor :cpus
|
attr_accessor :cpus
|
||||||
attr_accessor :cpu_mode
|
attr_accessor :cpu_mode
|
||||||
@@ -164,6 +165,7 @@ module VagrantPlugins
|
|||||||
# Domain specific settings.
|
# Domain specific settings.
|
||||||
@uuid = UNSET_VALUE
|
@uuid = UNSET_VALUE
|
||||||
@memory = UNSET_VALUE
|
@memory = UNSET_VALUE
|
||||||
|
@memory_backing = UNSET_VALUE
|
||||||
@cpus = UNSET_VALUE
|
@cpus = UNSET_VALUE
|
||||||
@cpu_mode = UNSET_VALUE
|
@cpu_mode = UNSET_VALUE
|
||||||
@cpu_model = UNSET_VALUE
|
@cpu_model = UNSET_VALUE
|
||||||
@@ -313,6 +315,21 @@ module VagrantPlugins
|
|||||||
policy: options[:policy])
|
policy: options[:policy])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def memorybacking(option, config = {})
|
||||||
|
case option
|
||||||
|
when :source
|
||||||
|
raise 'Source type must be specified' if config[:type].nil?
|
||||||
|
when :access
|
||||||
|
raise 'Access mode must be specified' if config[:mode].nil?
|
||||||
|
when :allocation
|
||||||
|
raise 'Allocation mode must be specified' if config[:mode].nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
@memory_backing = [] if @memory_backing == UNSET_VALUE
|
||||||
|
@memory_backing.push(name: option,
|
||||||
|
config: config)
|
||||||
|
end
|
||||||
|
|
||||||
def input(options = {})
|
def input(options = {})
|
||||||
if options[:type].nil? || options[:bus].nil?
|
if options[:type].nil? || options[:bus].nil?
|
||||||
raise 'Input type AND bus must be specified'
|
raise 'Input type AND bus must be specified'
|
||||||
@@ -569,6 +586,7 @@ module VagrantPlugins
|
|||||||
# Domain specific settings.
|
# Domain specific settings.
|
||||||
@uuid = '' if @uuid == UNSET_VALUE
|
@uuid = '' if @uuid == UNSET_VALUE
|
||||||
@memory = 512 if @memory == UNSET_VALUE
|
@memory = 512 if @memory == UNSET_VALUE
|
||||||
|
@memory_backing = [] if @memory_backing == UNSET_VALUE
|
||||||
@cpus = 1 if @cpus == UNSET_VALUE
|
@cpus = 1 if @cpus == UNSET_VALUE
|
||||||
@cpu_mode = 'host-model' if @cpu_mode == UNSET_VALUE
|
@cpu_mode = 'host-model' if @cpu_mode == UNSET_VALUE
|
||||||
@cpu_model = if (@cpu_model == UNSET_VALUE) && (@cpu_mode == 'custom')
|
@cpu_model = if (@cpu_model == UNSET_VALUE) && (@cpu_mode == 'custom')
|
||||||
|
|||||||
@@ -25,6 +25,13 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</cpu>
|
</cpu>
|
||||||
|
|
||||||
|
<% unless @memory_backing.empty? %>
|
||||||
|
<memoryBacking>
|
||||||
|
<% @memory_backing.each do |backing| %>
|
||||||
|
<<%= backing[:name] %> <%= backing[:config].map { |k,v| "#{k}='#{v}'"}.join(' ') %>/>
|
||||||
|
<% end %>
|
||||||
|
</memoryBacking>
|
||||||
|
<% end%>
|
||||||
|
|
||||||
<os>
|
<os>
|
||||||
<% if @machine_type %>
|
<% if @machine_type %>
|
||||||
|
|||||||
Reference in New Issue
Block a user