-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macos: Switch from hyperkit to vfkit
vfkit is a hypervisor using macOS virtualization framework, which means it has a much smaller codebase. qcow-tool is no longer used, though a replacement will be needed when we implement disk resizing. A lot of this commit is hyperkit->vfkit renaming After this commit, crc will require macOS 11 or newer.
- Loading branch information
1 parent
7ad7b51
commit 25ccb91
Showing
19 changed files
with
129 additions
and
296 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
os: | ||
- macOS-10.15 | ||
- macOS-11 | ||
go: | ||
- 1.16 | ||
|
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
os: | ||
- macOS-10.15 | ||
- macOS-11 | ||
- ubuntu-latest | ||
- ubuntu-18.04 | ||
|
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,61 +1,13 @@ | ||
package cache | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"io" | ||
"strings" | ||
|
||
"github.com/code-ready/crc/pkg/crc/machine/hyperkit" | ||
crcos "github.com/code-ready/crc/pkg/os" | ||
"github.com/code-ready/crc/pkg/crc/machine/vfkit" | ||
) | ||
|
||
func NewMachineDriverHyperKitCache() *Cache { | ||
return New(hyperkit.MachineDriverCommand, hyperkit.MachineDriverDownloadURL, hyperkit.MachineDriverVersion, getHyperKitMachineDriverVersion) | ||
} | ||
|
||
func NewQcowToolCache() *Cache { | ||
return New(hyperkit.QcowToolCommand, hyperkit.QcowToolDownloadURL, hyperkit.QcowToolVersion, getQcowToolVersion) | ||
} | ||
|
||
func NewHyperKitCache() *Cache { | ||
return New(hyperkit.HyperKitCommand, hyperkit.HyperKitDownloadURL, hyperkit.HyperKitVersion, getHyperKitVersion) | ||
} | ||
|
||
func getHyperKitMachineDriverVersion(executablePath string) (string, error) { | ||
return getVersionGeneric(executablePath, "version") | ||
} | ||
|
||
func getQcowToolVersion(executablePath string) (string, error) { | ||
stdout, _, err := crcos.RunWithDefaultLocale(executablePath, "--version") | ||
return strings.TrimSpace(stdout), err | ||
func NewVfkitCache() *Cache { | ||
return New(vfkit.VfkitCommand, vfkit.VfkitDownloadURL, vfkit.VfkitVersion, getVfkitVersion) | ||
} | ||
|
||
/* This is very similar to cache.getVersionGeneric, except that it's reading from stderr instead of | ||
* stdout, and it needs to deal with multiline output | ||
*/ | ||
func getHyperKitVersion(executablePath string) (string, error) { | ||
_, stderr, err := crcos.RunWithDefaultLocale(executablePath, "-v") | ||
if err != nil { | ||
return "", err | ||
} | ||
stderr, err = getFirstLine(stderr) | ||
if err != nil { | ||
return "", err | ||
} | ||
parsedOutput := strings.Split(stderr, ":") | ||
if len(parsedOutput) < 2 { | ||
return "", fmt.Errorf("Unable to parse the version information of %s", executablePath) | ||
} | ||
return strings.TrimSpace(parsedOutput[1]), err | ||
} | ||
|
||
func getFirstLine(s string) (line string, err error) { | ||
reader := bufio.NewReader(strings.NewReader(s)) | ||
line, err = reader.ReadString('\n') | ||
if err != nil && err != io.EOF { | ||
return "", err | ||
} | ||
|
||
return line, nil | ||
func getVfkitVersion(executablePath string) (string, error) { | ||
return getVersionGeneric(executablePath, "-v") | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//go:build darwin || build | ||
// +build darwin build | ||
|
||
package vfkit | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
const ( | ||
VfkitVersion = "0.0.1" | ||
) | ||
|
||
var ( | ||
VfkitCommand = fmt.Sprintf("vfkit-%s", runtime.GOARCH) | ||
VfkitDownloadURL = fmt.Sprintf("https://github.com/code-ready/vfkit/releases/download/v%s/%s", VfkitVersion, VfkitCommand) | ||
) |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package vfkit | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/code-ready/crc/pkg/crc/constants" | ||
"github.com/code-ready/crc/pkg/crc/machine/config" | ||
"github.com/code-ready/crc/pkg/crc/network" | ||
"github.com/code-ready/crc/pkg/drivers/vfkit" | ||
) | ||
|
||
func CreateHost(machineConfig config.MachineConfig) *vfkit.Driver { | ||
vfDriver := vfkit.NewDriver(machineConfig.Name, constants.MachineBaseDir) | ||
|
||
config.InitVMDriverFromMachineConfig(machineConfig, vfDriver.VMDriver) | ||
|
||
vfDriver.Cmdline = machineConfig.KernelCmdLine | ||
vfDriver.VmlinuzPath = machineConfig.Kernel | ||
vfDriver.InitrdPath = machineConfig.Initramfs | ||
vfDriver.VfkitPath = filepath.Join(constants.BinDir(), VfkitCommand) | ||
|
||
vfDriver.VirtioNet = machineConfig.NetworkMode == network.SystemNetworkingMode | ||
vfDriver.VsockPath = constants.TapSocketPath | ||
|
||
return vfDriver | ||
} |
Oops, something went wrong.