mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-19 07:14:22 +01:00
qemu: arm64: Set defaultGICVersion to 3 to limit the max vCPU number
[ port from runtime commit ee985a608015d81772901c1d9999190495fc9a0a ]
After removing dectect of host gic version, we need to limit the max vCPU
in different cases.
Given that in most cases, Kata is running on gicv3 host, set it as default
value. If the user really want to run Kata on gicv2 host, he/she need to
set default_maxvcpus in toml file to 8 instead of 0.
In summary, If the user uses host gicv3 gicv4, everything is fine
If the user uses host gicv2, set default_maxvcpus=8
Signed-off-by: Jia He <justin.he@arm.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
@@ -9,8 +9,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
govmmQemu "github.com/intel/govmm/qemu"
|
||||
@@ -59,50 +57,8 @@ func TestQemuArm64MemoryTopology(t *testing.T) {
|
||||
func TestMaxQemuVCPUs(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
type testData struct {
|
||||
contents string
|
||||
expectedResult uint32
|
||||
}
|
||||
|
||||
data := []testData{
|
||||
{"", uint32(runtime.NumCPU())},
|
||||
{" 1: 0 0 GICv2 25 Level vgic \n", uint32(8)},
|
||||
{" 1: 0 0 GICv3 25 Level vgic \n", uint32(123)},
|
||||
{" 1: 0 0 GICv4 25 Level vgic \n", uint32(123)},
|
||||
}
|
||||
|
||||
tmpdir, err := ioutil.TempDir("", "")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
savedGicProfile := gicProfile
|
||||
|
||||
testGicProfile := filepath.Join(tmpdir, "interrupts")
|
||||
|
||||
// override
|
||||
gicProfile = testGicProfile
|
||||
|
||||
defer func() {
|
||||
gicProfile = savedGicProfile
|
||||
}()
|
||||
|
||||
savedHostGICVersion := hostGICVersion
|
||||
|
||||
defer func() {
|
||||
hostGICVersion = savedHostGICVersion
|
||||
}()
|
||||
|
||||
for _, d := range data {
|
||||
err := ioutil.WriteFile(gicProfile, []byte(d.contents), os.FileMode(0640))
|
||||
assert.NoError(err)
|
||||
|
||||
hostGICVersion = getHostGICVersion()
|
||||
vCPUs := MaxQemuVCPUs()
|
||||
|
||||
assert.Equal(d.expectedResult, vCPUs)
|
||||
}
|
||||
vCPUs := MaxQemuVCPUs()
|
||||
assert.Equal(uint32(123), vCPUs)
|
||||
}
|
||||
|
||||
func TestQemuArm64AppendBridges(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user