snapshot: Lock instances before making snapshot
This commit is contained in:
parent
f1c5d518c2
commit
5e7c5b2d23
11 changed files with 167 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue