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

Function runHyperkitCmd

src/cmd/linuxkit/run_hyperkit.go:34–355  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34func runHyperkitCmd() *cobra.Command {
35 var (
36 hyperkitPath string
37 data string
38 dataPath string
39 ipStr string
40 state string
41 vsockports string
42 networking string
43 vpnkitUUID string
44 vpnkitPath string
45 uefiBoot bool
46 isoBoot bool
47 squashFSBoot bool
48 kernelBoot bool
49 consoleToFile bool
50 fw string
51 publishFlags multipleFlag
52 )
53 cmd := &cobra.Command{
54 Use: "hyperkit",
55 Short: "launch a VM using hyperkit",
56 Long: `Launch a VM using hyperkit.
57 'prefix' specifies the path to the VM image.
58 `,
59 Args: cobra.ExactArgs(1),
60 Example: "linuxkit run hyperkit [options] prefix",
61 RunE: func(cmd *cobra.Command, args []string) error {
62 path := args[0]
63
64 if data != "" && dataPath != "" {
65 return errors.New("cannot specify both -data and -data-file")
66 }
67
68 prefix := path
69
70 _, err := os.Stat(path + "-kernel")
71 statKernel := err == nil
72
73 var isoPaths []string
74
75 switch {
76 case squashFSBoot:
77 if kernelBoot || isoBoot {
78 return fmt.Errorf("please specify only one boot method")
79 }
80 if !statKernel {
81 return fmt.Errorf("booting a SquashFS root filesystem requires a kernel at %s", path+"-kernel")
82 }
83 _, err = os.Stat(path + "-squashfs.img")
84 statSquashFS := err == nil
85 if !statSquashFS {
86 return fmt.Errorf("cannot find SquashFS image (%s): %v", path+"-squashfs.img", err)
87 }
88 case isoBoot:
89 if kernelBoot {
90 return fmt.Errorf("please specify only one boot method")
91 }

Callers 1

runCmdFunction · 0.85

Calls 6

CreateMetadataISOFunction · 0.85
stringToIntArrayFunction · 0.85
launchVPNKitFunction · 0.85
shutdownVPNKitFunction · 0.85
vpnkitPublishPortsFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected