gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/runsc/cmd/nvproxy/nvproxy.go (about) 1 // Copyright 2023 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package nvproxy provides subcommands for the nvproxy command. 16 package nvproxy 17 18 import ( 19 "bytes" 20 "context" 21 22 "github.com/google/subcommands" 23 "gvisor.dev/gvisor/pkg/sentry/devices/nvproxy" 24 "gvisor.dev/gvisor/runsc/flag" 25 ) 26 27 type Nvproxy struct{} 28 29 func (*Nvproxy) Name() string { 30 return "nvproxy" 31 } 32 33 func (*Nvproxy) Synopsis() string { 34 return "shows information about nvproxy support" 35 } 36 37 func (*Nvproxy) Usage() string { 38 buf := bytes.Buffer{} 39 buf.WriteString("Usage: nvproxy <flags> <subcommand> <subcommand args>\n\n") 40 41 cdr := createCommander(&flag.FlagSet{}) 42 cdr.VisitGroups(func(grp *subcommands.CommandGroup) { 43 cdr.ExplainGroup(&buf, grp) 44 }) 45 46 return buf.String() 47 } 48 49 func (*Nvproxy) SetFlags(*flag.FlagSet) {} 50 51 func (*Nvproxy) Execute(ctx context.Context, f *flag.FlagSet, args ...any) subcommands.ExitStatus { 52 nvproxy.Init() 53 return createCommander(f).Execute(ctx, args...) 54 } 55 56 func createCommander(f *flag.FlagSet) *subcommands.Commander { 57 cdr := subcommands.NewCommander(f, "nvproxy") 58 cdr.Register(cdr.HelpCommand(), "") 59 cdr.Register(cdr.FlagsCommand(), "") 60 cdr.Register(new(listSupportedDrivers), "") 61 return cdr 62 }