Save container name in nvproxy FDs.

PiperOrigin-RevId: 630626291
This commit is contained in:
Ayush Ranjan
2024-05-04 03:10:56 -07:00
committed by gVisor bot
parent 88f1bb302d
commit 6e61813c1b
4 changed files with 24 additions and 15 deletions
+8 -2
View File
@@ -30,11 +30,12 @@ import (
type GoferClient struct {
clientFD lisafs.ClientFD
hostFD int
contName string
}
// NewGoferClient establishes the LISAFS connection to the dev gofer server.
// It takes ownership of fd.
func NewGoferClient(ctx context.Context, fd int) (*GoferClient, error) {
// It takes ownership of fd. contName is the owning container name.
func NewGoferClient(ctx context.Context, contName string, fd int) (*GoferClient, error) {
ctx.UninterruptibleSleepStart(false)
defer ctx.UninterruptibleSleepFinish(false)
@@ -63,6 +64,11 @@ func (g *GoferClient) Close() {
}
}
// ContainerName returns the name of the container that owns this gofer.
func (g *GoferClient) ContainerName() string {
return g.contName
}
// DirentNames returns names of all the dirents for /dev on the gofer.
func (g *GoferClient) DirentNames(ctx context.Context) ([]string, error) {
if g.hostFD >= 0 {
+8 -7
View File
@@ -66,8 +66,9 @@ func (dev *frontendDevice) Open(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.D
return nil, err
}
fd := &frontendFD{
dev: dev,
hostFD: int32(hostFD),
dev: dev,
containerName: devClient.ContainerName(),
hostFD: int32(hostFD),
}
if err := fd.vfsfd.Init(fd, opts.Flags, mnt, vfsd, &vfs.FileDescriptionOptions{
UseDentryMetadata: true,
@@ -94,12 +95,12 @@ type frontendFD struct {
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
dev *frontendDevice
hostFD int32
memmapFile frontendFDMemmapFile
queue waiter.Queue
dev *frontendDevice
containerName string
hostFD int32
memmapFile frontendFDMemmapFile
queue waiter.Queue
haveMmapContext atomic.Bool
// clients are handles of clients owned by this frontendFD. clients is
+7 -5
View File
@@ -53,8 +53,9 @@ func (dev *uvmDevice) Open(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.Dentry
return nil, err
}
fd := &uvmFD{
dev: dev,
hostFD: int32(hostFD),
dev: dev,
containerName: devClient.ContainerName(),
hostFD: int32(hostFD),
}
if err := fd.vfsfd.Init(fd, opts.Flags, mnt, vfsd, &vfs.FileDescriptionOptions{
UseDentryMetadata: true,
@@ -79,9 +80,10 @@ type uvmFD struct {
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
dev *uvmDevice
hostFD int32
memmapFile uvmFDMemmapFile
dev *uvmDevice
containerName string
hostFD int32
memmapFile uvmFDMemmapFile
queue waiter.Queue
}
+1 -1
View File
@@ -1977,7 +1977,7 @@ func (k *Kernel) GetUserCounters(uid auth.KUID) *UserCounters {
// AddDevGofer initializes the dev gofer connection and starts tracking it.
// It takes ownership of goferFD.
func (k *Kernel) AddDevGofer(contName string, goferFD int) error {
client, err := devutil.NewGoferClient(k.SupervisorContext(), goferFD)
client, err := devutil.NewGoferClient(k.SupervisorContext(), contName, goferFD)
if err != nil {
return err
}