[DRE-commits] [vagrant-libvirt] 68/104: Volume driver cache parameter

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:55:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.11
in repository vagrant-libvirt.

commit 5d3ea3119105c6d6d44b17543fe6b67be14c7f07
Author: Jevgeni Kiski <jevgeni.kiski at skype.net>
Date:   Sat Sep 14 15:33:44 2013 +0300

    Volume driver cache parameter
---
 README.md                                    | 2 ++
 lib/vagrant-libvirt/action/create_domain.rb  | 2 ++
 lib/vagrant-libvirt/config.rb                | 2 ++
 lib/vagrant-libvirt/templates/domain.xml.erb | 2 +-
 4 files changed, 7 insertions(+), 1 deletion(-)

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 @@
   <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'/>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list