MCPcopy
hub / github.com/google/gvisor / main

Function main

tools/gpu/main.go:79–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77}
78
79func main() {
80 ctx := context.Background()
81 if len(os.Args) < 2 {
82 printUsage()
83 os.Exit(1)
84 }
85 nvproxy.Init()
86 switch os.Args[1] {
87 case installCmdStr:
88 if err := installCmd.Parse(os.Args[2:]); err != nil {
89 log.Warningf("%s failed with: %v", installCmdStr, err)
90 os.Exit(1)
91 }
92 installer, err := drivers.NewInstaller(*version, *latest)
93 if err != nil {
94 log.Warningf("Failed to create installer: %v", err.Error())
95 os.Exit(1)
96 }
97 if err := installer.MaybeInstall(ctx); err != nil {
98 log.Warningf("Failed to install driver: %v", err.Error())
99 os.Exit(1)
100 }
101 case checksumCmdStr:
102 if err := checksumCmd.Parse(os.Args[2:]); err != nil {
103 log.Warningf("%s failed with: %v", checksumCmdStr, err)
104 os.Exit(1)
105 }
106
107 var eg errgroup.Group
108 for _, arch := range []string{"amd64", "arm64"} {
109 eg.Go(func() error {
110 installer, err := drivers.NewInstaller(*checksumVersion, false)
111 if err != nil {
112 return fmt.Errorf("failed to create installer: %w", err)
113 }
114 checksum, err := installer.ChecksumDriver(ctx, arch)
115 if err != nil {
116 return fmt.Errorf("failed to get checksum on arch %q: %w", arch, err)
117 }
118 fmt.Printf("%s %s %s\n", arch, *checksumVersion, checksum)
119 return nil
120 })
121 }
122 if err := eg.Wait(); err != nil {
123 log.Warningf("Failed to get checksum: %v", err.Error())
124 os.Exit(1)
125 }
126
127 case validateChecksumCmdStr:
128 if err := validateChecksumCmd.Parse(os.Args[2:]); err != nil {
129 log.Warningf("%s failed with: %v", validateChecksumCmdStr, err)
130 os.Exit(1)
131 }
132
133 var eg errgroup.Group
134
135 nvproxy.ForEachSupportDriver(func(version nvconf.DriverVersion, checksums nvproxy.Checksums) {
136 eg.Go(func() error {

Callers

nothing calls this directly

Calls 14

MaybeInstallMethod · 0.95
ChecksumDriverMethod · 0.95
InitFunction · 0.92
WarningfFunction · 0.92
NewInstallerFunction · 0.92
ForEachSupportDriverFunction · 0.92
ValidateChecksumFunction · 0.92
ListSupportedDriversFunction · 0.92
printUsageFunction · 0.70
ParseMethod · 0.65
ErrorfMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…