Skip to content

Commit b8da8ca

Browse files
nixprimegvisor-bot
authored andcommitted
Internal change.
PiperOrigin-RevId: 817859872
1 parent 828a103 commit b8da8ca

File tree

8 files changed

+70
-3
lines changed

8 files changed

+70
-3
lines changed

runsc/boot/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ go_library(
1818
"gofer_conf.go",
1919
"limits.go",
2020
"loader.go",
21+
"loader_impl.go",
2122
"mount_hints.go",
2223
"network.go",
2324
"restore.go",

runsc/boot/loader.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ type Loader struct {
278278
// saveRestoreNet indicates if the saved network stack should be used
279279
// during restore.
280280
saveRestoreNet bool
281+
282+
LoaderExtra
281283
}
282284

283285
// execID uniquely identifies a sentry process that is executed in a container.
@@ -381,6 +383,8 @@ type Args struct {
381383
HostTHP HostTHP
382384

383385
SaveFDs []*fd.FD
386+
387+
ArgsExtra
384388
}
385389

386390
// HostTHP holds host transparent hugepage settings.
@@ -471,6 +475,7 @@ func New(args Args) (*Loader, error) {
471475
containerSpecs: make(map[string]*specs.Spec),
472476
saveFDs: args.SaveFDs,
473477
}
478+
setLoaderFromArgsExtra(l, &args)
474479

475480
if args.NumCPU == 0 {
476481
args.NumCPU = runtime.NumCPU()

runsc/boot/loader_impl.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2025 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+
//go:build !false
16+
// +build !false
17+
18+
package boot
19+
20+
type LoaderExtra struct{}
21+
22+
type ArgsExtra struct{}
23+
24+
func setLoaderFromArgsExtra(l *Loader, args *Args) {}

runsc/cmd/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ go_library(
3434
name = "cmd",
3535
srcs = [
3636
"boot.go",
37+
"boot_impl.go",
3738
"capability.go",
3839
"checkpoint.go",
3940
"chroot.go",

runsc/cmd/boot.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,11 @@ type Boot struct {
190190
// nvidiaDriverVersion is the Nvidia driver version on the host.
191191
nvidiaDriverVersion string
192192

193-
// uid and gud are the user and group IDs to switch to after setting up the user namespace.
193+
// uid and gid are the user and group IDs to switch to after setting up the user namespace.
194194
uid int
195195
gid int
196+
197+
bootExtra
196198
}
197199

198200
// Name implements subcommands.Command.Name.
@@ -251,6 +253,8 @@ func (b *Boot) SetFlags(f *flag.FlagSet) {
251253
f.IntVar(&b.finalMetricsFD, "final-metrics-log-fd", -1, "file descriptor to write metrics to upon sandbox termination.")
252254
f.IntVar(&b.profilingMetricsFD, "profiling-metrics-fd", -1, "file descriptor to write sentry profiling metrics.")
253255
f.BoolVar(&b.profilingMetricsLossy, "profiling-metrics-fd-lossy", false, "if true, treat the sentry profiling metrics FD as lossy and write a checksum to it.")
256+
257+
b.setFlagsExtra(f)
254258
}
255259

256260
// Execute implements subcommands.Command.Execute. It starts a sandbox in a
@@ -543,6 +547,7 @@ func (b *Boot) Execute(_ context.Context, f *flag.FlagSet, args ...any) subcomma
543547
HostTHP: b.hostTHP,
544548
SaveFDs: b.saveFDs.GetFDs(),
545549
}
550+
b.setBootArgsExtra(&bootArgs)
546551
l, err := boot.New(bootArgs)
547552
if err != nil {
548553
util.Fatalf("creating loader: %v", err)

runsc/cmd/boot_impl.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2025 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+
//go:build !false
16+
// +build !false
17+
18+
package cmd
19+
20+
import (
21+
"gvisor.dev/gvisor/runsc/boot"
22+
"gvisor.dev/gvisor/runsc/flag"
23+
)
24+
25+
type bootExtra struct{}
26+
27+
func (b *Boot) setFlagsExtra(f *flag.FlagSet) {}
28+
29+
func (b *Boot) setBootArgsExtra(bootArgs *boot.Args) {}

runsc/sandbox/sandbox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ func (s *Sandbox) createSandboxProcess(conf *config.Config, args *Args, startSyn
968968
donations.DonateAndClose("save-fds", files...)
969969
}
970970

971-
if err := createSandboxProcessExtra(conf, args, &donations); err != nil {
971+
if err := createSandboxProcessExtra(conf, args, cmd, &donations); err != nil {
972972
return err
973973
}
974974

runsc/sandbox/sandbox_impl.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
package sandbox
1919

2020
import (
21+
"os/exec"
22+
2123
"gvisor.dev/gvisor/pkg/sentry/control"
2224
"gvisor.dev/gvisor/runsc/boot"
2325
"gvisor.dev/gvisor/runsc/config"
2426
"gvisor.dev/gvisor/runsc/donation"
2527
)
2628

27-
func createSandboxProcessExtra(conf *config.Config, args *Args, donations *donation.Agency) error {
29+
func createSandboxProcessExtra(conf *config.Config, args *Args, cmd *exec.Cmd, donations *donation.Agency) error {
2830
return nil
2931
}
3032

0 commit comments

Comments
 (0)