allow cache mode to be set for additional disks

This commit is contained in:
Adam Spiers 2014-10-26 23:47:50 +00:00
parent e410100baa
commit 7b38af568c
3 changed files with 3 additions and 1 deletions

View File

@ -281,6 +281,7 @@ You can create and attach additional disks to a VM via `libvirt.storage :file`.
* `device` - Name of the device node the disk image will have in the VM, e.g. *vdb*. If unspecified, the next available device is chosen. * `device` - Name of the device node the disk image will have in the VM, e.g. *vdb*. If unspecified, the next available device is chosen.
* `size` - Size of the disk image. If unspecified, defaults to 10G. * `size` - Size of the disk image. If unspecified, defaults to 10G.
* `type` - Type of disk image to create. Defaults to *qcow2*. * `type` - Type of disk image to create. Defaults to *qcow2*.
* `cache` - Cache mode to use, e.g. `none`, `writeback`, `writethrough` (see the [libvirt documentation for possible values](http://libvirt.org/formatdomain.html#elementsDisks) or [here](https://www.suse.com/documentation/sles11/book_kvm/data/sect1_chapter_book_kvm.html) for a fuller explanation). Defaults to *default*.
The following example creates two additional disks. The following example creates two additional disks.

View File

@ -141,6 +141,7 @@ module VagrantPlugins
:type => options[:type], :type => options[:type],
:size => options[:size], :size => options[:size],
:path => options[:path], :path => options[:path],
:cache => options[:cache] || 'default',
} }
if storage_type == :file if storage_type == :file

View File

@ -36,7 +36,7 @@
<%# additional disks -%> <%# additional disks -%>
<% @disks.each do |d| -%> <% @disks.each do |d| -%>
<disk type='file' device='disk'> <disk type='file' device='disk'>
<driver name='qemu' type='<%= d[:type] %>'/> <driver name='qemu' type='<%= d[:type] %>' cache='<%= d[:cache] %>'/>
<source file='<%= d[:path] %>'/> <source file='<%= d[:path] %>'/>
<target dev='<%= d[:device] %>' bus='virtio'/> <target dev='<%= d[:device] %>' bus='virtio'/>
<%# this will get auto generated by libvirt <%# this will get auto generated by libvirt