Skip to content

vfkit: Extract isoPath() helper #21111

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

Merged
merged 1 commit into from
Jul 28, 2025
Merged
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
14 changes: 7 additions & 7 deletions pkg/drivers/vfkit/vfkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,10 @@ func (d *Driver) Create() error {

func (d *Driver) extractKernel() error {
log.Info("Extracting bzimage and initrd...")
isoPath := d.ResolveStorePath(isoFilename)
if err := pkgdrivers.ExtractFile(isoPath, "/boot/bzimage", d.kernelPath()); err != nil {
if err := pkgdrivers.ExtractFile(d.isoPath(), "/boot/bzimage", d.kernelPath()); err != nil {
return err
}
return pkgdrivers.ExtractFile(isoPath, "/boot/initrd", d.initrdPath())
return pkgdrivers.ExtractFile(d.isoPath(), "/boot/initrd", d.initrdPath())
}

func (d *Driver) Start() error {
Expand Down Expand Up @@ -258,8 +257,6 @@ func (d *Driver) Start() error {
// startVfkit starts the vfkit child process. If socketPath is not empty, vfkit
// is connected to the vmnet network via the socket instead of "nat" network.
func (d *Driver) startVfkit(socketPath string) error {
machineDir := filepath.Join(d.StorePath, "machines", d.GetMachineName())

var startCmd []string

startCmd = append(startCmd,
Expand Down Expand Up @@ -296,9 +293,8 @@ func (d *Driver) startVfkit(socketPath string) error {
startCmd = append(startCmd,
"--device", "virtio-rng")

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

startCmd = append(startCmd,
"--device", fmt.Sprintf("virtio-blk,path=%s", d.diskPath()))
Expand Down Expand Up @@ -516,6 +512,10 @@ func (d *Driver) publicSSHKeyPath() string {
return d.sshKeyPath() + ".pub"
}

func (d *Driver) isoPath() string {
return d.ResolveStorePath(isoFilename)
}

func (d *Driver) kernelPath() string {
return d.ResolveStorePath("bzimage")
}
Expand Down
Loading