From 1749e4cf94ed559fe16a2190db846bdbebeea298 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 22 Mar 2012 13:41:48 -0700 Subject: [PATCH] Enable Host IO cache on SATA controller by default --- CHANGELOG.md | 1 + lib/vagrant/action.rb | 1 + lib/vagrant/action/builtin.rb | 1 + lib/vagrant/action/vm/sane_defaults.rb | 29 ++++++++++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 lib/vagrant/action/vm/sane_defaults.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 2601be51f..03ec69992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - `vagrant ssh` now works on Solaris, where `IdentitiesOnly` was not an available option. [GH-820] - Output works properly in the face of broken pipes. [GH-819] + - Enable Host IO Cache on the SATA controller by default. ## 1.0.1 (March 11, 2012) diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 86ff9ce25..1ad7cc3ce 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -54,6 +54,7 @@ module Vagrant autoload :ProvisionerCleanup, 'vagrant/action/vm/provisioner_cleanup' autoload :PruneNFSExports, 'vagrant/action/vm/prune_nfs_exports' autoload :Resume, 'vagrant/action/vm/resume' + autoload :SaneDefaults, 'vagrant/action/vm/sane_defaults' autoload :ShareFolders, 'vagrant/action/vm/share_folders' autoload :SetupPackageFiles, 'vagrant/action/vm/setup_package_files' autoload :Suspend, 'vagrant/action/vm/suspend' diff --git a/lib/vagrant/action/builtin.rb b/lib/vagrant/action/builtin.rb index 5f7a26614..69c951c37 100644 --- a/lib/vagrant/action/builtin.rb +++ b/lib/vagrant/action/builtin.rb @@ -46,6 +46,7 @@ module Vagrant use VM::HostName use VM::ClearNetworkInterfaces use VM::Network + use VM::SaneDefaults use VM::Customize use VM::Boot end diff --git a/lib/vagrant/action/vm/sane_defaults.rb b/lib/vagrant/action/vm/sane_defaults.rb new file mode 100644 index 000000000..418ca8d97 --- /dev/null +++ b/lib/vagrant/action/vm/sane_defaults.rb @@ -0,0 +1,29 @@ +module Vagrant + module Action + module VM + # This middleware enforces some sane defaults on the virtualbox + # VM which help with performance, stability, and in some cases + # behavior. + class SaneDefaults + def initialize(app, env) + @app = app + end + + def call(env) + # Enable the host IO cache on the sata controller. Note that + # if this fails then its not a big deal, so we don't raise any + # errors. The Host IO cache vastly improves disk IO performance + # for VMs. + command = [ + "storagectl", env[:vm].uuid, + "--name", "SATA Controller", + "--hostiocache", "on" + ] + env[:vm].driver.execute_command(command) + + @app.call(env) + end + end + end + end +end