mirror of
https://github.com/containers/podman.git
synced 2025-10-17 19:24:04 +08:00

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>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package provider
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/containers/common/pkg/config"
|
|
"github.com/containers/podman/v5/pkg/machine/applehv"
|
|
"github.com/containers/podman/v5/pkg/machine/define"
|
|
"github.com/containers/podman/v5/pkg/machine/libkrun"
|
|
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func Get() (vmconfigs.VMProvider, error) {
|
|
cfg, err := config.Default()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
provider := cfg.Machine.Provider
|
|
if providerOverride, found := os.LookupEnv("CONTAINERS_MACHINE_PROVIDER"); found {
|
|
provider = providerOverride
|
|
}
|
|
resolvedVMType, err := define.ParseVMType(provider, define.AppleHvVirt)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
logrus.Debugf("Using Podman machine with `%s` virtualization provider", resolvedVMType.String())
|
|
switch resolvedVMType {
|
|
case define.AppleHvVirt:
|
|
return new(applehv.AppleHVStubber), nil
|
|
case define.LibKrun:
|
|
return new(libkrun.LibKrunStubber), nil
|
|
default:
|
|
return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String())
|
|
}
|
|
}
|