MCPcopy Create free account
hub / github.com/linuxkit/linuxkit / hypervStartConsole

Function hypervStartConsole

src/cmd/linuxkit/hyperv_windows.go:25–60  ·  view source on GitHub ↗
(vmName string)

Source from the content-addressed store, hash-verified

23)
24
25func hypervStartConsole(vmName string) error {
26 if err := hypervConfigureConsole(); err != nil {
27 log.Infof("Configure Console: %v", err)
28 }
29
30 pipeName := fmt.Sprintf(`\\.\pipe\%s-com1`, vmName)
31 var c net.Conn
32 var err error
33 for count := 1; count < 100; count++ {
34 c, err = winio.DialPipe(pipeName, nil)
35 defer c.Close()
36 if err != nil {
37 // Argh, different Windows versions seem to
38 // return different errors and we can't easily
39 // catch the error. On some versions it is
40 // winio.ErrTimeout...
41 // Instead poll 100 times and then error out
42 log.Infof("Connect to console: %v", err)
43 time.Sleep(10 * 1000 * 1000 * time.Nanosecond)
44 continue
45 }
46 break
47 }
48 if err != nil {
49 return err
50 }
51
52 log.Info("Connected")
53 go io.Copy(c, os.Stdin)
54
55 _, err = io.Copy(os.Stdout, c)
56 if err != nil {
57 return err
58 }
59 return nil
60}
61
62var (
63 hypervStdinMode uint32

Callers 1

runHyperVCmdFunction · 0.70

Calls 2

hypervConfigureConsoleFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected