summaryrefslogtreecommitdiff
path: root/pkg/machine/qemu
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2022-06-22 14:17:30 -0500
committerBrent Baude <bbaude@redhat.com>2022-06-27 12:40:15 -0500
commit99f68898c0f1c4564cebd6a3ee18418c74684403 (patch)
tree71cfe2b3ccbeb592a7c0d380099b4c0b649e24eb /pkg/machine/qemu
parent1022ea36dd36cf57a2556f5eac99b30500513e08 (diff)
downloadpodman-99f68898c0f1c4564cebd6a3ee18418c74684403.tar.gz
podman-99f68898c0f1c4564cebd6a3ee18418c74684403.tar.bz2
podman-99f68898c0f1c4564cebd6a3ee18418c74684403.zip
reveal machine error, ignore false state
This PR covers two edge cases discovered by fiddling with machine manually. It is possible (like after a manual cleanup of a machine) that a leftover qemu socket file can indicate the prescense of a machine running. Also, reveal the error of a Exec.Command by wrapping the generic error around what was in stderr. [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/machine/qemu')
-rw-r--r--pkg/machine/qemu/machine.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index 5094345ea..f7ef52573 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -930,7 +930,12 @@ func (v *MachineVM) State(bypass bool) (machine.Status, error) {
}
monitor, err := qmp.NewSocketMonitor(v.QMPMonitor.Network, v.QMPMonitor.Address.GetPath(), v.QMPMonitor.Timeout)
if err != nil {
- // FIXME: this error should probably be returned
+ // If an improper cleanup was done and the socketmonitor was not deleted,
+ // it can appear as though the machine state is not stopped. Check for ECONNREFUSED
+ // almost assures us that the vm is stopped.
+ if errors.Is(err, syscall.ECONNREFUSED) {
+ return machine.Stopped, nil
+ }
return "", err
}
if err := monitor.Connect(); err != nil {