mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-15 06:34:03 +00:00
qemu: append kernel root parameters iff root image is provided
For initrd based boot, we do not need the root parameters. Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
parent
21343d7d71
commit
463e6dee0b
@ -175,7 +175,7 @@ func (q *qemu) init(pod *Pod) error {
|
||||
|
||||
q.config = pod.config.HypervisorConfig
|
||||
q.pod = pod
|
||||
q.arch = newQemuArch(q.config.HypervisorMachineType)
|
||||
q.arch = newQemuArch(q.config)
|
||||
|
||||
if err = pod.storage.fetchHypervisorState(pod.id, &q.state); err != nil {
|
||||
q.Logger().Debug("Creating bridges")
|
||||
|
@ -42,10 +42,13 @@ var qemuPaths = map[string]string{
|
||||
QemuQ35: defaultQemuPath,
|
||||
}
|
||||
|
||||
var kernelParams = []Param{
|
||||
var kernelRootParams = []Param{
|
||||
{"root", "/dev/pmem0p1"},
|
||||
{"rootflags", "dax,data=ordered,errors=remount-ro rw"},
|
||||
{"rootfstype", "ext4"},
|
||||
}
|
||||
|
||||
var kernelParams = []Param{
|
||||
{"tsc", "reliable"},
|
||||
{"no_timer_check", ""},
|
||||
{"rcupdate.rcu_expedited", "1"},
|
||||
@ -83,12 +86,13 @@ func maxQemuVCPUs() uint32 {
|
||||
return uint32(240)
|
||||
}
|
||||
|
||||
func newQemuArch(machineType string) qemuArch {
|
||||
func newQemuArch(config HypervisorConfig) qemuArch {
|
||||
machineType := config.HypervisorMachineType
|
||||
if machineType == "" {
|
||||
machineType = defaultQemuMachineType
|
||||
}
|
||||
|
||||
return &qemuAmd64{
|
||||
q := &qemuAmd64{
|
||||
qemuArchBase{
|
||||
machineType: machineType,
|
||||
qemuPaths: qemuPaths,
|
||||
@ -98,6 +102,12 @@ func newQemuArch(machineType string) qemuArch {
|
||||
kernelParams: kernelParams,
|
||||
},
|
||||
}
|
||||
|
||||
if config.ImagePath != "" {
|
||||
q.kernelParams = append(q.kernelParams, kernelRootParams...)
|
||||
}
|
||||
|
||||
return q
|
||||
}
|
||||
|
||||
func (q *qemuAmd64) capabilities() capabilities {
|
||||
|
@ -26,21 +26,28 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func newTestQemu(machineType string) qemuArch {
|
||||
config := HypervisorConfig{
|
||||
HypervisorMachineType: machineType,
|
||||
}
|
||||
return newQemuArch(config)
|
||||
}
|
||||
|
||||
func TestQemuAmd64Capabilities(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
amd64 := newQemuArch(QemuPC)
|
||||
amd64 := newTestQemu(QemuPC)
|
||||
caps := amd64.capabilities()
|
||||
assert.True(caps.isBlockDeviceHotplugSupported())
|
||||
|
||||
amd64 = newQemuArch(QemuQ35)
|
||||
amd64 = newTestQemu(QemuQ35)
|
||||
caps = amd64.capabilities()
|
||||
assert.False(caps.isBlockDeviceHotplugSupported())
|
||||
}
|
||||
|
||||
func TestQemuAmd64Bridges(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
amd64 := newQemuArch(QemuPC)
|
||||
amd64 := newTestQemu(QemuPC)
|
||||
len := 5
|
||||
|
||||
bridges := amd64.bridges(uint32(len))
|
||||
@ -53,7 +60,7 @@ func TestQemuAmd64Bridges(t *testing.T) {
|
||||
assert.NotNil(b.Address)
|
||||
}
|
||||
|
||||
amd64 = newQemuArch(QemuQ35)
|
||||
amd64 = newTestQemu(QemuQ35)
|
||||
bridges = amd64.bridges(uint32(len))
|
||||
assert.Len(bridges, len)
|
||||
|
||||
@ -64,14 +71,14 @@ func TestQemuAmd64Bridges(t *testing.T) {
|
||||
assert.NotNil(b.Address)
|
||||
}
|
||||
|
||||
amd64 = newQemuArch(QemuQ35 + QemuPC)
|
||||
amd64 = newTestQemu(QemuQ35 + QemuPC)
|
||||
bridges = amd64.bridges(uint32(len))
|
||||
assert.Nil(bridges)
|
||||
}
|
||||
|
||||
func TestQemuAmd64CPUModel(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
amd64 := newQemuArch(QemuPC)
|
||||
amd64 := newTestQemu(QemuPC)
|
||||
|
||||
expectedOut := defaultCPUModel
|
||||
model := amd64.cpuModel()
|
||||
@ -85,7 +92,7 @@ func TestQemuAmd64CPUModel(t *testing.T) {
|
||||
|
||||
func TestQemuAmd64MemoryTopology(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
amd64 := newQemuArch(QemuPC)
|
||||
amd64 := newTestQemu(QemuPC)
|
||||
memoryOffset := 1024
|
||||
|
||||
hostMem := uint64(100)
|
||||
@ -103,7 +110,7 @@ func TestQemuAmd64MemoryTopology(t *testing.T) {
|
||||
func TestQemuAmd64AppendImage(t *testing.T) {
|
||||
var devices []govmmQemu.Device
|
||||
assert := assert.New(t)
|
||||
amd64 := newQemuArch(QemuPC)
|
||||
amd64 := newTestQemu(QemuPC)
|
||||
|
||||
f, err := ioutil.TempFile("", "img")
|
||||
assert.NoError(err)
|
||||
@ -135,7 +142,7 @@ func TestQemuAmd64AppendBridges(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
// check PC
|
||||
amd64 := newQemuArch(QemuPC)
|
||||
amd64 := newTestQemu(QemuPC)
|
||||
|
||||
bridges := amd64.bridges(1)
|
||||
assert.Len(bridges, 1)
|
||||
@ -156,7 +163,7 @@ func TestQemuAmd64AppendBridges(t *testing.T) {
|
||||
assert.Equal(expectedOut, devices)
|
||||
|
||||
// Check Q35
|
||||
amd64 = newQemuArch(QemuQ35)
|
||||
amd64 = newTestQemu(QemuQ35)
|
||||
|
||||
bridges = amd64.bridges(1)
|
||||
assert.Len(bridges, 1)
|
||||
|
@ -38,11 +38,14 @@ var qemuPaths = map[string]string{
|
||||
}
|
||||
|
||||
var kernelParams = []Param{
|
||||
{"root", "/dev/vda1"},
|
||||
{"console", "ttyAMA0"},
|
||||
{"iommu.passthrough", "0"},
|
||||
}
|
||||
|
||||
var kernelRootParams = []Param{
|
||||
{"root", "/dev/vda1"},
|
||||
}
|
||||
|
||||
var supportedQemuMachines = []govmmQemu.Machine{
|
||||
{
|
||||
Type: QemuVirt,
|
||||
@ -55,12 +58,13 @@ func maxQemuVCPUs() uint32 {
|
||||
return uint32(runtime.NumCPU())
|
||||
}
|
||||
|
||||
func newQemuArch(machineType string) qemuArch {
|
||||
func newQemuArch(config HypervisrConfig) qemuArch {
|
||||
machineType := config.HypervisorMachineType
|
||||
if machineType == "" {
|
||||
machineType = defaultQemuMachineType
|
||||
}
|
||||
|
||||
return &qemuArm64{
|
||||
q := &qemuArm64{
|
||||
qemuArchBase{
|
||||
machineType: machineType,
|
||||
qemuPaths: qemuPaths,
|
||||
@ -70,4 +74,10 @@ func newQemuArch(machineType string) qemuArch {
|
||||
kernelParams: kernelParams,
|
||||
},
|
||||
}
|
||||
|
||||
if config.ImagePath != "" {
|
||||
q.kernelParams = append(q.kernelParams, kernelRootParams...)
|
||||
}
|
||||
|
||||
return q
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user