From c4ded6ee5e48ff911be83229c2885a5ab7a3b1d7 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 27 Aug 2018 13:55:24 +0800 Subject: [PATCH] qemu: refactor maximum vcpus supported in aarch64 on aarch64, we support different gic interrupt controllers. The maximum number of vCPUs depends on the GIC version, or on how many redistributors we can fit into the memory map. Fixes: #584 Signed-off-by: Penny Zheng Signed-off-by: Wei Chen --- virtcontainers/qemu_arm64.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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()) }