diff --git a/commands/ls.go b/commands/ls.go index 5da1e06992..bbba06e978 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -306,14 +306,32 @@ func getHostListItems(hostList []*host.Host) []HostListItem { hostListItemsChan := make(chan HostListItem) for _, h := range hostList { - go getHostState(h, hostListItemsChan) + if h.DriverName != "virtualbox" { + go getHostState(h, hostListItemsChan) + } } - for range hostList { - hostListItems = append(hostListItems, <-hostListItemsChan) + // Virtualbox is temperamental about doing things concurrently, + // so we schedule the actions in a "queue" to be executed serially + // after the concurrent actions are scheduled. + for _, h := range hostList { + if h.DriverName == "virtualbox" { + serialChan := make(chan HostListItem) + + go getHostState(h, serialChan) + + hostListItems = append(hostListItems, <-serialChan) + close(serialChan) + } } + for _, h := range hostList { + if h.DriverName != "virtualbox" { + hostListItems = append(hostListItems, <-hostListItemsChan) + } + } close(hostListItemsChan) + return hostListItems }