From e5635f2da26f5145104f810e0ebb413c5c4d675a Mon Sep 17 00:00:00 2001 From: dima Date: Sat, 11 Feb 2017 14:07:49 +0100 Subject: [PATCH] fixes #734 fixed logic for set nic model type --- .../action/create_network_interfaces.rb | 4 ++-- lib/vagrant-libvirt/action/start_domain.rb | 12 +++++++----- lib/vagrant-libvirt/config.rb | 10 +++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb index 9a84190..1eee56e 100644 --- a/lib/vagrant-libvirt/action/create_network_interfaces.rb +++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb @@ -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( diff --git a/lib/vagrant-libvirt/action/start_domain.rb b/lib/vagrant-libvirt/action/start_domain.rb index 26ee676..0a75bd2 100644 --- a/lib/vagrant-libvirt/action/start_domain.rb +++ b/lib/vagrant-libvirt/action/start_domain.rb @@ -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 diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 9cf6886..2602905 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -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