Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vfkit: Switch to EFIBootLoader from LinuxBootLoader (BIOS) #4309

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 *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
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 @@ -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,
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
16 changes: 6 additions & 10 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 Expand Up @@ -170,11 +167,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),
Expand Down