Skip to content

Commit

Permalink
Fix locking error in WSL machine rm -f
Browse files Browse the repository at this point in the history
Fixed a bug where `podman machine rm -f` would cause a deadlock when
running with WSL.

The deadlock is caused by the Remove() function calling the Stop()
function after Remove() locks the VM. Stop() also has a lock call, which
fails and deadlocks because Remove() already claimed lock. Fix this by
moving the stop call before the lock

[NO NEW TESTS NEEDED]

Signed-off-by: Ashley Cui <[email protected]>
  • Loading branch information
ashley-cui authored and openshift-cherrypick-robot committed Nov 30, 2023
1 parent 78fdb40 commit a72c39a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/machine/wsl/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1594,9 +1594,6 @@ func readWinProxyTid(v *MachineVM) (uint32, uint32, string, error) {
func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, func() error, error) {
var files []string

v.lock.Lock()
defer v.lock.Unlock()

if v.isRunning() {
if !opts.Force {
return "", nil, &machine.ErrVMRunningCannotDestroyed{Name: v.Name}
Expand All @@ -1606,6 +1603,9 @@ func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, fun
}
}

v.lock.Lock()
defer v.lock.Unlock()

// Collect all the files that need to be destroyed
if !opts.SaveKeys {
files = append(files, v.IdentityPath, v.IdentityPath+".pub")
Expand Down

0 comments on commit a72c39a

Please sign in to comment.