github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/persist/api/interface.go (about) 1 // Copyright (c) 2019 Huawei Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 // 5 6 package persistapi 7 8 // PersistDriver is interface describing operations to save/restore persist data 9 type PersistDriver interface { 10 // ToDisk flushes data to disk(or other storage media such as a remote db) 11 ToDisk(SandboxState, map[string]ContainerState) error 12 // FromDisk will restore all data for sandbox with `sid` from storage. 13 // We only support get data for one whole sandbox 14 FromDisk(sid string) (SandboxState, map[string]ContainerState, error) 15 // Destroy will remove everything from storage 16 Destroy(sid string) error 17 // Lock locks the persist driver, "exclusive" decides whether the lock is exclusive or shared. 18 // It returns Unlock Function and errors 19 Lock(sid string, exclusive bool) (func() error, error) 20 21 // GlobalWrite writes "data" to "StorageRootPath"/"relativePath"; 22 // GlobalRead reads "data" from "StorageRootPath"/"relativePath"; 23 // these functions are used for writing/reading some global data, 24 // they are specially designed for ACRN so far. 25 // Don't use them too much unless you have no other choice! @weizhang555 26 GlobalWrite(relativePath string, data []byte) error 27 GlobalRead(relativePath string) ([]byte, error) 28 29 // RunStoragePath is the sandbox runtime directory. 30 // It will contain one state.json and one lock file for each created sandbox. 31 RunStoragePath() string 32 33 // RunVMStoragePath is the vm directory. 34 // It will contain all guest vm sockets and shared mountpoints. 35 RunVMStoragePath() string 36 }