Skip to content

vfkit: Use EFI booloader #20833

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
7 changes: 5 additions & 2 deletions deploy/iso/minikube-iso/board/minikube/aarch64/grub.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
set default="0"
set timeout="5"
set timeout="0"

menuentry "Buildroot" {
linux /boot/bzimage console=ttyAMA0 # kernel
# The console depends on the driver:
# qemu: console=ttyAMA0
# vfkit,krunkit: console=hvc0
linux /boot/bzimage console=ttyAMA0 console=hvc0
initrd /boot/initrd # rootfs
}
2 changes: 1 addition & 1 deletion deploy/iso/minikube-iso/board/minikube/x86_64/grub.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set default="0"
set timeout="5"
set timeout="0"

menuentry "Buildroot" {
linux /boot/bzimage console=tty0 rw # kernel
Expand Down
41 changes: 11 additions & 30 deletions pkg/drivers/vfkit/vfkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const (
isoFilename = "boot2docker.iso"
pidFileName = "vfkit.pid"
sockFilename = "vfkit.sock"
serialFileName = "serial.log"
efiFileName = "vfkit.efi"
defaultSSHUser = "docker"
)

Expand All @@ -67,7 +69,6 @@ type Driver struct {
DiskSize int
CPU int
Memory int
Cmdline string
ExtraDisks int
Network string // "", "nat", "vmnet-shared"
MACAddress string // For network=nat, network=""
Expand Down Expand Up @@ -189,12 +190,6 @@ func (d *Driver) Create() error {
if err := b2dutils.CopyIsoToMachineDir(d.Boot2DockerURL, d.MachineName); err != nil {
return err
}
isoPath := d.ResolveStorePath(isoFilename)

log.Info("Extracting Kernel...")
if err := d.extractKernel(isoPath); err != nil {
return err
}

log.Info("Creating SSH key...")
if err := ssh.GenerateSSHKey(d.sshKeyPath()); err != nil {
Expand Down Expand Up @@ -256,9 +251,10 @@ func (d *Driver) startVfkit(socketPath string) error {
"--memory", fmt.Sprintf("%d", d.Memory),
"--cpus", fmt.Sprintf("%d", d.CPU),
"--restful-uri", fmt.Sprintf("unix://%s", d.sockfilePath()))
var isoPath = filepath.Join(machineDir, isoFilename)

efiPath := d.ResolveStorePath(efiFileName)
startCmd = append(startCmd,
"--device", fmt.Sprintf("virtio-blk,path=%s", isoPath))
"--bootloader", fmt.Sprintf("efi,variable-store=%s,create", efiPath))

if socketPath != "" {
// The guest will be able to access other guests in the vmnet network.
Expand All @@ -273,20 +269,21 @@ func (d *Driver) startVfkit(socketPath string) error {
startCmd = append(startCmd,
"--device", "virtio-rng")

var isoPath = filepath.Join(machineDir, isoFilename)
startCmd = append(startCmd,
"--kernel", d.ResolveStorePath("bzimage"))
startCmd = append(startCmd,
"--kernel-cmdline", d.Cmdline)
"--device", fmt.Sprintf("virtio-blk,path=%s", isoPath))

startCmd = append(startCmd,
"--initrd", d.ResolveStorePath("initrd"))
"--device", fmt.Sprintf("virtio-blk,path=%s", d.diskPath()))

for i := 0; i < d.ExtraDisks; i++ {
startCmd = append(startCmd,
"--device", fmt.Sprintf("virtio-blk,path=%s", pkgdrivers.ExtraDiskPath(d.BaseDriver, i)))
}

serialPath := d.ResolveStorePath(serialFileName)
startCmd = append(startCmd,
"--device", fmt.Sprintf("virtio-blk,path=%s", d.diskPath()))
"--device", fmt.Sprintf("virtio-serial,logFilePath=%s", serialPath))

log.Debugf("executing: vfkit %s", strings.Join(startCmd, " "))
os.Remove(d.sockfilePath())
Expand Down Expand Up @@ -410,22 +407,6 @@ func (d *Driver) Restart() error {
return d.Start()
}

func (d *Driver) extractKernel(isoPath string) error {
for _, f := range []struct {
pathInIso string
destPath string
}{
{"/boot/bzimage", "bzimage"},
{"/boot/initrd", "initrd"},
} {
fullDestPath := d.ResolveStorePath(f.destPath)
if err := pkgdrivers.ExtractFile(isoPath, f.pathInIso, fullDestPath); err != nil {
return err
}
}
return nil
}

func (d *Driver) killVfkit() error {
if err := d.SetVFKitState("HardStop"); err != nil {
// Typically fails with EOF due to https://github.com/crc-org/vfkit/issues/277.
Expand Down
1 change: 0 additions & 1 deletion pkg/minikube/registry/drvs/vfkit/vfkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func configure(cfg config.ClusterConfig, n config.Node) (interface{}, error) {
DiskSize: cfg.DiskSize,
Memory: cfg.Memory,
CPU: cfg.CPUs,
Cmdline: "",
ExtraDisks: cfg.ExtraDisks,
Network: cfg.Network,
MACAddress: mac,
Expand Down