From d79b94c82bc457abb4dfa4c459d025b6cc643522 Mon Sep 17 00:00:00 2001 From: Sergio Lopez Date: Mon, 20 May 2024 16:17:59 +0200 Subject: [PATCH] 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 --- pkg/machine/apple/vfkit.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/machine/apple/vfkit.go b/pkg/machine/apple/vfkit.go index 05a44e3515a2..636944146681 100644 --- a/pkg/machine/apple/vfkit.go +++ b/pkg/machine/apple/vfkit.go @@ -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,