Skip to content

Commit

Permalink
macos: Remove no longer needed code
Browse files Browse the repository at this point in the history
After the switch to UEFI, we can remove all the code related to
externally-provided kernel/initramfs/kernel command line.
  • Loading branch information
cfergeau committed Jun 18, 2024
1 parent e3a55b1 commit 1f37239
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 81 deletions.
2 changes: 0 additions & 2 deletions pkg/crc/machine/bundle/copier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ func createDummyBundleFiles(t *testing.T, bundle *CrcBundleInfo) {
bundle.GetKubeConfigPath(),
bundle.GetSSHKeyPath(),
bundle.GetDiskImagePath(),
bundle.GetKernelPath(),
bundle.GetInitramfsPath(),
}

for _, file := range files {
Expand Down
23 changes: 0 additions & 23 deletions pkg/crc/machine/bundle/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ type Node struct {
Kind []string `json:"kind"`
Hostname string `json:"hostname"`
DiskImage string `json:"diskImage"`
KernelCmdLine string `json:"kernelCmdLine,omitempty"`
Initramfs string `json:"initramfs,omitempty"`
Kernel string `json:"kernel,omitempty"`
InternalIP string `json:"internalIP"`
PodmanVersion string `json:"podmanVersion,omitempty"`
}
Expand Down Expand Up @@ -145,24 +142,6 @@ func (bundle *CrcBundleInfo) GetSSHKeyPath() string {
return bundle.resolvePath(bundle.ClusterInfo.SSHPrivateKeyFile)
}

func (bundle *CrcBundleInfo) GetKernelPath() string {
if bundle.Nodes[0].Kernel == "" {
return ""
}
return bundle.resolvePath(bundle.Nodes[0].Kernel)
}

func (bundle *CrcBundleInfo) GetInitramfsPath() string {
if bundle.Nodes[0].Initramfs == "" {
return ""
}
return bundle.resolvePath(bundle.Nodes[0].Initramfs)
}

func (bundle *CrcBundleInfo) GetKernelCommandLine() string {
return bundle.Nodes[0].KernelCmdLine
}

func (bundle *CrcBundleInfo) GetBundleBuildTime() (time.Time, error) {
return time.Parse(time.RFC3339, strings.TrimSpace(bundle.BuildInfo.BuildTime))
}
Expand Down Expand Up @@ -200,8 +179,6 @@ func (bundle *CrcBundleInfo) verify() error {
files := []string{
bundle.GetSSHKeyPath(),
bundle.GetDiskImagePath(),
bundle.GetKernelPath(),
bundle.GetInitramfsPath(),
bundle.GetOcPath(),
bundle.GetKubeConfigPath()}

Expand Down
5 changes: 0 additions & 5 deletions pkg/crc/machine/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ type MachineConfig struct {
SharedDirPassword string
SharedDirUsername string

// macOS specific configuration
KernelCmdLine string
Initramfs string
Kernel string

// Experimental features
NetworkMode network.Mode
}
29 changes: 0 additions & 29 deletions pkg/crc/machine/driver_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"

"github.com/crc-org/crc/v2/pkg/crc/logging"
"github.com/crc-org/crc/v2/pkg/crc/machine/config"
"github.com/crc-org/crc/v2/pkg/crc/machine/vfkit"
machineVf "github.com/crc-org/crc/v2/pkg/drivers/vfkit"
Expand Down Expand Up @@ -37,34 +36,6 @@ func updateDriverConfig(host *host.Host, driver *machineVf.Driver) error {
return host.UpdateConfig(driverData)
}

func updateKernelArgs(vm *virtualMachine) error {
logging.Info("Updating kernel args...")
sshRunner, err := vm.SSHRunner()
if err != nil {
return err
}
defer sshRunner.Close()

stdout, stderr, err := sshRunner.RunPrivileged("Get kernel args", `-- sh -c 'rpm-ostree kargs'`)
if err != nil {
logging.Errorf("Failed to get kernel args: %v - %s", err, stderr)
return err
}
logging.Debugf("Kernel args: %s", stdout)

vfkitDriver, err := loadDriverConfig(vm.Host)
if err != nil {
return err
}
logging.Debugf("Current Kernel args: %s", vfkitDriver.Cmdline)
vfkitDriver.Cmdline = stdout

if err := updateDriverConfig(vm.Host, vfkitDriver); err != nil {
return err
}
return vm.api.Save(vm.Host)
}

func updateDriverStruct(_ *host.Host, _ *machineVf.Driver) error {
return drivers.ErrNotImplemented
}
4 changes: 0 additions & 4 deletions pkg/crc/machine/driver_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ func updateDriverConfig(host *host.Host, driver *machineLibvirt.Driver) error {
return host.UpdateConfig(driverData)
}

func updateKernelArgs(_ *virtualMachine) error {
return nil
}

/*
func (r *RPCServerDriver) SetConfigRaw(data []byte, _ *struct{}) error {
return json.Unmarshal(data, &r.ActualDriver)
Expand Down
4 changes: 0 additions & 4 deletions pkg/crc/machine/driver_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ func updateDriverConfig(host *host.Host, driver *machineLibhvee.Driver) error {
return host.UpdateConfig(driverData)
}

func updateKernelArgs(_ *virtualMachine) error {
return nil
}

func updateDriverStruct(host *host.Host, driver *machineLibhvee.Driver) error {
host.Driver = driver
return nil
Expand Down
3 changes: 0 additions & 3 deletions pkg/crc/machine/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,6 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
ImageSourcePath: crcBundleMetadata.GetDiskImagePath(),
ImageFormat: crcBundleMetadata.GetDiskImageFormat(),
SSHKeyPath: crcBundleMetadata.GetSSHKeyPath(),
KernelCmdLine: crcBundleMetadata.GetKernelCommandLine(),
Initramfs: crcBundleMetadata.GetInitramfsPath(),
Kernel: crcBundleMetadata.GetKernelPath(),
SharedDirs: sharedDirs,
SharedDirPassword: startConfig.SharedDirPassword,
SharedDirUsername: startConfig.SharedDirUsername,
Expand Down
3 changes: 0 additions & 3 deletions pkg/crc/machine/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ func (client *client) Stop() (state.State, error) {
logging.Debugf("%v", err)
}
}
if err := updateKernelArgs(vm); err != nil {
logging.Debugf("%v", err)
}
logging.Info("Stopping the instance, this may take a few minutes...")
if err := vm.Stop(); err != nil {
status, stateErr := vm.State()
Expand Down
3 changes: 0 additions & 3 deletions pkg/crc/machine/vfkit/driver_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ func CreateHost(machineConfig config.MachineConfig) *vfkit.Driver {

config.InitVMDriverFromMachineConfig(machineConfig, vfDriver.VMDriver)

vfDriver.Cmdline = machineConfig.KernelCmdLine
vfDriver.VmlinuzPath = machineConfig.Kernel
vfDriver.InitrdPath = machineConfig.Initramfs
vfDriver.VfkitPath = ExecutablePath()

vfDriver.VirtioNet = machineConfig.NetworkMode == network.SystemNetworkingMode
Expand Down
7 changes: 2 additions & 5 deletions pkg/drivers/vfkit/driver_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ import (

type Driver struct {
*drivers.VMDriver
VmlinuzPath string
Cmdline string
InitrdPath string
VfkitPath string
VirtioNet bool
VfkitPath string
VirtioNet bool

VsockPath string
DaemonVsockPort uint
Expand Down

0 comments on commit 1f37239

Please sign in to comment.