mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 16:27:50 +00: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:
parent
93d1f7b4e3
commit
6e7dd435a2
@ -55,6 +55,7 @@ default_vcpus = 1
|
|||||||
# `default_maxvcpus = 8` the memory footprint will be small, but 8 will be the maximum number of
|
# `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,
|
# vCPUs supported by the SB/VM. In general, we recommend that you do not edit this variable,
|
||||||
# unless you know what are you doing.
|
# unless you know what are you doing.
|
||||||
|
# NOTICE: on arm platform with gicv2 interrupt controller, set it to 8.
|
||||||
default_maxvcpus = @DEFMAXVCPUS@
|
default_maxvcpus = @DEFMAXVCPUS@
|
||||||
|
|
||||||
# Bridges can be used to hot plug devices.
|
# Bridges can be used to hot plug devices.
|
||||||
|
@ -58,6 +58,7 @@ default_vcpus = 1
|
|||||||
# `default_maxvcpus = 8` the memory footprint will be small, but 8 will be the maximum number of
|
# `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,
|
# vCPUs supported by the SB/VM. In general, we recommend that you do not edit this variable,
|
||||||
# unless you know what are you doing.
|
# unless you know what are you doing.
|
||||||
|
# NOTICE: on arm platform with gicv2 interrupt controller, set it to 8.
|
||||||
default_maxvcpus = @DEFMAXVCPUS@
|
default_maxvcpus = @DEFMAXVCPUS@
|
||||||
|
|
||||||
# Bridges can be used to hot plug devices.
|
# Bridges can be used to hot plug devices.
|
||||||
|
@ -59,6 +59,7 @@ default_vcpus = 1
|
|||||||
# `default_maxvcpus = 8` the memory footprint will be small, but 8 will be the maximum number of
|
# `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,
|
# vCPUs supported by the SB/VM. In general, we recommend that you do not edit this variable,
|
||||||
# unless you know what are you doing.
|
# unless you know what are you doing.
|
||||||
|
# NOTICE: on arm platform with gicv2 interrupt controller, set it to 8.
|
||||||
default_maxvcpus = @DEFMAXVCPUS@
|
default_maxvcpus = @DEFMAXVCPUS@
|
||||||
|
|
||||||
# Bridges can be used to hot plug devices.
|
# Bridges can be used to hot plug devices.
|
||||||
|
@ -8,7 +8,6 @@ package virtcontainers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
govmmQemu "github.com/intel/govmm/qemu"
|
govmmQemu "github.com/intel/govmm/qemu"
|
||||||
@ -27,6 +26,8 @@ const qmpMigrationWaitTimeout = 10 * time.Second
|
|||||||
|
|
||||||
const defaultQemuMachineOptions = "usb=off,accel=kvm,gic-version=host"
|
const defaultQemuMachineOptions = "usb=off,accel=kvm,gic-version=host"
|
||||||
|
|
||||||
|
var defaultGICVersion = uint32(3)
|
||||||
|
|
||||||
var kernelParams = []Param{
|
var kernelParams = []Param{
|
||||||
{"console", "hvc0"},
|
{"console", "hvc0"},
|
||||||
{"console", "hvc1"},
|
{"console", "hvc1"},
|
||||||
@ -51,7 +52,7 @@ var gicList = map[uint32]uint32{
|
|||||||
|
|
||||||
// MaxQemuVCPUs returns the maximum number of vCPUs supported
|
// MaxQemuVCPUs returns the maximum number of vCPUs supported
|
||||||
func MaxQemuVCPUs() uint32 {
|
func MaxQemuVCPUs() uint32 {
|
||||||
return uint32(runtime.NumCPU())
|
return gicList[defaultGICVersion]
|
||||||
}
|
}
|
||||||
|
|
||||||
func newQemuArch(config HypervisorConfig) (qemuArch, error) {
|
func newQemuArch(config HypervisorConfig) (qemuArch, error) {
|
||||||
|
@ -9,8 +9,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
govmmQemu "github.com/intel/govmm/qemu"
|
govmmQemu "github.com/intel/govmm/qemu"
|
||||||
@ -59,50 +57,8 @@ func TestQemuArm64MemoryTopology(t *testing.T) {
|
|||||||
func TestMaxQemuVCPUs(t *testing.T) {
|
func TestMaxQemuVCPUs(t *testing.T) {
|
||||||
assert := assert.New(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()
|
vCPUs := MaxQemuVCPUs()
|
||||||
|
assert.Equal(uint32(123), vCPUs)
|
||||||
assert.Equal(d.expectedResult, vCPUs)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQemuArm64AppendBridges(t *testing.T) {
|
func TestQemuArm64AppendBridges(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user