FIX #2617 Check hostonlyif after its creation

Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
David Gageot 2015-12-18 17:43:05 +01:00
parent fbf97b7c73
commit dd379d33c8
1 changed files with 12 additions and 0 deletions

View File

@ -15,6 +15,7 @@ const (
var (
reHostonlyInterfaceCreated = regexp.MustCompile(`Interface '(.+)' was successfully created`)
errDuplicateHostOnlyInterfaceNetworks = errors.New("VirtualBox is configured with multiple host-only interfaces with the same IP. Please remove all of them but one.")
errNewHostOnlyInterfaceNotVisible = errors.New("The host-only interface we just created is not visible. This is a well known bug of VirtualBox. You might want to uninstall it and reinstall the version listed here: https://www.virtualbox.org/ticket/14437?cversion=0&cnum_hist=42")
)
// Host-only network.
@ -173,6 +174,17 @@ func getOrCreateHostOnlyNetwork(hostIP net.IP, netmask net.IPMask, dhcpIP net.IP
return nil, err
}
// Check that the interface really exists.
// Sometimes, Vbox says it created the interface but then it cannot be found...
nets, err = listHostOnlyNetworks(vbox)
if err != nil {
return nil, err
}
hostOnlyNet = getHostOnlyNetwork(nets, hostIP, netmask)
if hostOnlyNet == nil {
return nil, errNewHostOnlyInterfaceNotVisible
}
return hostOnlyNet, nil
}