mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-30 12:34:22 +01:00
virtcontainers: store: Add a ItemLock API
The ItemLock API allows for taking shared and exclusive locks on all items. For virtcontainers, this is specialized into taking locks on the Lock item, and will be used for sandbox locking. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
@@ -202,6 +202,21 @@ func (s *VCStore) Raw(id string) (string, error) {
|
||||
return s.state.Raw(id)
|
||||
}
|
||||
|
||||
// Lock takes an exclusive lock on the virtcontainers state Lock item.
|
||||
func (s *VCStore) Lock() (string, error) {
|
||||
return s.state.ItemLock(Lock, true)
|
||||
}
|
||||
|
||||
// RLock takes a shared lock on the virtcontainers state Lock item.
|
||||
func (s *VCStore) RLock() (string, error) {
|
||||
return s.state.ItemLock(Lock, false)
|
||||
}
|
||||
|
||||
// Unlock unlocks the virtcontainers state Lock item.
|
||||
func (s *VCStore) Unlock(token string) error {
|
||||
return s.state.ItemUnlock(Lock, token)
|
||||
}
|
||||
|
||||
// Utilities for virtcontainers
|
||||
|
||||
// SandboxConfigurationRoot returns a virtcontainers sandbox configuration root URL.
|
||||
|
||||
Reference in New Issue
Block a user