Skip to content

Commit

Permalink
machine: change getDefaultDevices signature
Browse files Browse the repository at this point in the history
Changes the signature for `getDefaultDevices` to take
a `vmconfigs.MachineConfig`.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <[email protected]>
  • Loading branch information
jakecorrenti committed Feb 9, 2024
1 parent 5311233 commit 02eb907
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
12 changes: 1 addition & 11 deletions pkg/machine/applehv/stubber.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,11 @@ func (a AppleHVStubber) StartVM(mc *vmconfigs.MachineConfig) (func() error, func

netDevice.SetUnixSocketPath(gvproxySocket.GetPath())

readySocket, err := mc.ReadySocket()
if err != nil {
return nil, nil, err
}

logfile, err := mc.LogFile()
if err != nil {
return nil, nil, err
}

// create a one-time virtual machine for starting because we dont want all this information in the
// machineconfig if possible. the preference was to derive this stuff
vm := vfConfig.NewVirtualMachine(uint(mc.Resources.CPUs), mc.Resources.Memory, mc.AppleHypervisor.Vfkit.VirtualMachine.Bootloader)

defaultDevices, err := getDefaultDevices(mc.ImagePath.GetPath(), logfile.GetPath(), readySocket.GetPath())
defaultDevices, readySocket, err := getDefaultDevices(mc)
if err != nil {
return nil, nil, err
}
Expand Down
29 changes: 19 additions & 10 deletions pkg/machine/applehv/vfkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,43 @@
package applehv

import (
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
vfConfig "github.com/crc-org/vfkit/pkg/config"
)

// TODO this signature could be an machineconfig
func getDefaultDevices(imagePath, logPath, readyPath string) ([]vfConfig.VirtioDevice, error) {
func getDefaultDevices(mc *vmconfigs.MachineConfig) ([]vfConfig.VirtioDevice, *define.VMFile, error) {
var devices []vfConfig.VirtioDevice

disk, err := vfConfig.VirtioBlkNew(imagePath)
disk, err := vfConfig.VirtioBlkNew(mc.ImagePath.GetPath())
if err != nil {
return nil, err
return nil, nil, err
}
rng, err := vfConfig.VirtioRngNew()
if err != nil {
return nil, err
return nil, nil, err
}

serial, err := vfConfig.VirtioSerialNew(logPath)
logfile, err := mc.LogFile()
if err != nil {
return nil, err
return nil, nil, err
}
serial, err := vfConfig.VirtioSerialNew(logfile.GetPath())
if err != nil {
return nil, nil, err
}

readyDevice, err := vfConfig.VirtioVsockNew(1025, readyPath, true)
readySocket, err := mc.ReadySocket()
if err != nil {
return nil, err
return nil, nil, err
}

readyDevice, err := vfConfig.VirtioVsockNew(1025, readySocket.GetPath(), true)
if err != nil {
return nil, nil, err
}
devices = append(devices, disk, rng, serial, readyDevice)
return devices, nil
return devices, readySocket, nil
}

func getDebugDevices() ([]vfConfig.VirtioDevice, error) {
Expand Down

0 comments on commit 02eb907

Please sign in to comment.