-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23726 from ashley-cui/machlist
machine: Add -all-providers flag to machine list
- Loading branch information
Showing
12 changed files
with
261 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
package e2e_test | ||
|
||
import "github.com/containers/podman/v5/pkg/machine/define" | ||
|
||
const podmanBinary = "../../../bin/darwin/podman" | ||
|
||
func getOtherProvider() string { | ||
if isVmtype(define.AppleHvVirt) { | ||
return "libkrun" | ||
} else if isVmtype(define.LibKrun) { | ||
return "applehv" | ||
} | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
package e2e_test | ||
|
||
const podmanBinary = "../../../bin/podman-remote" | ||
|
||
func getOtherProvider() string { | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,20 @@ | ||
//go:build !windows && !darwin | ||
|
||
package provider | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io/fs" | ||
"os" | ||
|
||
"github.com/containers/common/pkg/config" | ||
"github.com/containers/podman/v5/pkg/machine/define" | ||
"github.com/containers/podman/v5/pkg/machine/qemu" | ||
"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.QemuVirt) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
logrus.Debugf("Using Podman machine with `%s` virtualization provider", resolvedVMType.String()) | ||
switch resolvedVMType { | ||
case define.QemuVirt: | ||
return qemu.NewStubber() | ||
default: | ||
return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String()) | ||
} | ||
} | ||
|
||
func GetAll(_ bool) ([]vmconfigs.VMProvider, error) { | ||
return []vmconfigs.VMProvider{new(qemu.QEMUStubber)}, nil | ||
} | ||
|
||
// SupportedProviders returns the providers that are supported on the host operating system | ||
func SupportedProviders() []define.VMType { | ||
return []define.VMType{define.QemuVirt} | ||
} | ||
|
||
// InstalledProviders returns the supported providers that are installed on the host | ||
func InstalledProviders() ([]define.VMType, error) { | ||
cfg, err := config.Default() | ||
if err != nil { | ||
return nil, err | ||
} | ||
_, err = cfg.FindHelperBinary(qemu.QemuCommand, true) | ||
if errors.Is(err, fs.ErrNotExist) { | ||
return []define.VMType{}, nil | ||
installedTypes := []define.VMType{} | ||
providers := GetAll() | ||
for _, p := range providers { | ||
installed, err := IsInstalled(p.VMType()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if installed { | ||
installedTypes = append(installedTypes, p.VMType()) | ||
} | ||
} | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return []define.VMType{define.QemuVirt}, nil | ||
} | ||
|
||
// HasPermsForProvider returns whether the host operating system has the proper permissions to use the given provider | ||
func HasPermsForProvider(provider define.VMType) bool { | ||
// there are no permissions required for QEMU | ||
return provider == define.QemuVirt | ||
return installedTypes, nil | ||
} |
Oops, something went wrong.