Allow use of virtio-scsi driver for SCSI devices (#692)

For better performance allows enabling the virtio-scsi model on the
scsi controller in VM's.

Additionally supports inferring use of virtio-scsi model from disk
device or bus, and similarly infer the correct values for these
based on device or bus.

Currently one controller per 7 domain volume disks is created, this
follows virt-manager's behaviour, and is assumed a reasonable default.
However note that virtio-scsi should be capable of allowing many more
disks to be assigned per controller than this. It is presumed that the
source of the number 7 is allowing for 8 devices per controller
including the host adapter, which therefore allows for 7. Hardware SCSI
controllers typically supported 16 addressable devices including the
adapter providing for a 15 disk limit. Whether this is necessary is not
yet clear.

Co-authored-by: Darragh Bailey <daragh.bailey@gmail.com>
This commit is contained in:
Michael Kerrin
2015-06-02 10:00:38 +01:00
committed by Darragh Bailey
parent a4842acf12
commit 37c3330de1
6 changed files with 298 additions and 2 deletions

View File

@@ -99,6 +99,7 @@ module VagrantPlugins
attr_accessor :machine_virtual_size
attr_accessor :disk_bus
attr_accessor :disk_device
attr_accessor :disk_controller_model
attr_accessor :disk_driver_opts
attr_accessor :nic_model_type
attr_accessor :nested
@@ -256,6 +257,7 @@ module VagrantPlugins
@machine_virtual_size = UNSET_VALUE
@disk_bus = UNSET_VALUE
@disk_device = UNSET_VALUE
@disk_controller_model = UNSET_VALUE
@disk_driver_opts = {}
@nic_model_type = UNSET_VALUE
@nested = UNSET_VALUE
@@ -871,8 +873,15 @@ module VagrantPlugins
@machine_type = nil if @machine_type == UNSET_VALUE
@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
@disk_device = @disk_bus == 'scsi' ? 'sda' : 'vda' if @disk_device == UNSET_VALUE
@disk_bus = @disk_device.start_with?('sd') ? 'scsi' : 'virtio' if @disk_bus == UNSET_VALUE
if @disk_controller_model == UNSET_VALUE
if @disk_bus == 'scsi' or @disk_device.start_with?('sd') == 'sd'
@disk_controller_model = 'virtio-scsi'
else
@disk_controller_model = nil
end
end
@disk_driver_opts = {} if @disk_driver_opts == UNSET_VALUE
@nic_model_type = nil if @nic_model_type == UNSET_VALUE
@nested = false if @nested == UNSET_VALUE

View File

@@ -122,6 +122,11 @@
<target dev='<%= volume[:device] %>' bus='<%= volume[:bus] %>'/>
</disk>
<%- end -%>
<%- if @disk_bus == "scsi" and @disk_controller_model != nil %>
<%- for idx in 0..(@domain_volumes.length / 7) do %>
<controller type='scsi' model='<%= @disk_controller_model %>' index='<%= idx -%>'/>
<%- end -%>
<%- end -%>
<%# additional disks -%>
<%- @disks.each_with_index do |d, index| -%>
<disk type='file' device='disk'>