mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Explicitly fail checkpoint/restore attempts on nvproxy FDs.
PiperOrigin-RevId: 631262290
This commit is contained in:
@@ -87,8 +87,7 @@ func (dev *frontendDevice) Open(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.D
|
||||
// frontendFD implements vfs.FileDescriptionImpl for /dev/nvidia# and
|
||||
// /dev/nvidiactl.
|
||||
//
|
||||
// frontendFD is not savable; we do not implement save/restore of host GPU
|
||||
// state.
|
||||
// +stateify savable
|
||||
type frontendFD struct {
|
||||
vfsfd vfs.FileDescription
|
||||
vfs.FileDescriptionDefaultImpl
|
||||
@@ -101,7 +100,7 @@ type frontendFD struct {
|
||||
memmapFile frontendFDMemmapFile
|
||||
|
||||
queue waiter.Queue
|
||||
haveMmapContext atomic.Bool
|
||||
haveMmapContext atomic.Bool `state:"nosave"`
|
||||
|
||||
// clients are handles of clients owned by this frontendFD. clients is
|
||||
// protected by nvp.objsMu.
|
||||
|
||||
@@ -60,6 +60,7 @@ func (fd *frontendFD) InvalidateUnsavable(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// +stateify savable
|
||||
type frontendFDMemmapFile struct {
|
||||
memmap.NoBufferedIOFallback
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build !false
|
||||
// +build !false
|
||||
|
||||
package nvproxy
|
||||
|
||||
import (
|
||||
@@ -19,20 +22,32 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func (n *nvproxy) beforeSave() {
|
||||
n.objsLock()
|
||||
defer n.objsUnlock()
|
||||
if len(n.clients) != 0 {
|
||||
// beforeSave is invoked by stateify.
|
||||
func (nvp *nvproxy) beforeSave() {
|
||||
nvp.objsLock()
|
||||
defer nvp.objsUnlock()
|
||||
if len(nvp.clients) != 0 {
|
||||
panic("can't save with live nvproxy clients")
|
||||
}
|
||||
}
|
||||
|
||||
func (n *nvproxy) afterLoad(goContext.Context) {
|
||||
// afterLoad is invoked by stateify.
|
||||
func (nvp *nvproxy) afterLoad(goContext.Context) {
|
||||
Init()
|
||||
abiCons, ok := abis[n.version]
|
||||
abiCons, ok := abis[nvp.version]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("driver version %q not found in abis map", n.version))
|
||||
panic(fmt.Sprintf("driver version %q not found in abis map", nvp.version))
|
||||
}
|
||||
n.abi = abiCons.cons()
|
||||
n.objsFreeSet = make(map[*object]struct{})
|
||||
nvp.abi = abiCons.cons()
|
||||
nvp.objsFreeSet = make(map[*object]struct{})
|
||||
}
|
||||
|
||||
// beforeSave is invoked by stateify.
|
||||
func (fd *frontendFD) beforeSave() {
|
||||
panic("nvproxy.frontendFD is not saveable.")
|
||||
}
|
||||
|
||||
// beforeSave is invoked by stateify.
|
||||
func (fd *uvmFD) beforeSave() {
|
||||
panic("nvproxy.uvmFD is not saveable.")
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func (dev *uvmDevice) Open(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.Dentry
|
||||
|
||||
// uvmFD implements vfs.FileDescriptionImpl for /dev/nvidia-uvm.
|
||||
//
|
||||
// uvmFD is not savable; we do not implement save/restore of host GPU state.
|
||||
// +stateify savable
|
||||
type uvmFD struct {
|
||||
vfsfd vfs.FileDescription
|
||||
vfs.FileDescriptionDefaultImpl
|
||||
|
||||
@@ -66,6 +66,7 @@ func (fd *uvmFD) InvalidateUnsavable(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// +stateify savable
|
||||
type uvmFDMemmapFile struct {
|
||||
fd *uvmFD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user