qemu: allow using legacy serial device for the console

This allows to get guest early boot logs which are usually
missed when virtconsole is used.
- It utilizes previous work on the govmm side:
https://github.com/kata-containers/govmm/pull/203
- unit test added

Fixes: #4237
Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
This commit is contained in:
Snir Sheriber
2022-05-12 14:26:51 +03:00
parent 44814dce19
commit c67b9d2975
10 changed files with 82 additions and 19 deletions

View File

@@ -263,6 +263,34 @@ func TestQemuArchBaseAppendConsoles(t *testing.T) {
assert.Contains(qemuArchBase.kernelParams, Param{"console", "hvc1"})
}
func TestQemuArchBaseAppendConsolesLegacy(t *testing.T) {
var devices []govmmQemu.Device
var err error
assert := assert.New(t)
qemuArchBase := newQemuArchBase()
qemuArchBase.legacySerial = true
path := filepath.Join(filepath.Join(fs.MockRunStoragePath(), "test"), consoleSocket)
expectedOut := []govmmQemu.Device{
govmmQemu.LegacySerialDevice{
Chardev: "charconsole0",
},
govmmQemu.CharDevice{
Driver: govmmQemu.LegacySerial,
Backend: govmmQemu.Socket,
DeviceID: "console0",
ID: "charconsole0",
Path: path,
},
}
devices, err = qemuArchBase.appendConsole(context.Background(), devices, path)
assert.NoError(err)
assert.Equal(expectedOut, devices)
assert.Contains(qemuArchBase.kernelParams, Param{"console", "ttyS0"})
}
func TestQemuArchBaseAppendImage(t *testing.T) {
var devices []govmmQemu.Device
assert := assert.New(t)