Skip to content

Commit

Permalink
qemu: refactor maximum vcpus supported in aarch64
Browse files Browse the repository at this point in the history
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: kata-containers#584

Signed-off-by: Penny Zheng <[email protected]>
Signed-off-by: Wei Chen <[email protected]>
  • Loading branch information
Pennyzct committed Aug 27, 2018
1 parent cc29b8d commit a14cf06
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion virtcontainers/qemu_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,24 @@ 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 {
return uint32(runtime.NumCPU())
if hostGICVersion != 0 {
return gicList[hostGICVersion]
} else {
return uint32(runtime.NumCPU())
}
}

func newQemuArch(config HypervisorConfig) qemuArch {
Expand Down

0 comments on commit a14cf06

Please sign in to comment.