mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
RuntimeCkpt is now State and the checkpoint file is called state.json.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/docker/libcontainer/network"
|
||||
)
|
||||
|
||||
// State represents a running container's state
|
||||
@@ -12,12 +14,17 @@ type State struct {
|
||||
InitPid int `json:"init_pid,omitempty"`
|
||||
// InitStartTime is the init process start time
|
||||
InitStartTime string `json:"init_start_time,omitempty"`
|
||||
// Network runtime state.
|
||||
NetworkState network.NetworkState `json:"network_state,omitempty"`
|
||||
}
|
||||
|
||||
// The name of the runtime state file
|
||||
const stateFile = "state.json"
|
||||
|
||||
// SaveState writes the container's runtime state to a state.json file
|
||||
// in the specified path
|
||||
func SaveState(basePath string, state *State) error {
|
||||
f, err := os.Create(filepath.Join(basePath, "state.json"))
|
||||
f, err := os.Create(filepath.Join(basePath, stateFile))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -28,7 +35,7 @@ func SaveState(basePath string, state *State) error {
|
||||
|
||||
// GetState reads the state.json file for a running container
|
||||
func GetState(basePath string) (*State, error) {
|
||||
f, err := os.Open(filepath.Join(basePath, "state.json"))
|
||||
f, err := os.Open(filepath.Join(basePath, stateFile))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -44,5 +51,5 @@ func GetState(basePath string) (*State, error) {
|
||||
|
||||
// DeleteState deletes the state.json file
|
||||
func DeleteState(basePath string) error {
|
||||
return os.Remove(filepath.Join(basePath, "state.json"))
|
||||
return os.Remove(filepath.Join(basePath, stateFile))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user