Files
podman/pkg/machine/define/errors.go
Brent Baude 4eeaedfe13 Prevent two podman machines running on darwin
As issue #25112 points out, it was possible to start a machine on one of the darwin providers and then switch providers and start another one with a different name.  This PR firstly prevents that use which is a forbidden use case.

Secondarily, performed some minor cleanup on the error messages being used so that the error would be specific to this condition.

This bug fix is for darwin only.  In the case of Windows, we probably need to answer the question I raised in #24067 first, which is whether we want to stop allowing WSL to run multiple machines.

Fixes #25112

Signed-off-by: Brent Baude <bbaude@redhat.com>
2025-01-29 13:24:18 -06:00

62 lines
1.4 KiB
Go

package define
import (
"errors"
"fmt"
"github.com/containers/common/pkg/strongunits"
)
var (
ErrWrongState = errors.New("VM in wrong state to perform action")
ErrVMAlreadyExists = errors.New("VM already exists")
ErrNotImplemented = errors.New("functionality not implemented")
)
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 ErrNewDiskSizeTooSmall struct {
OldSize, NewSize strongunits.GiB
}
func (err *ErrNewDiskSizeTooSmall) Error() string {
return fmt.Sprintf("invalid disk size %d: new disk must be larger than %dGB", err.OldSize, err.NewSize)
}
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)
}