fixes #734 fixed logic for set nic model type

This commit is contained in:
dima
2017-02-11 14:07:49 +01:00
parent fe694b4ad2
commit e5635f2da2
3 changed files with 14 additions and 12 deletions

View File

@@ -17,7 +17,7 @@ module VagrantPlugins
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_network_interfaces')
@management_network_name = env[:machine].provider_config.management_network_name
config = env[:machine].provider_config
@nic_model_type = config.nic_model_type
@nic_model_type = config.nic_model_type || 'virtio'
@nic_adapter_count = config.nic_adapter_count
@app = app
end
@@ -243,7 +243,7 @@ module VagrantPlugins
xml.mac(address: mac) if mac
xml.target(dev: target_dev_name(device_name, type, iface_number))
xml.alias(name: "net#{iface_number}")
xml.model(type: model_type)
xml.model(type: model_type.to_s)
xml.driver(driver_options)
end
end.to_xml(

View File

@@ -54,10 +54,12 @@ module VagrantPlugins
end
# Iterface type
REXML::XPath.each(xml_descr, '/domain/devices/interface/model') do |iface_model|
if iface_model.attributes['type'] != config.nic_model_type
descr_changed = true
iface_model.attributes['type'] = config.nic_model_type
unless config.nic_model_type.nil?
REXML::XPath.each(xml_descr, '/domain/devices/interface/model') do |iface_model|
if iface_model.attributes['type'] != config.nic_model_type
descr_changed = true
iface_model.attributes['type'] = config.nic_model_type
end
end
end
@@ -225,7 +227,7 @@ module VagrantPlugins
if config.sound_type
sound = REXML::XPath.first(xml_descr,'/domain/devices/sound/model')
end
# dtb
if config.dtb

View File

@@ -119,7 +119,7 @@ module VagrantPlugins
attr_accessor :rng
# Watchdog device
attr_accessor :watchdog_dev
attr_accessor :watchdog_dev
# USB device passthrough
attr_accessor :usbs
@@ -214,9 +214,9 @@ module VagrantPlugins
# Random number device passthrough
@rng = UNSET_VALUE
# Watchdog device
@watchdog_dev = UNSET_VALUE
@watchdog_dev = UNSET_VALUE
# USB device passthrough
@usbs = UNSET_VALUE
@@ -359,7 +359,7 @@ module VagrantPlugins
slot: options[:slot],
function: options[:function])
end
def watchdog(options = {})
if options[:model].nil?
raise 'Model must be specified.'
@@ -572,7 +572,7 @@ module VagrantPlugins
@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
@nic_model_type = nil if @nic_model_type == UNSET_VALUE
@nested = false if @nested == UNSET_VALUE
@volume_cache = 'default' if @volume_cache == UNSET_VALUE
@kernel = nil if @kernel == UNSET_VALUE