Explicitly fail checkpoint/restore attempts on nvproxy FDs.

PiperOrigin-RevId: 631262290
This commit is contained in:
Ayush Ranjan
2024-05-06 19:40:24 -07:00
committed by gVisor bot
parent db6ee959df
commit 87670dcc03
5 changed files with 29 additions and 13 deletions
+2 -3
View File
@@ -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
+24 -9
View File
@@ -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.")
}
+1 -1
View File
@@ -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
+1
View File
@@ -66,6 +66,7 @@ func (fd *uvmFD) InvalidateUnsavable(ctx context.Context) error {
return nil
}
// +stateify savable
type uvmFDMemmapFile struct {
fd *uvmFD
}