From 27b2e2bd30952f1eab47ad1b68d0a2b3eeab7470 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 27 May 2024 14:21:50 +0200 Subject: [PATCH 1/2] macos: Boot the VM using UEFI --- pkg/drivers/vfkit/driver_darwin.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/drivers/vfkit/driver_darwin.go b/pkg/drivers/vfkit/driver_darwin.go index d57a21982c..15e4c2e97c 100644 --- a/pkg/drivers/vfkit/driver_darwin.go +++ b/pkg/drivers/vfkit/driver_darwin.go @@ -170,11 +170,10 @@ func (d *Driver) Start() error { return err } - bootLoader := config.NewLinuxBootloader( - d.VmlinuzPath, - "console=hvc0 "+d.Cmdline, - d.InitrdPath, - ) + efiStore := d.ResolveStorePath("efistore.nvram") + create := !crcos.FileExists(efiStore) + + bootLoader := config.NewEFIBootloader(efiStore, create) vm := config.NewVirtualMachine( uint(d.CPU), From 4fd662ae4e822a5ffb63f8b97ca89e6bcd212890 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 27 May 2024 14:20:57 +0200 Subject: [PATCH 2/2] macos: Remove no longer needed code After the switch to UEFI, we can remove all the code related to externally-provided kernel/initramfs/kernel command line. --- pkg/crc/machine/bundle/copier_test.go | 2 -- pkg/crc/machine/bundle/metadata.go | 23 -------------------- pkg/crc/machine/config/config.go | 5 ----- pkg/crc/machine/driver_darwin.go | 29 -------------------------- pkg/crc/machine/driver_linux.go | 4 ---- pkg/crc/machine/driver_windows.go | 4 ---- pkg/crc/machine/start.go | 3 --- pkg/crc/machine/stop.go | 3 --- pkg/crc/machine/vfkit/driver_darwin.go | 3 --- pkg/drivers/vfkit/driver_darwin.go | 7 ++----- 10 files changed, 2 insertions(+), 81 deletions(-) diff --git a/pkg/crc/machine/bundle/copier_test.go b/pkg/crc/machine/bundle/copier_test.go index d7f137b820..c8d474e18c 100644 --- a/pkg/crc/machine/bundle/copier_test.go +++ b/pkg/crc/machine/bundle/copier_test.go @@ -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 { diff --git a/pkg/crc/machine/bundle/metadata.go b/pkg/crc/machine/bundle/metadata.go index 2118784a18..2eead2a612 100644 --- a/pkg/crc/machine/bundle/metadata.go +++ b/pkg/crc/machine/bundle/metadata.go @@ -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"` } @@ -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)) } @@ -200,8 +179,6 @@ func (bundle *CrcBundleInfo) verify() error { files := []string{ bundle.GetSSHKeyPath(), bundle.GetDiskImagePath(), - bundle.GetKernelPath(), - bundle.GetInitramfsPath(), bundle.GetOcPath(), bundle.GetKubeConfigPath()} diff --git a/pkg/crc/machine/config/config.go b/pkg/crc/machine/config/config.go index 9bb3fd422f..2b2ecbf080 100644 --- a/pkg/crc/machine/config/config.go +++ b/pkg/crc/machine/config/config.go @@ -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 } diff --git a/pkg/crc/machine/driver_darwin.go b/pkg/crc/machine/driver_darwin.go index be73283bbf..9567304ebf 100644 --- a/pkg/crc/machine/driver_darwin.go +++ b/pkg/crc/machine/driver_darwin.go @@ -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" @@ -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 } diff --git a/pkg/crc/machine/driver_linux.go b/pkg/crc/machine/driver_linux.go index 87b334b4d1..87e4475c0b 100644 --- a/pkg/crc/machine/driver_linux.go +++ b/pkg/crc/machine/driver_linux.go @@ -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) diff --git a/pkg/crc/machine/driver_windows.go b/pkg/crc/machine/driver_windows.go index 0b1c4b25c0..bff7816955 100644 --- a/pkg/crc/machine/driver_windows.go +++ b/pkg/crc/machine/driver_windows.go @@ -34,10 +34,6 @@ func updateDriverConfig(host *host.Host, driver *machineHyperv.Driver) error { return host.UpdateConfig(driverData) } -func updateKernelArgs(_ *virtualMachine) error { - return nil -} - func updateDriverStruct(host *host.Host, driver *machineHyperv.Driver) error { host.Driver = driver return nil diff --git a/pkg/crc/machine/start.go b/pkg/crc/machine/start.go index e0cb87deb8..889d8a363d 100644 --- a/pkg/crc/machine/start.go +++ b/pkg/crc/machine/start.go @@ -317,9 +317,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, diff --git a/pkg/crc/machine/stop.go b/pkg/crc/machine/stop.go index e355563a2f..ab9e37bb2b 100644 --- a/pkg/crc/machine/stop.go +++ b/pkg/crc/machine/stop.go @@ -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() diff --git a/pkg/crc/machine/vfkit/driver_darwin.go b/pkg/crc/machine/vfkit/driver_darwin.go index 63a1c9c0c5..882f8ccaf1 100644 --- a/pkg/crc/machine/vfkit/driver_darwin.go +++ b/pkg/crc/machine/vfkit/driver_darwin.go @@ -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 diff --git a/pkg/drivers/vfkit/driver_darwin.go b/pkg/drivers/vfkit/driver_darwin.go index 15e4c2e97c..222fe2ec0f 100644 --- a/pkg/drivers/vfkit/driver_darwin.go +++ b/pkg/drivers/vfkit/driver_darwin.go @@ -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