diff --git a/src/runtime/cli/config/configuration-fc.toml.in b/src/runtime/cli/config/configuration-fc.toml.in index 054950d2a9..4e5158f5b2 100644 --- a/src/runtime/cli/config/configuration-fc.toml.in +++ b/src/runtime/cli/config/configuration-fc.toml.in @@ -55,6 +55,7 @@ default_vcpus = 1 # `default_maxvcpus = 8` the memory footprint will be small, but 8 will be the maximum number of # vCPUs supported by the SB/VM. In general, we recommend that you do not edit this variable, # unless you know what are you doing. +# NOTICE: on arm platform with gicv2 interrupt controller, set it to 8. default_maxvcpus = @DEFMAXVCPUS@ # Bridges can be used to hot plug devices. diff --git a/src/runtime/cli/config/configuration-qemu-virtiofs.toml.in b/src/runtime/cli/config/configuration-qemu-virtiofs.toml.in index 129dc9963d..8a220feaae 100644 --- a/src/runtime/cli/config/configuration-qemu-virtiofs.toml.in +++ b/src/runtime/cli/config/configuration-qemu-virtiofs.toml.in @@ -58,6 +58,7 @@ default_vcpus = 1 # `default_maxvcpus = 8` the memory footprint will be small, but 8 will be the maximum number of # vCPUs supported by the SB/VM. In general, we recommend that you do not edit this variable, # unless you know what are you doing. +# NOTICE: on arm platform with gicv2 interrupt controller, set it to 8. default_maxvcpus = @DEFMAXVCPUS@ # Bridges can be used to hot plug devices. diff --git a/src/runtime/cli/config/configuration-qemu.toml.in b/src/runtime/cli/config/configuration-qemu.toml.in index bca733e2ad..7ac6d90988 100644 --- a/src/runtime/cli/config/configuration-qemu.toml.in +++ b/src/runtime/cli/config/configuration-qemu.toml.in @@ -59,6 +59,7 @@ default_vcpus = 1 # `default_maxvcpus = 8` the memory footprint will be small, but 8 will be the maximum number of # vCPUs supported by the SB/VM. In general, we recommend that you do not edit this variable, # unless you know what are you doing. +# NOTICE: on arm platform with gicv2 interrupt controller, set it to 8. default_maxvcpus = @DEFMAXVCPUS@ # Bridges can be used to hot plug devices. diff --git a/src/runtime/virtcontainers/qemu_arm64.go b/src/runtime/virtcontainers/qemu_arm64.go index ed38457711..5b1ca82ce2 100644 --- a/src/runtime/virtcontainers/qemu_arm64.go +++ b/src/runtime/virtcontainers/qemu_arm64.go @@ -8,7 +8,6 @@ package virtcontainers import ( "context" "fmt" - "runtime" "time" govmmQemu "github.com/intel/govmm/qemu" @@ -27,6 +26,8 @@ const qmpMigrationWaitTimeout = 10 * time.Second const defaultQemuMachineOptions = "usb=off,accel=kvm,gic-version=host" +var defaultGICVersion = uint32(3) + var kernelParams = []Param{ {"console", "hvc0"}, {"console", "hvc1"}, @@ -51,7 +52,7 @@ var gicList = map[uint32]uint32{ // MaxQemuVCPUs returns the maximum number of vCPUs supported func MaxQemuVCPUs() uint32 { - return uint32(runtime.NumCPU()) + return gicList[defaultGICVersion] } func newQemuArch(config HypervisorConfig) (qemuArch, error) { diff --git a/src/runtime/virtcontainers/qemu_arm64_test.go b/src/runtime/virtcontainers/qemu_arm64_test.go index eeb6c2ed67..95bffacc26 100644 --- a/src/runtime/virtcontainers/qemu_arm64_test.go +++ b/src/runtime/virtcontainers/qemu_arm64_test.go @@ -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) {