Files
Brent Baude d2c1de5993 Add krun support to podman machine
This PR adds libkrun support to podman machine.  This is an experimental feature and should not be marketed yet.  Before we unmark the experimental status on this function, we will need to have full CI support and a full podman point release has pased.

This work relies on the fact that vfkit and libkrun share a reasonably (if not perfectly) same API.  The --log-level debug option will not show a GUI screen for boots as krun is not capable of this.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-04-26 08:58:38 -05:00

43 lines
1.6 KiB
Go

//go:build darwin
package vfkit
import (
"errors"
"fmt"
"github.com/containers/podman/v5/pkg/machine/define"
)
type Endpoint string
// 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) (define.Status, error) {
switch val {
case string(VZMachineStateRunning), string(VZMachineStatePausing), string(VZMachineStateResuming), string(VZMachineStateStopping), string(VZMachineStatePaused):
return define.Running, nil
case string(VZMachineStateStopped):
return define.Stopped, nil
case string(VZMachineStateStarting):
return define.Starting, nil
case string(VZMachineStateError):
return "", errors.New("machine is in error state")
}
return "", fmt.Errorf("unknown machine state: %s", val)
}