govmm: Define the number of supported vCPUs per architecture

Based on qhe QEMU supports on those architectures.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
This commit is contained in:
Samuel Ortiz 2022-02-08 21:25:08 +00:00
parent 77c29bfd3b
commit a5f6df6a49
4 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,12 @@
//
// Copyright (c) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package govmm
// MaxVCPUs returns the maximum number of vCPUs supported
func MaxVCPUs() uint32 {
return uint32(240)
}

View File

@ -0,0 +1,25 @@
//
// Copyright (c) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package govmm
//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),
}
var defaultGICVersion = uint32(3)
// MaxVCPUs returns the maximum number of vCPUs supported
func MaxVCPUs() uint32 {
return gicList[defaultGICVersion]
}

View File

@ -0,0 +1,12 @@
//
// Copyright (c) 2018 IBM
//
// SPDX-License-Identifier: Apache-2.0
//
package qemu
// MaxVCPUs returns the maximum number of vCPUs supported
func MaxVCPUs() uint32 {
return uint32(128)
}

View File

@ -0,0 +1,15 @@
//
// Copyright (c) 2018 IBM
//
// SPDX-License-Identifier: Apache-2.0
//
package govmm
// MaxVCPUs returns the maximum number of vCPUs supported
func MaxVCPUs() uint32 {
// Max number of virtual Cpu defined in qemu. See
// https://github.com/qemu/qemu/blob/80422b00196a7af4c6efb628fae0ad8b644e98af/target/s390x/cpu.h#L55
// #define S390_MAX_CPUS 248
return uint32(248)
}