snapshot: Lock instances before making snapshot

This commit is contained in:
Tom Wiesing 2022-10-12 16:18:14 +02:00
parent f1c5d518c2
commit 5e7c5b2d23
No known key found for this signature in database
11 changed files with 167 additions and 0 deletions

View file

@ -44,6 +44,21 @@ type Snapshot struct {
// Snapshot creates a new snapshot of this instance into dest
func (snapshots *Manager) NewSnapshot(instance instances.WissKI, io stream.IOStream, desc SnapshotDescription) (snapshot Snapshot) {
logging.LogMessage(io, "Locking instance")
if err := instance.TryLock(); err != nil {
io.EPrintln(err)
logging.LogMessage(io, "Aborting snapshot creation")
return Snapshot{
ErrPanic: err,
}
}
defer func() {
logging.LogMessage(io, "Unlocking instance")
instance.Unlock()
}()
// setup the snapshot
snapshot.Description = desc
snapshot.Instance = instance.Instance