aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2022-03-23 18:22:18 +0100
committerMatthew Heon <mheon@redhat.com>2022-03-30 15:36:05 -0400
commit07c5946d9c2b3892a0562a5b78d2061b0c0d1c25 (patch)
treeea0d723485ebdf7ed92e04522b66de86a1ee5c93
parent770594381611308c4feeb310d8b8ac68759287db (diff)
downloadpodman-07c5946d9c2b3892a0562a5b78d2061b0c0d1c25.tar.gz
podman-07c5946d9c2b3892a0562a5b78d2061b0c0d1c25.tar.bz2
podman-07c5946d9c2b3892a0562a5b78d2061b0c0d1c25.zip
podman machine start: lookup qemu path again if not found
We store the full path to qemu in the machine config. When the path changes on the host the machine can longer be started. To fix it we get the path again when we fail to start the machine due the missing binary. We want to store and use the full path first because otherwise existing machines can break when the qemu version changed. [NO NEW TESTS NEEDED] We still have no machine tests. Fixes #13394 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r--pkg/machine/qemu/machine.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index d4a2cffac..b440d9de2 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -98,7 +98,7 @@ func (p *Provider) NewMachine(opts machine.InitOptions) (machine.VM, error) {
return nil, err
}
- cmd := append([]string{execPath})
+ cmd := []string{execPath}
// Add memory
cmd = append(cmd, []string{"-m", strconv.Itoa(int(vm.Memory))}...)
// Add cpus
@@ -434,7 +434,23 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
_, err = os.StartProcess(v.CmdLine[0], cmd, attr)
if err != nil {
- return err
+ // check if qemu was not found
+ if !errors.Is(err, os.ErrNotExist) {
+ return err
+ }
+ // lookup qemu again maybe the path was changed, https://github.com/containers/podman/issues/13394
+ cfg, err := config.Default()
+ if err != nil {
+ return err
+ }
+ cmd[0], err = cfg.FindHelperBinary(QemuCommand, true)
+ if err != nil {
+ return err
+ }
+ _, err = os.StartProcess(cmd[0], cmd, attr)
+ if err != nil {
+ return err
+ }
}
fmt.Println("Waiting for VM ...")
socketPath, err := getRuntimeDir()