Permalink
Browse files

Add an unsafe flag for KVM's unsafe volume cache.

  • Loading branch information...
1 parent 94534df commit c85c7962fe44e933792c7f338d702e7fb338f07c @bowlofeggs bowlofeggs committed with Aug 14, 2015
View
@@ -349,6 +349,11 @@ Currently undocumented.
####`repos`
Currently undocumented.
+####`unsafe`
+Set this to true if you want to use KVM's unsafe cache mode. If you do this, you
+will trade data integrity on your development environment's filesystem for a
+noticeable speed boost. See http://libvirt.org/formatdomain.html#elementsDisks
+
###Command line
The command line arguments are currently undocumented. If you'd like to help
improve these, please send a patch. They are not critical to Oh-My-Vagrant
View
@@ -44,6 +44,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: ''
:reallyrm: false
View
@@ -25,6 +25,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: simple atomic example
:reallyrm: false
@@ -29,6 +29,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: simple docker build example
:reallyrm: false
@@ -35,6 +35,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: simple docker kubernetes example
:reallyrm: false
@@ -33,6 +33,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: sub folder simple docker file build example
:reallyrm: false
@@ -42,6 +42,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: ''
:reallyrm: false
@@ -35,6 +35,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: 'simple kubernetes on atomic example without cached images'
:reallyrm: false
View
@@ -39,6 +39,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: fake kubernetes example
:reallyrm: false
@@ -53,6 +53,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: contrived puppet-gluster example
:reallyrm: false
View
@@ -25,6 +25,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: simple rhel example
:reallyrm: false
View
@@ -35,6 +35,7 @@
:poolid: true
:repos: []
:update: false
+:unsafe: false
:nested: false
:comment: simple shell run example
:reallyrm: false
View
@@ -92,6 +92,7 @@ password = '' # default subscription manager password
poolid = true # default list of poolid's (true to auto-attach)
repos = [] # default list of extra repos's to enable
update = false # determine whether or not to update the box on vagrant up
+unsafe = false # true will trade data safety for performance gains
nested = false # should we allow vm nesting
comment = '' # store a comment field in the omv.yaml file
@@ -218,6 +219,7 @@ if File.exist?(f)
poolid = settings[:poolid]
repos = settings[:repos]
update = settings[:update]
+ unsafe = settings[:unsafe]
nested = settings[:nested]
comment = settings[:comment]
really_use_rm = settings[:reallyrm]
@@ -459,6 +461,17 @@ while skip < ARGV.length
update = false
end
+ elsif ARGV[skip].start_with?(arg='--omv-unsafe=')
+ v = ARGV.delete_at(skip).dup
+ v.slice! arg
+
+ unsafe = v.to_s
+ if ['true'].include?(unsafe.downcase)
+ unsafe = true
+ else
+ unsafe = false
+ end
+
elsif ARGV[skip].start_with?(arg='--omv-nested=')
v = ARGV.delete_at(skip).dup
v.slice! arg
@@ -533,6 +546,7 @@ settings = {
:poolid => poolid,
:repos => repos,
:update => update,
+ :unsafe => unsafe,
:nested => nested,
:comment => comment,
:reallyrm => really_use_rm.nil?? 'nil' : really_use_rm,
@@ -893,6 +907,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vm_ansible_extras = x.fetch(:ansible_extras, ansible_extras) # get value
vm_sync = x.fetch(:sync, sync) # get value
vm_update = x.fetch(:update, update) # get value
+ vm_unsafe = x.fetch(:unsafe, unsafe) # get value
vm_nested = x.fetch(:nested, nested) # get value
# sanity check the user-supplied IP addresses and gracefully fail
@@ -1419,6 +1434,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
libvirt.memory = 1024
end
+ # use kvm's unsafe mode
+ if vm_unsafe
+ # Configure the Vagrant environment to use kvm's unsafe cache mode.
+ # If you do this, you will trade data integrity on your development
+ # environment's filesystem for a noticeable speed boost.
+ # See http://libvirt.org/formatdomain.html#elementsDisks
+ libvirt.volume_cache = 'unsafe'
+ end
+
# allow nesting vm's
if vm_nested
libvirt.nested = true

0 comments on commit c85c796

Please sign in to comment.