Skip to content

Commit 9a8d040

Browse files
committed
vm_darwin.go: The startVM function waits until the sshLocalPort becomes available.
Signed-off-by: Norio Nomura <[email protected]>
1 parent 3372ae7 commit 9a8d040

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/driver/vz/vm_darwin.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ func startVM(ctx context.Context, inst *limatype.Instance, sshLocalPort int) (*v
7878
_ = os.RemoveAll(f)
7979
}
8080
}()
81+
waitSSHLocalPortAccessible := make(chan struct{})
82+
defer close(waitSSHLocalPortAccessible)
8183
go func() {
8284
// Handle errors via errCh and handle stop vm during context close
8385
defer func() {
@@ -135,6 +137,7 @@ func startVM(ctx context.Context, inst *limatype.Instance, sshLocalPort int) (*v
135137
if err != nil {
136138
errCh <- err
137139
}
140+
waitSSHLocalPortAccessible <- struct{}{}
138141
case vz.VirtualMachineStateStopped:
139142
logrus.Info("[VZ] - vm state change: stopped")
140143
wrapper.mu.Lock()
@@ -151,7 +154,7 @@ func startVM(ctx context.Context, inst *limatype.Instance, sshLocalPort int) (*v
151154
}
152155
}
153156
}()
154-
157+
<-waitSSHLocalPortAccessible
155158
return wrapper, errCh, err
156159
}
157160

0 commit comments

Comments
 (0)