diff --git a/virtcontainers/qemu_arm64.go b/virtcontainers/qemu_arm64.go index 112631b09b..9385a533b5 100644 --- a/virtcontainers/qemu_arm64.go +++ b/virtcontainers/qemu_arm64.go @@ -107,8 +107,22 @@ func getGuestGICVersion() (version string) { return "host" } +//In qemu, maximum number of vCPUs depends on the GIC version, or on how +//many redistributors we can fit into the memory map. +//related codes are under github.com/qemu/qemu/hw/arm/virt.c(Line 135 and 1306 in stable-2.11) +//for now, qemu only supports v2 and v3, we treat v4 as v3 based on +//backward compatibility. +var gicList = map[uint32]uint32{ + uint32(2): uint32(8), + uint32(3): uint32(123), + uint32(4): uint32(123), +} + // MaxQemuVCPUs returns the maximum number of vCPUs supported func MaxQemuVCPUs() uint32 { + if hostGICVersion != 0 { + return gicList[hostGICVersion] + } return uint32(runtime.NumCPU()) }