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 29, 2018
1 parent a303892 commit adbfd15
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions virtcontainers/qemu_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down

0 comments on commit adbfd15

Please sign in to comment.