Skip to content

Commit

Permalink
podman machine start: lookup qemu path again if not found
Browse files Browse the repository at this point in the history
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 containers#13394

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Mar 23, 2022
1 parent f049cba commit 59dc70b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pkg/machine/qemu/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -436,7 +436,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()
Expand Down

0 comments on commit 59dc70b

Please sign in to comment.