github.com/metacubex/gvisor@v0.0.0-20240320004321-933faba989ec/pkg/sentry/usage/usage_state_autogen.go (about)

     1  // automatically generated by stateify.
     2  
     3  package usage
     4  
     5  import (
     6  	"context"
     7  
     8  	"github.com/metacubex/gvisor/pkg/state"
     9  )
    10  
    11  func (s *CPUStats) StateTypeName() string {
    12  	return "pkg/sentry/usage.CPUStats"
    13  }
    14  
    15  func (s *CPUStats) StateFields() []string {
    16  	return []string{
    17  		"UserTime",
    18  		"SysTime",
    19  		"VoluntarySwitches",
    20  	}
    21  }
    22  
    23  func (s *CPUStats) beforeSave() {}
    24  
    25  // +checklocksignore
    26  func (s *CPUStats) StateSave(stateSinkObject state.Sink) {
    27  	s.beforeSave()
    28  	stateSinkObject.Save(0, &s.UserTime)
    29  	stateSinkObject.Save(1, &s.SysTime)
    30  	stateSinkObject.Save(2, &s.VoluntarySwitches)
    31  }
    32  
    33  func (s *CPUStats) afterLoad(context.Context) {}
    34  
    35  // +checklocksignore
    36  func (s *CPUStats) StateLoad(ctx context.Context, stateSourceObject state.Source) {
    37  	stateSourceObject.Load(0, &s.UserTime)
    38  	stateSourceObject.Load(1, &s.SysTime)
    39  	stateSourceObject.Load(2, &s.VoluntarySwitches)
    40  }
    41  
    42  func (i *IO) StateTypeName() string {
    43  	return "pkg/sentry/usage.IO"
    44  }
    45  
    46  func (i *IO) StateFields() []string {
    47  	return []string{
    48  		"CharsRead",
    49  		"CharsWritten",
    50  		"ReadSyscalls",
    51  		"WriteSyscalls",
    52  		"BytesRead",
    53  		"BytesWritten",
    54  		"BytesWriteCancelled",
    55  	}
    56  }
    57  
    58  func (i *IO) beforeSave() {}
    59  
    60  // +checklocksignore
    61  func (i *IO) StateSave(stateSinkObject state.Sink) {
    62  	i.beforeSave()
    63  	stateSinkObject.Save(0, &i.CharsRead)
    64  	stateSinkObject.Save(1, &i.CharsWritten)
    65  	stateSinkObject.Save(2, &i.ReadSyscalls)
    66  	stateSinkObject.Save(3, &i.WriteSyscalls)
    67  	stateSinkObject.Save(4, &i.BytesRead)
    68  	stateSinkObject.Save(5, &i.BytesWritten)
    69  	stateSinkObject.Save(6, &i.BytesWriteCancelled)
    70  }
    71  
    72  func (i *IO) afterLoad(context.Context) {}
    73  
    74  // +checklocksignore
    75  func (i *IO) StateLoad(ctx context.Context, stateSourceObject state.Source) {
    76  	stateSourceObject.Load(0, &i.CharsRead)
    77  	stateSourceObject.Load(1, &i.CharsWritten)
    78  	stateSourceObject.Load(2, &i.ReadSyscalls)
    79  	stateSourceObject.Load(3, &i.WriteSyscalls)
    80  	stateSourceObject.Load(4, &i.BytesRead)
    81  	stateSourceObject.Load(5, &i.BytesWritten)
    82  	stateSourceObject.Load(6, &i.BytesWriteCancelled)
    83  }
    84  
    85  func init() {
    86  	state.Register((*CPUStats)(nil))
    87  	state.Register((*IO)(nil))
    88  }