Skip to content

Commit

Permalink
Merge pull request #17838 from baude/addhv1
Browse files Browse the repository at this point in the history
basic hypverv machine implementation
  • Loading branch information
openshift-merge-robot authored Mar 20, 2023
2 parents 27903e0 + 0dac214 commit 060c125
Show file tree
Hide file tree
Showing 106 changed files with 9,552 additions and 33 deletions.
6 changes: 3 additions & 3 deletions cmd/podman/machine/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ func hostInfo() (*entities.MachineHostInfo, error) {
}
}

host.VMType = provider.VMType()
host.VMType = provider.VMType().String()

dataDir, err := machine.GetDataDir(host.VMType)
dataDir, err := machine.GetDataDir(provider.VMType())
if err != nil {
return nil, fmt.Errorf("failed to get machine image dir")
}
host.MachineImageDir = dataDir

confDir, err := machine.GetConfDir(host.VMType)
confDir, err := machine.GetConfDir(provider.VMType())
if err != nil {
return nil, fmt.Errorf("failed to get machine config dir %w", err)
}
Expand Down
9 changes: 9 additions & 0 deletions cmd/podman/machine/platform_windows.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package machine

import (
"os"

"github.com/containers/podman/v4/pkg/machine"
"github.com/containers/podman/v4/pkg/machine/hyperv"
"github.com/containers/podman/v4/pkg/machine/wsl"
)

func GetSystemDefaultProvider() machine.VirtProvider {
// This is a work-around for default provider on windows while
// hyperv is one developer.
// TODO this needs to be changed back
if _, exists := os.LookupEnv("HYPERV"); exists {
return hyperv.GetVirtualizationProvider()
}
return wsl.GetWSLProvider()
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/containers/common v0.51.1-0.20230316131336-0be880eaeb02
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/image/v5 v5.24.3-0.20230314083015-0c6d07e02a9a
github.com/containers/libhvee v0.0.1
github.com/containers/ocicrypt v1.1.7
github.com/containers/psgo v1.8.0
github.com/containers/storage v1.45.5-0.20230315220505-1c6287eea927
Expand Down Expand Up @@ -94,6 +95,7 @@ require (
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsouza/go-dockerclient v1.9.3 // indirect
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6J
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
github.com/containers/image/v5 v5.24.3-0.20230314083015-0c6d07e02a9a h1:2xIif78r5x2nmdb5uhjXBZuexiDAt1c/XIXFxFhfKSk=
github.com/containers/image/v5 v5.24.3-0.20230314083015-0c6d07e02a9a/go.mod h1:9PM/hiCVTh6dt8Swi7eYKXKHIaPabHn8gtFV2YD44Mk=
github.com/containers/libhvee v0.0.1 h1:QpknIQ2VG54HLNoXb0ZXdmah8lw7EC2atD5pX7543pI=
github.com/containers/libhvee v0.0.1/go.mod h1:bV1MfbuXk/ZLWHiWZpm8aePOR6iJGD1q55guYhH4CnA=
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA=
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
github.com/containers/ocicrypt v1.0.1/go.mod h1:MeJDzk1RJHv89LjsH0Sp5KTY3ZYkjXO/C+bKAeWFIrc=
Expand Down Expand Up @@ -395,6 +397,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY=
github.com/go-openapi/analysis v0.21.4 h1:ZDFLvSNxpDaomuCueM0BlSXxpANBlFYiBvr+GXrvIHc=
github.com/go-openapi/analysis v0.21.4/go.mod h1:4zQ35W4neeZTqh3ol0rv/O8JBbka9QyAgQRPp9y3pfo=
Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/applehv/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var (
// vmtype refers to qemu (vs libvirt, krun, etc).
vmtype = "apple"
vmtype = machine.AppleHvVirt
)

func GetVirtualizationProvider() machine.VirtProvider {
Expand Down
33 changes: 27 additions & 6 deletions pkg/machine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type VirtProvider interface {
LoadVMByName(name string) (VM, error)
NewMachine(opts InitOptions) (VM, error)
RemoveAndCleanMachines() error
VMType() string
VMType() VMType
}

type RemoteConnectionType string
Expand Down Expand Up @@ -183,7 +183,7 @@ func (rc RemoteConnectionType) MakeSSHURL(host, path, port, userName string) url
}

// GetCacheDir returns the dir where VM images are downloaded into when pulled
func GetCacheDir(vmType string) (string, error) {
func GetCacheDir(vmType VMType) (string, error) {
dataDir, err := GetDataDir(vmType)
if err != nil {
return "", err
Expand All @@ -197,12 +197,12 @@ func GetCacheDir(vmType string) (string, error) {

// GetDataDir returns the filepath where vm images should
// live for podman-machine.
func GetDataDir(vmType string) (string, error) {
func GetDataDir(vmType VMType) (string, error) {
dataDirPrefix, err := DataDirPrefix()
if err != nil {
return "", err
}
dataDir := filepath.Join(dataDirPrefix, vmType)
dataDir := filepath.Join(dataDirPrefix, vmType.String())
if _, err := os.Stat(dataDir); !errors.Is(err, os.ErrNotExist) {
return dataDir, nil
}
Expand All @@ -222,12 +222,12 @@ func DataDirPrefix() (string, error) {

// GetConfigDir returns the filepath to where configuration
// files for podman-machine should live
func GetConfDir(vmType string) (string, error) {
func GetConfDir(vmType VMType) (string, error) {
confDirPrefix, err := ConfDirPrefix()
if err != nil {
return "", err
}
confDir := filepath.Join(confDirPrefix, vmType)
confDir := filepath.Join(confDirPrefix, vmType.String())
if _, err := os.Stat(confDir); !errors.Is(err, os.ErrNotExist) {
return confDir, nil
}
Expand Down Expand Up @@ -379,3 +379,24 @@ type ConnectionConfig struct {
// PodmanPipe is the exported podman service named pipe (Windows hosts only)
PodmanPipe *VMFile `json:"PodmanPipe"`
}

type VMType int64

const (
QemuVirt VMType = iota
WSLVirt
AppleHvVirt
HyperVVirt
)

func (v VMType) String() string {
switch v {
case WSLVirt:
return "wsl"
case AppleHvVirt:
return "applehv"
case HyperVVirt:
return "hyperv"
}
return "qemu"
}
2 changes: 1 addition & 1 deletion pkg/machine/fcos.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type FcosDownload struct {
Download
}

func NewFcosDownloader(vmType, vmName string, imageStream FCOSStream, vp VirtProvider) (DistributionDownload, error) {
func NewFcosDownloader(vmType VMType, vmName string, imageStream FCOSStream, vp VirtProvider) (DistributionDownload, error) {
info, err := GetFCOSDownload(vp, imageStream)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 060c125

Please sign in to comment.