make return explicit so CleanIfErr runs as expectd

Signed-off-by: Jait Jacob <jai8.jacob@gmail.com>
This commit is contained in:
Jait Jacob 2026-07-21 23:30:29 +05:30
parent 2ad3a79631
commit eb26516dba
No known key found for this signature in database
GPG key ID: 10414D17D526AA85

View file

@ -439,23 +439,29 @@ func StopThenStart(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, hardSto
}
mc.Lock()
defer mc.Unlock()
if err := mc.Refresh(); err != nil {
return fmt.Errorf("reload config: %w", err)
}
if err := stopLocked(mc, mp, dirs, hardStop); err != nil {
err = mc.Refresh()
if err != nil {
err = fmt.Errorf("reload config: %w", err)
return err
}
if err := mc.Refresh(); err != nil {
return fmt.Errorf("reload config: %w", err)
err = stopLocked(mc, mp, dirs, hardStop)
if err != nil {
return err
}
err = mc.Refresh()
if err != nil {
err = fmt.Errorf("reload config: %w", err)
return err
}
callbackFuncs := machine.CleanUp()
defer callbackFuncs.CleanIfErr(&err)
go callbackFuncs.CleanOnSignal(opts.Quiet)
return startLocked(mc, mp, dirs, opts, updateSystemConn, &callbackFuncs)
err = startLocked(mc, mp, dirs, opts, updateSystemConn, &callbackFuncs)
return err
}
// stopLocked stops the machine and expects the caller to hold the machine's lock.
@ -537,11 +543,14 @@ func Start(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, opts machine.St
defer func() { _ = mcunlock() }()
}
if err = mc.Refresh(); err != nil {
return fmt.Errorf("reload config: %w", err)
err = mc.Refresh()
if err != nil {
err = fmt.Errorf("reload config: %w", err)
return err
}
return startLocked(mc, mp, dirs, opts, updateSystemConn, &callbackFuncs)
err = startLocked(mc, mp, dirs, opts, updateSystemConn, &callbackFuncs)
return err
}
// startLocked starts the machine and expects the caller to hold the machine's lock.