Merge pull request #21577 from jakecorrenti/get-default-devices-machineconfig

machine: change getDefaultDevices signature
This commit is contained in:
openshift-merge-bot[bot]
2024-02-09 16:59:04 +00:00
committed by GitHub
2 changed files with 20 additions and 21 deletions

View File

@ -141,21 +141,11 @@ func (a AppleHVStubber) StartVM(mc *vmconfigs.MachineConfig) (func() error, func
netDevice.SetUnixSocketPath(gvproxySocket.GetPath()) 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 // 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 // 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) 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 { if err != nil {
return nil, nil, err return nil, nil, err
} }

View File

@ -3,34 +3,43 @@
package applehv package applehv
import ( import (
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/vmconfigs" "github.com/containers/podman/v5/pkg/machine/vmconfigs"
vfConfig "github.com/crc-org/vfkit/pkg/config" vfConfig "github.com/crc-org/vfkit/pkg/config"
) )
// TODO this signature could be an machineconfig func getDefaultDevices(mc *vmconfigs.MachineConfig) ([]vfConfig.VirtioDevice, *define.VMFile, error) {
func getDefaultDevices(imagePath, logPath, readyPath string) ([]vfConfig.VirtioDevice, error) {
var devices []vfConfig.VirtioDevice var devices []vfConfig.VirtioDevice
disk, err := vfConfig.VirtioBlkNew(imagePath) disk, err := vfConfig.VirtioBlkNew(mc.ImagePath.GetPath())
if err != nil { if err != nil {
return nil, err return nil, nil, err
} }
rng, err := vfConfig.VirtioRngNew() rng, err := vfConfig.VirtioRngNew()
if err != nil { if err != nil {
return nil, err return nil, nil, err
} }
serial, err := vfConfig.VirtioSerialNew(logPath) logfile, err := mc.LogFile()
if err != nil { 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 { 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) devices = append(devices, disk, rng, serial, readyDevice)
return devices, nil return devices, readySocket, nil
} }
func getDebugDevices() ([]vfConfig.VirtioDevice, error) { func getDebugDevices() ([]vfConfig.VirtioDevice, error) {