Volume driver cache parameter

This commit is contained in:
Jevgeni Kiski 2013-09-14 15:33:44 +03:00
parent eba55990c4
commit 5d3ea31191
4 changed files with 7 additions and 1 deletions

View File

@ -103,6 +103,7 @@ This provider exposes quite a few provider-specific configuration options:
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
* `cpus` - Number of virtual cpus. Defaults to 1 if not set.
* `nested` - [Enable nested virtualization](https://github.com/torvalds/linux/blob/master/Documentation/virtual/kvm/nested-vmx.txt). Default is false.
* `volume_cache` - cache attribute controls the cache mechanism, possible values are "default", "none", "writethrough", "writeback", "directsync" and "unsafe". [See driver->cache in libvirt documentation](http://libvirt.org/formatdomain.html#elementsDisks).
Specific domain settings can be set for each domain separately in multi-VM
environment. Example below shows a part of Vagrantfile, where specific options
@ -116,6 +117,7 @@ Vagrant.configure("2") do |config|
domain.memory = 2048
domain.cpus = 2
domain.nested = true
domain.volume_cache = 'none'
end
end

View File

@ -21,6 +21,7 @@ module VagrantPlugins
@cpus = config.cpus
@nested = config.nested
@memory_size = config.memory*1024
@domain_volume_cache = config.volume_cache
# TODO get type from driver config option
@domain_type = 'kvm'
@ -42,6 +43,7 @@ module VagrantPlugins
env[:ui].info(" -- Base box: #{env[:machine].box.name}")
env[:ui].info(" -- Storage pool: #{env[:machine].provider_config.storage_pool_name}")
env[:ui].info(" -- Image: #{@domain_volume_path}")
env[:ui].info(" -- Volume Cache: #{@domain_volume_cache}")
# Create libvirt domain.
# Is there a way to tell fog to create new domain with already

View File

@ -39,6 +39,7 @@ module VagrantPlugins
@memory = UNSET_VALUE
@cpus = UNSET_VALUE
@nested = UNSET_VALUE
@volume_cache = UNSET_VALUE
end
def finalize!
@ -53,6 +54,7 @@ module VagrantPlugins
@memory = 512 if @memory == UNSET_VALUE
@cpus = 1 if @cpus == UNSET_VALUE
@nested = false if @nested == UNSET_VALUE
@volume_cache = 'default' if @volume_cache == UNSET_VALUE
end
def validate(machine)

View File

@ -22,7 +22,7 @@
<clock offset='utc'/>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<driver name='qemu' type='qcow2' cache='<%= @domain_volume_cache %>'/>
<source file='<%= @domain_volume_path %>'/>
<%# we need to ensure a unique target dev -%>
<target dev='vda' bus='virtio'/>