From 88399f41d7ec2b030e98b7fccf7fba355c4f46b2 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Wed, 4 Nov 2015 18:18:08 +0100 Subject: [PATCH] FIX #2154 query virtualbox serially Signed-off-by: David Gageot --- commands/ls.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) 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 }