From df41f6f037a0e15d0ee5640f47c22a54b14199f2 Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Thu, 10 Nov 2022 18:49:46 +0000 Subject: [PATCH] Ensure default public_network :dev shown on error (#1670) During validation ensure that the default value for public network devices is selected and shown on error if it's not one of the host devices that are currently discovered. --- lib/vagrant-libvirt/config.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index c311828..402e57b 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -1214,8 +1214,9 @@ module VagrantPlugins # only interested in public networks where portgroup is nil, as then source will be a host device if type == :public_network && opts[:portgroup] == nil devices = host_devices(machine) - if !devices.include?(opts[:dev]) - errors << "network configuration #{index} for machine #{machine.name} is a public_network referencing host device '#{opts[:dev]}' which does not exist, consider adding ':dev => ....' referencing one of #{devices.join(", ")}" + hostdev = opts.fetch(:dev, 'eth0') + if !devices.include?(hostdev) + errors << "network configuration #{index} for machine #{machine.name} is a public_network referencing host device '#{hostdev}' which does not exist, consider adding ':dev => ....' referencing one of #{devices.join(", ")}" end end end