Skip to content

Commit c276a83

Browse files
committed
vfkit: Use EFI bootloader
With the fixed iso, we can simplify the driver using the EFI bootloader option[1] instead of the legacy and deprecated --kernel, --kernel-cmdline, and --initrd options[2]. Example run: % minikube start -p vfkit --driver vfkit --container-runtime containerd --network vmnet-shared --iso-url file://$PWD/minikube-arm64-timeout-0.iso 😄 [vfkit] minikube v1.36.0 on Darwin 15.5 (arm64) ✨ Using the vfkit driver based on user configuration 👍 Starting "vfkit" primary control-plane node in "vfkit" cluster 🔥 Creating vfkit VM (CPUs=2, Memory=6000MB, Disk=20000MB) ... 📦 Preparing Kubernetes v1.33.1 on containerd 1.7.23 ... ▪ Generating certificates and keys ... ▪ Booting up control plane ... ▪ Configuring RBAC rules ... 🔗 Configuring bridge CNI (Container Networking Interface) ... 🔎 Verifying Kubernetes components... ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 🌟 Enabled addons: default-storageclass, storage-provisioner 🏄 Done! kubectl is now configured to use "vfkit" cluster and "default" namespace by default This avoids the need to extract the kernel and initrd. I expected to see some speedup but direct kernel boot is little bit faster even including the time to extract the kernel and initrd. [1] https://github.com/crc-org/vfkit/blob/main/doc/usage.md#efi-bootloader [2] https://github.com/crc-org/vfkit/blob/main/doc/usage.md#deprecated-options
1 parent 7e6df61 commit c276a83

File tree

1 file changed

+7
-33
lines changed

1 file changed

+7
-33
lines changed

pkg/drivers/vfkit/vfkit.go

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const (
5757
pidFileName = "vfkit.pid"
5858
sockFilename = "vfkit.sock"
5959
logFileName = "vfkig.log"
60+
efiFileName = "vfkit.efi"
6061
defaultSSHUser = "docker"
6162
)
6263

@@ -189,12 +190,6 @@ func (d *Driver) Create() error {
189190
if err := b2dutils.CopyIsoToMachineDir(d.Boot2DockerURL, d.MachineName); err != nil {
190191
return err
191192
}
192-
isoPath := d.ResolveStorePath(isoFilename)
193-
194-
log.Info("Extracting Kernel...")
195-
if err := d.extractKernel(isoPath); err != nil {
196-
return err
197-
}
198193

199194
log.Info("Creating SSH key...")
200195
if err := ssh.GenerateSSHKey(d.sshKeyPath()); err != nil {
@@ -256,9 +251,10 @@ func (d *Driver) startVfkit(socketPath string) error {
256251
"--memory", fmt.Sprintf("%d", d.Memory),
257252
"--cpus", fmt.Sprintf("%d", d.CPU),
258253
"--restful-uri", fmt.Sprintf("unix://%s", d.sockfilePath()))
259-
var isoPath = filepath.Join(machineDir, isoFilename)
254+
255+
efiPath := d.ResolveStorePath(efiFileName)
260256
startCmd = append(startCmd,
261-
"--device", fmt.Sprintf("virtio-blk,path=%s", isoPath))
257+
"--bootloader", fmt.Sprintf("efi,variable-store=%s,create", efiPath))
262258

263259
if socketPath != "" {
264260
// The guest will be able to access other guests in the vmnet network.
@@ -273,24 +269,18 @@ func (d *Driver) startVfkit(socketPath string) error {
273269
startCmd = append(startCmd,
274270
"--device", "virtio-rng")
275271

272+
var isoPath = filepath.Join(machineDir, isoFilename)
276273
startCmd = append(startCmd,
277-
"--kernel", d.ResolveStorePath("bzimage"))
278-
279-
// Required to enable logging to vfkit.log.
280-
startCmd = append(startCmd,
281-
"--kernel-cmdline", "console=hvc0")
274+
"--device", fmt.Sprintf("virtio-blk,path=%s", isoPath))
282275

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

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

291-
startCmd = append(startCmd,
292-
"--device", fmt.Sprintf("virtio-blk,path=%s", d.diskPath()))
293-
294284
logPath := d.ResolveStorePath(logFileName)
295285
startCmd = append(startCmd,
296286
"--device", fmt.Sprintf("virtio-serial,logFilePath=%s", logPath))
@@ -417,22 +407,6 @@ func (d *Driver) Restart() error {
417407
return d.Start()
418408
}
419409

420-
func (d *Driver) extractKernel(isoPath string) error {
421-
for _, f := range []struct {
422-
pathInIso string
423-
destPath string
424-
}{
425-
{"/boot/bzimage", "bzimage"},
426-
{"/boot/initrd", "initrd"},
427-
} {
428-
fullDestPath := d.ResolveStorePath(f.destPath)
429-
if err := pkgdrivers.ExtractFile(isoPath, f.pathInIso, fullDestPath); err != nil {
430-
return err
431-
}
432-
}
433-
return nil
434-
}
435-
436410
func (d *Driver) killVfkit() error {
437411
if err := d.SetVFKitState("HardStop"); err != nil {
438412
// Typically fails with EOF due to https://github.com/crc-org/vfkit/issues/277.

0 commit comments

Comments
 (0)