Allow custom name for disk device

This is needed for example for xen in full virtualisation mode
as it won't allow the default vda
This commit is contained in:
Michal Sylwester 2017-01-30 17:06:31 +01:00
parent ecea549e7f
commit 07dbb907bd
6 changed files with 11 additions and 2 deletions

View File

@ -277,6 +277,10 @@ end
_target_](http://libvirt.org/formatdomain.html#elementsDisks). NOTE: this
option applies only to disks associated with a box image. To set the bus type
on additional disks, see the [Additional Disks](#additional-disks) section.
* `disk_device` - The disk device to emulate. Defaults to vda if not
set, which should be fine for paravirtualized guests, but some fully
virtualized guests may require hda. NOTE: this option also applies only to
disks associated with a box image.
* `nic_model_type` - parameter specifies the model of the network adapter when
you create a domain value by default virtio KVM believe possible values, see
the [documentation for

View File

@ -42,6 +42,7 @@ module VagrantPlugins
@machine_type = config.machine_type
@machine_arch = config.machine_arch
@disk_bus = config.disk_bus
@disk_device = config.disk_device
@nested = config.nested
@memory_size = config.memory.to_i * 1024
@management_network_mac = config.management_network_mac

View File

@ -71,6 +71,7 @@ module VagrantPlugins
attr_accessor :machine_arch
attr_accessor :machine_virtual_size
attr_accessor :disk_bus
attr_accessor :disk_device
attr_accessor :nic_model_type
attr_accessor :nested
attr_accessor :volume_cache
@ -170,6 +171,7 @@ module VagrantPlugins
@machine_arch = UNSET_VALUE
@machine_virtual_size = UNSET_VALUE
@disk_bus = UNSET_VALUE
@disk_device = UNSET_VALUE
@nic_model_type = UNSET_VALUE
@nested = UNSET_VALUE
@volume_cache = UNSET_VALUE
@ -569,6 +571,7 @@ module VagrantPlugins
@machine_arch = nil if @machine_arch == UNSET_VALUE
@machine_virtual_size = nil if @machine_virtual_size == UNSET_VALUE
@disk_bus = 'virtio' if @disk_bus == UNSET_VALUE
@disk_device = 'vda' if @disk_device == UNSET_VALUE
@nic_model_type = 'virtio' if @nic_model_type == UNSET_VALUE
@nested = false if @nested == UNSET_VALUE
@volume_cache = 'default' if @volume_cache == UNSET_VALUE

View File

@ -74,7 +74,7 @@
<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='<%= @disk_bus %>'/>
<target dev='<%= @disk_device %>' bus='<%= @disk_bus %>'/>
</disk>
<% end %>
<%# additional disks -%>

View File

@ -18,7 +18,7 @@ class EnvironmentHelper
1024
end
%w(cpus cpu_mode loader boot_order machine_type disk_bus nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
%w(cpus cpu_mode loader boot_order machine_type disk_bus disk_device nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
define_method(name.to_sym) do
nil
end

View File

@ -36,6 +36,7 @@ describe 'templates/domain' do
domain.instance_variable_set('@domain_volume_path', '/var/lib/libvirt/images/test.qcow2')
domain.instance_variable_set('@domain_volume_cache', 'unsafe')
domain.disk_bus = 'ide'
domain.disk_device = 'vda'
domain.storage(:file, path: 'test-disk1.qcow2')
domain.storage(:file, path: 'test-disk2.qcow2')
domain.disks.each do |disk|