diff --git a/README.md b/README.md index eccd59f..08b8106 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb index 504c973..fcee258 100644 --- a/lib/vagrant-libvirt/action/create_domain.rb +++ b/lib/vagrant-libvirt/action/create_domain.rb @@ -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 diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 55eb513..6e28724 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -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) diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb index fdb7e4a..5c4a3d8 100644 --- a/lib/vagrant-libvirt/templates/domain.xml.erb +++ b/lib/vagrant-libvirt/templates/domain.xml.erb @@ -22,7 +22,7 @@ - + <%# we need to ensure a unique target dev -%>