gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/pkg/sentry/devices/nvproxy/save_restore.go (about)

     1  // Copyright 2023 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  package nvproxy
    16  
    17  import (
    18  	goContext "context"
    19  	"fmt"
    20  )
    21  
    22  // beforeSave is invoked by stateify.
    23  func (nvp *nvproxy) beforeSave() {
    24  	nvp.beforeSaveImpl()
    25  }
    26  
    27  // afterLoad is invoked by stateify.
    28  func (nvp *nvproxy) afterLoad(ctx goContext.Context) {
    29  	Init()
    30  	abiCons, ok := abis[nvp.version]
    31  	if !ok {
    32  		panic(fmt.Sprintf("driver version %q not found in abis map", nvp.version))
    33  	}
    34  	nvp.abi = abiCons.cons()
    35  	nvp.objsFreeSet = make(map[*object]struct{})
    36  	nvp.afterLoadImpl(ctx)
    37  }
    38  
    39  // beforeSave is invoked by stateify.
    40  func (fd *frontendFD) beforeSave() {
    41  	fd.beforeSaveImpl()
    42  }
    43  
    44  // afterLoad is invoked by stateify.
    45  func (fd *frontendFD) afterLoad(ctx goContext.Context) {
    46  	fd.afterLoadImpl(ctx)
    47  }
    48  
    49  // beforeSave is invoked by stateify.
    50  func (fd *uvmFD) beforeSave() {
    51  	fd.beforeSaveImpl()
    52  }
    53  
    54  // afterLoad is invoked by stateify.
    55  func (fd *uvmFD) afterLoad(ctx goContext.Context) {
    56  	fd.afterLoadImpl(ctx)
    57  }