From ba9050984ecde310ef9bcb8a36faf09156e272e7 Mon Sep 17 00:00:00 2001 From: coding Date: Mon, 1 Jun 2015 11:51:42 +0800 Subject: [PATCH] Make NFS correctly detect host/guest addresses. The logic is that we first gather all usable guest addresses, then use routing information (through a udp socket) to figure out host IP for use to connect to guest. --- lib/vagrant-libvirt/action/prepare_nfs_settings.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vagrant-libvirt/action/prepare_nfs_settings.rb b/lib/vagrant-libvirt/action/prepare_nfs_settings.rb index 0f9b796..b74268a 100644 --- a/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +++ b/lib/vagrant-libvirt/action/prepare_nfs_settings.rb @@ -19,8 +19,8 @@ module VagrantPlugins if using_nfs? @logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP") - env[:nfs_host_ip] = read_host_ip(env[:machine]) env[:nfs_machine_ip] = read_machine_ip(env[:machine]) + env[:nfs_host_ip] = read_host_ip(env[:nfs_machine_ip]) @logger.info("host IP: #{env[:nfs_host_ip]} machine IP: #{env[:nfs_machine_ip]}") @@ -39,9 +39,9 @@ module VagrantPlugins # # @param [Machine] machine # @return [String] - def read_host_ip(machine) + def read_host_ip(ip) UDPSocket.open do |s| - s.connect(machine.ssh_info[:host], 1) + s.connect(ip, 1) s.addr.last end end