qemu: treat console kernel params within appendConsole

as it is tightly coupled with the appended console device
additionally have it tested

Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
This commit is contained in:
Snir Sheriber 2022-05-10 19:36:25 +03:00
parent 51fa4ab671
commit 44814dce19
7 changed files with 19 additions and 16 deletions

View File

@ -552,13 +552,6 @@ func (q *qemu) CreateVM(ctx context.Context, id string, network Network, hypervi
return err
}
// Breaks hypervisor abstration Has Kata Specific logic
kernel := govmmQemu.Kernel{
Path: kernelPath,
InitrdPath: initrdPath,
Params: q.kernelParameters(),
}
incoming := q.setupTemplate(&knobs, &memory)
// With the current implementations, VM templating will not work with file
@ -630,6 +623,14 @@ func (q *qemu) CreateVM(ctx context.Context, id string, network Network, hypervi
return err
}
// Breaks hypervisor abstraction has Kata Specific logic
kernel := govmmQemu.Kernel{
Path: kernelPath,
InitrdPath: initrdPath,
// some devices configuration may also change kernel params, make sure this is called afterwards
Params: q.kernelParameters(),
}
qemuConfig := govmmQemu.Config{
Name: fmt.Sprintf("sandbox-%s", q.id),
UUID: q.state.UUID,

View File

@ -56,8 +56,6 @@ var kernelParams = []Param{
{"i8042.noaux", "1"},
{"noreplace-smp", ""},
{"reboot", "k"},
{"console", "hvc0"},
{"console", "hvc1"},
{"cryptomgr.notests", ""},
{"net.ifnames", "0"},
{"pci", "lastbus=0"},

View File

@ -337,6 +337,12 @@ func (q *qemuArchBase) appendConsole(_ context.Context, devices []govmmQemu.Devi
devices = append(devices, console)
consoleKernelParams := []Param{
{"console", "hvc0"},
{"console", "hvc1"},
}
q.kernelParams = append(q.kernelParams, consoleKernelParams...)
return devices, nil
}

View File

@ -259,6 +259,8 @@ func TestQemuArchBaseAppendConsoles(t *testing.T) {
devices, err = qemuArchBase.appendConsole(context.Background(), devices, path)
assert.NoError(err)
assert.Equal(expectedOut, devices)
assert.Contains(qemuArchBase.kernelParams, Param{"console", "hvc0"})
assert.Contains(qemuArchBase.kernelParams, Param{"console", "hvc1"})
}
func TestQemuArchBaseAppendImage(t *testing.T) {

View File

@ -33,8 +33,6 @@ const qmpMigrationWaitTimeout = 10 * time.Second
const defaultQemuMachineOptions = "usb=off,accel=kvm,gic-version=host"
var kernelParams = []Param{
{"console", "hvc0"},
{"console", "hvc1"},
{"iommu.passthrough", "0"},
}

View File

@ -41,8 +41,6 @@ const tpmHostPath = "/dev/tpmrm0"
var kernelParams = []Param{
{"rcupdate.rcu_expedited", "1"},
{"reboot", "k"},
{"console", "hvc0"},
{"console", "hvc1"},
{"cryptomgr.notests", ""},
{"net.ifnames", "0"},
}

View File

@ -39,9 +39,7 @@ const (
)
// Verify needed parameters
var kernelParams = []Param{
{"console", "ttysclp0"},
}
var kernelParams = []Param{}
var ccwbridge = types.NewBridge(types.CCW, "", make(map[uint32]string, types.CCWBridgeMaxCapacity), 0)
@ -112,6 +110,8 @@ func (q *qemuS390x) appendConsole(ctx context.Context, devices []govmmQemu.Devic
return devices, fmt.Errorf("Failed to append console %v", err)
}
q.kernelParams = append(q.kernelParams, Param{"console", "ttysclp0"})
serial := govmmQemu.SerialDevice{
Driver: virtioSerialCCW,
ID: id,