spiegel_podman/pkg/machine/applehv/rest_config.go
Brent Baude dc7515dc32 MVP for Podman Machine with AppleHV
this pr is the first pass at enabling podman machine to use the apple hypervisor. there are still several TODO
areas like host networking.  once the decision is handled on what host networking should look like, these TODOs
should be fairly quick to resolve.  they also will impact the remove methods.

you must also have vfkit (https://github.com/crc-org/vfkit)

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-05-02 13:09:56 -05:00

40 lines
1.6 KiB
Go

//go:build arm64 && darwin
package applehv
import (
"errors"
"fmt"
"github.com/containers/podman/v4/pkg/machine"
)
// VZMachineState is what the restful service in vfkit will return
type VZMachineState string
const (
// Values that the machine can be in
// "VirtualMachineStateStoppedVirtualMachineStateRunningVirtualMachineStatePausedVirtualMachineStateErrorVirtualMachineStateStartingVirtualMachineStatePausingVirtualMachineStateResumingVirtualMachineStateStopping"
VZMachineStateStopped VZMachineState = "VirtualMachineStateStopped"
VZMachineStateRunning VZMachineState = "VirtualMachineStateRunning"
VZMachineStatePaused VZMachineState = "VirtualMachineStatePaused"
VZMachineStateError VZMachineState = "VirtualMachineStateError"
VZMachineStateStarting VZMachineState = "VirtualMachineStateStarting"
VZMachineStatePausing VZMachineState = "VirtualMachineStatePausing"
VZMachineStateResuming VZMachineState = "VirtualMachineStateResuming"
VZMachineStateStopping VZMachineState = "VirtualMachineStateStopping"
)
func ToMachineStatus(val string) (machine.Status, error) {
switch val {
case string(VZMachineStateRunning), string(VZMachineStatePausing), string(VZMachineStateResuming), string(VZMachineStateStopping), string(VZMachineStatePaused):
return machine.Running, nil
case string(VZMachineStateStopped):
return machine.Stopped, nil
case string(VZMachineStateStarting):
return machine.Starting, nil
case string(VZMachineStateError):
return "", errors.New("machine is in error state")
}
return "", fmt.Errorf("unknown machine state: %s", val)
}