Check AppleHypervisor before accessing it

In GetDefaultDevices(), make sure MachineConfig has an AppleHypervisor
instance before attempting to access it. This fixes a SIGSEGV when
running with libkrun as machine provider.

Signed-off-by: Sergio Lopez <slp@redhat.com>
This commit is contained in:
Sergio Lopez
2024-05-20 16:17:59 +02:00
parent f7bd15d527
commit 3ab9e864f6

View File

@ -43,8 +43,7 @@ func GetDefaultDevices(mc *vmconfigs.MachineConfig) ([]vfConfig.VirtioDevice, *d
}
devices = append(devices, disk, rng, serial, readyDevice)
rosettaCfg := mc.AppleHypervisor.Vfkit.Rosetta
if rosettaCfg {
if mc.AppleHypervisor != nil && mc.AppleHypervisor.Vfkit.Rosetta {
rosetta := &vfConfig.RosettaShare{
DirectorySharingConfig: vfConfig.DirectorySharingConfig{
MountTag: define.MountTag,