mirror of
				https://github.com/containers/podman.git
				synced 2025-11-04 08:56:05 +08:00 
			
		
		
		
	Merge pull request #13620 from Luap99/qemu-path
podman machine start: lookup qemu path again if not found
This commit is contained in:
		@ -98,7 +98,7 @@ func (p *Provider) NewMachine(opts machine.InitOptions) (machine.VM, error) {
 | 
				
			|||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd := append([]string{execPath})
 | 
						cmd := []string{execPath}
 | 
				
			||||||
	// Add memory
 | 
						// Add memory
 | 
				
			||||||
	cmd = append(cmd, []string{"-m", strconv.Itoa(int(vm.Memory))}...)
 | 
						cmd = append(cmd, []string{"-m", strconv.Itoa(int(vm.Memory))}...)
 | 
				
			||||||
	// Add cpus
 | 
						// Add cpus
 | 
				
			||||||
@ -430,13 +430,29 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Disable graphic window when not in debug mode
 | 
						// Disable graphic window when not in debug mode
 | 
				
			||||||
	// Done in start, so we're not suck with the debug level we used on init
 | 
						// Done in start, so we're not suck with the debug level we used on init
 | 
				
			||||||
	if logrus.GetLevel() != logrus.DebugLevel {
 | 
						if !logrus.IsLevelEnabled(logrus.DebugLevel) {
 | 
				
			||||||
		cmd = append(cmd, "-display", "none")
 | 
							cmd = append(cmd, "-display", "none")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_, err = os.StartProcess(v.CmdLine[0], cmd, attr)
 | 
						_, err = os.StartProcess(v.CmdLine[0], cmd, attr)
 | 
				
			||||||
	if err != nil {
 | 
						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 ...")
 | 
						fmt.Println("Waiting for VM ...")
 | 
				
			||||||
	socketPath, err := getRuntimeDir()
 | 
						socketPath, err := getRuntimeDir()
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user