Files
podman/pkg/machine/define/errors.go
lstocchi a9a9eda883 rename ErrRelaunchAttempt to ErrRelaunchSucceeded and fix elevated error handling
The old ErrRelaunchAttempt name was ambiguous — it reads as though the
relaunch attempt failed, when it actually signals success. Rename to
ErrRelaunchSucceeded and update comments at every call site to clarify
that this is not a real error but a sentinel indicating the elevated
child process completed the operation successfully.

Also fix a bug in WSL's launchElevate where a failed elevated process
was incorrectly wrapped with the sentinel, causing callers to treat the
failure as success and print "Machine init complete."

Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-04-03 18:37:24 +02:00

61 lines
1.5 KiB
Go

package define
import (
"errors"
"fmt"
)
var (
ErrWrongState = errors.New("VM in wrong state to perform action")
ErrNotImplemented = errors.New("functionality not implemented")
ErrRelaunchSucceeded = errors.New("stopping execution: command relaunched with --reexec flag for elevated privileges succeeded")
ErrRebootInitiated = errors.New("system reboot initiated")
)
type ErrVMAlreadyExists struct {
Name string
}
func (err *ErrVMAlreadyExists) Error() string {
return fmt.Sprintf("machine %q already exists", err.Name)
}
type ErrVMRunningCannotDestroyed struct {
Name string
}
func (err *ErrVMRunningCannotDestroyed) Error() string {
return fmt.Sprintf("running vm %q cannot be destroyed", err.Name)
}
type ErrVMDoesNotExist struct {
Name string
}
func (err *ErrVMDoesNotExist) Error() string {
// the current error in qemu is not quoted
return fmt.Sprintf("%s: VM does not exist", err.Name)
}
type ErrIncompatibleMachineConfig struct {
Name string
Path string
}
func (err *ErrIncompatibleMachineConfig) Error() string {
return fmt.Sprintf("incompatible machine config %q (%s) for this version of Podman", err.Path, err.Name)
}
type ErrMultipleActiveVM struct {
Name string
Provider string
}
func (err *ErrMultipleActiveVM) Error() string {
msg := ""
if err.Provider != "" {
msg = " on the " + err.Provider + " provider"
}
return fmt.Sprintf("%s already starting or running%s: only one VM can be active at a time", err.Name, msg)
}