Skip to content

Commit

Permalink
Check AppleHypervisor before accessing it
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
slp committed May 20, 2024
1 parent f7bd15d commit 3ab9e86
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/machine/apple/vfkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3ab9e86

Please sign in to comment.