Skip to content

Commit

Permalink
Use libhvee instead of the current PowerShell cmdlet implementation
Browse files Browse the repository at this point in the history
This replaces the interaction of Hyper-V from our machine-drivers based
driver as used in Minikube/minishift to the libhvee library as used by
podman machine.
  • Loading branch information
gbraad authored and praveenkumar committed Sep 23, 2024
1 parent 593eaab commit e5e2fde
Show file tree
Hide file tree
Showing 51 changed files with 6,256 additions and 355 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/cheggaaa/pb/v3 v3.1.5
github.com/containers/gvisor-tap-vsock v0.7.5
github.com/containers/image/v5 v5.32.2
github.com/containers/libhvee v0.7.1
github.com/coreos/go-systemd/v22 v22.5.0
github.com/crc-org/admin-helper v0.5.4
github.com/crc-org/machine v0.0.0-20240715101719-0c1bc9eb95f8
Expand Down Expand Up @@ -76,6 +77,7 @@ require (
github.com/areYouLazy/libhosty v1.1.0 // indirect
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containers/common v0.59.1 // indirect
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
github.com/containers/ocicrypt v1.2.0 // indirect
github.com/containers/storage v1.55.0 // indirect
Expand All @@ -96,7 +98,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
Expand Down
7 changes: 6 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vc
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/containers/common v0.59.1 h1:7VkmJN3YvD0jLFwaUjLHSRJ98JLffydiyOJjYr0dUTo=
github.com/containers/common v0.59.1/go.mod h1:53VicJCZ2AD0O+Br7VVoyrS7viXF4YmwlTIocWUT8XE=
github.com/containers/gvisor-tap-vsock v0.7.5 h1:bTy4u3DOmmUPwurL6me2rsgfypAFDhyeJleUcQmBR/E=
github.com/containers/gvisor-tap-vsock v0.7.5/go.mod h1:GW9jOqAEEGdaS20XwTYdm6KCYDHIulOE/yEEOabkoE4=
github.com/containers/image/v5 v5.32.2 h1:SzNE2Y6sf9b1GJoC8qjCuMBXwQrACFp4p0RK15+4gmQ=
github.com/containers/image/v5 v5.32.2/go.mod h1:v1l73VeMugfj/QtKI+jhYbwnwFCFnNGckvbST3rQ5Hk=
github.com/containers/libhvee v0.7.1 h1:dWGF5GLq9DZvXo3P8aDp3cNieL5eCaSell4UmeA/jY4=
github.com/containers/libhvee v0.7.1/go.mod h1:fRKB3AyIqHMvq6xaeYhTpckM2cdoq0oecolyoiuLP7M=
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.2.0 h1:X14EgRK3xNFvJEfI5O4Qn4T3E25ANudSOZz/sirVuPM=
Expand Down Expand Up @@ -118,8 +122,9 @@ github.com/go-jose/go-jose/v4 v4.0.2 h1:R3l3kkBds16bO7ZFAEEcofK0MkrAJt3jlJznWZG0
github.com/go-jose/go-jose/v4 v4.0.2/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
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-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-openapi/analysis v0.23.0 h1:aGday7OWupfMs+LbmLZG4k0MYXIANxcuBTYUC03zFCU=
github.com/go-openapi/analysis v0.23.0/go.mod h1:9mz9ZWaSlV8TvjQHLl2mUW2PbZtemkE8yA5v22ohupo=
github.com/go-openapi/errors v0.22.0 h1:c4xY/OLxUBSTiepAg3j/MHuAv5mJhnf53LLMWFB+u/w=
Expand Down
18 changes: 9 additions & 9 deletions pkg/crc/machine/driver_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@ import (
"errors"

"github.com/crc-org/crc/v2/pkg/crc/machine/config"
"github.com/crc-org/crc/v2/pkg/crc/machine/hyperv"
machineHyperv "github.com/crc-org/crc/v2/pkg/drivers/hyperv"
"github.com/crc-org/crc/v2/pkg/crc/machine/libhvee"
machineLibhvee "github.com/crc-org/crc/v2/pkg/drivers/libhvee"
"github.com/crc-org/crc/v2/pkg/libmachine"
"github.com/crc-org/crc/v2/pkg/libmachine/host"
)

func newHost(api libmachine.API, machineConfig config.MachineConfig) (*host.Host, error) {
json, err := json.Marshal(hyperv.CreateHost(machineConfig))
json, err := json.Marshal(libhvee.CreateHost(machineConfig))
if err != nil {
return nil, errors.New("Failed to marshal driver options")
}
return api.NewHost("hyperv", "", json)
}

func loadDriverConfig(host *host.Host) (*machineHyperv.Driver, error) {
var hypervDriver machineHyperv.Driver
err := json.Unmarshal(host.RawDriver, &hypervDriver)
func loadDriverConfig(host *host.Host) (*machineLibhvee.Driver, error) {
var libhveeDriver machineLibhvee.Driver
err := json.Unmarshal(host.RawDriver, &libhveeDriver)

return &hypervDriver, err
return &libhveeDriver, err
}

func updateDriverConfig(host *host.Host, driver *machineHyperv.Driver) error {
func updateDriverConfig(host *host.Host, driver *machineLibhvee.Driver) error {
driverData, err := json.Marshal(driver)
if err != nil {
return err
}
return host.UpdateConfig(driverData)
}

func updateDriverStruct(host *host.Host, driver *machineHyperv.Driver) error {
func updateDriverStruct(host *host.Host, driver *machineLibhvee.Driver) error {
host.Driver = driver
return nil
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
package hyperv
package libhvee

import (
"path/filepath"
"strings"

"github.com/crc-org/crc/v2/pkg/crc/constants"
"github.com/crc-org/crc/v2/pkg/crc/machine/config"
"github.com/crc-org/crc/v2/pkg/drivers/hyperv"
"github.com/crc-org/crc/v2/pkg/drivers/libhvee"
"github.com/crc-org/machine/libmachine/drivers"
)

func CreateHost(machineConfig config.MachineConfig) *hyperv.Driver {
hypervDriver := hyperv.NewDriver(machineConfig.Name, constants.MachineBaseDir)
func CreateHost(machineConfig config.MachineConfig) *libhvee.Driver {
libhveeDriver := libhvee.NewDriver(machineConfig.Name, constants.MachineBaseDir)

config.InitVMDriverFromMachineConfig(machineConfig, hypervDriver.VMDriver)
config.InitVMDriverFromMachineConfig(machineConfig, libhveeDriver.VMDriver)

hypervDriver.DisableDynamicMemory = true

hypervDriver.SharedDirs = configureShareDirs(machineConfig)
return hypervDriver
libhveeDriver.SharedDirs = configureShareDirs(machineConfig)
return libhveeDriver
}

// converts a path like c:\users\crc to /mnt/c/users/crc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hyperv
package libhvee

import (
"testing"
Expand Down
Loading

0 comments on commit e5e2fde

Please sign in to comment.