-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathrun_virtualizationframework.go
More file actions
72 lines (63 loc) · 2.42 KB
/
run_virtualizationframework.go
File metadata and controls
72 lines (63 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"github.com/spf13/cobra"
)
const (
virtualizationNetworkingNone string = "none"
virtualizationNetworkingDockerForMac = "docker-for-mac"
virtualizationNetworkingVPNKit = "vpnkit"
virtualizationNetworkingVMNet = "vmnet"
virtualizationNetworkingDefault = virtualizationNetworkingVMNet
virtualizationFrameworkConsole = "console=hvc0"
)
type virtualizationFramwworkConfig struct {
cpus uint
mem uint64
disks Disks
data string
dataPath string
state string
networking string
kernelBoot bool
virtiofsShares []string
}
func runVirtualizationFrameworkCmd() *cobra.Command {
var (
data string
dataPath string
state string
networking string
kernelBoot bool
virtiofsShares []string
)
cmd := &cobra.Command{
Use: "virtualization",
Short: "launch a VM using the macOS virtualization framework",
Long: `Launch a VM using the macOS virtualization framework.
'prefix' specifies the path to the VM image.
`,
Args: cobra.ExactArgs(1),
Example: "linuxkit run virtualization [options] prefix",
RunE: func(cmd *cobra.Command, args []string) error {
cfg := virtualizationFramwworkConfig{
cpus: uint(cpus),
mem: uint64(mem) * 1024 * 1024,
disks: disks,
data: data,
dataPath: dataPath,
state: state,
networking: networking,
kernelBoot: kernelBoot,
virtiofsShares: virtiofsShares,
}
return runVirtualizationFramework(cfg, args[0])
},
}
cmd.Flags().StringVar(&data, "data", "", "String of metadata to pass to VM; error to specify both -data and -data-file")
cmd.Flags().StringVar(&dataPath, "data-file", "", "Path to file containing metadata to pass to VM; error to specify both -data and -data-file")
cmd.Flags().StringVar(&state, "state", "", "Path to directory to keep VM state in")
cmd.Flags().StringVar(&networking, "networking", virtualizationNetworkingDefault, "Networking mode. Valid options are 'default', 'vmnet' and 'none'. 'vmnet' uses the Apple vmnet framework. 'none' disables networking.`")
cmd.Flags().BoolVar(&kernelBoot, "kernel", false, "Boot image is kernel+initrd+cmdline 'path'-kernel/-initrd/-cmdline")
cmd.Flags().StringArrayVar(&virtiofsShares, "virtiofs", []string{}, "Directory shared on virtiofs")
return cmd
}