mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Save container name in nvproxy FDs.
PiperOrigin-RevId: 630626291
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user