MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / launchVPNKit

Function launchVPNKit

src/cmd/linuxkit/run_hyperkit.go:384–428  ·  view source on GitHub ↗

launchVPNKit starts a new instance of VPNKit. Ethernet socket and port socket will be created and passed to VPNKit. The VSOCK socket should be created by HyperKit when it starts.

(vpnkitPath, etherSock, vsockSock, portSock string)

Source from the content-addressed store, hash-verified

382// will be created and passed to VPNKit. The VSOCK socket should be created
383// by HyperKit when it starts.
384func launchVPNKit(vpnkitPath, etherSock, vsockSock, portSock string) (*os.Process, error) {
385 var err error
386
387 if vpnkitPath == "" {
388 vpnkitPath, err = exec.LookPath("vpnkit")
389 if err != nil {
390 return nil, fmt.Errorf("unable to find vpnkit binary")
391 }
392 }
393
394 etherFile, err := createListenSocket(etherSock)
395 if err != nil {
396 return nil, err
397 }
398
399 portFile, err := createListenSocket(portSock)
400 if err != nil {
401 return nil, err
402 }
403
404 cmd := exec.Command(vpnkitPath,
405 "--ethernet", "fd:3",
406 "--vsock-path", vsockSock,
407 "--port", "fd:4")
408
409 cmd.ExtraFiles = append(cmd.ExtraFiles, etherFile)
410 cmd.ExtraFiles = append(cmd.ExtraFiles, portFile)
411
412 cmd.Env = os.Environ() // pass env for DEBUG
413
414 cmd.Stdin = os.Stdin
415 cmd.Stdout = os.Stdout
416 cmd.Stderr = os.Stderr
417
418 log.Debugf("Starting vpnkit: %v", cmd.Args)
419 if err := cmd.Start(); err != nil {
420 return nil, err
421 }
422
423 go func() {
424 _ = cmd.Wait() // run in background
425 }()
426
427 return cmd.Process, nil
428}
429
430// vpnkitPublishPorts instructs VPNKit to expose ports from the VM on localhost
431// Pre-register the VM with VPNKit using the UUID. This gives the IP

Callers 1

runHyperkitCmdFunction · 0.85

Calls 2

createListenSocketFunction · 0.85
WaitMethod · 0.80

Tested by

no test coverage detected