Skip to content

Commit 2851c65

Browse files
jlebonopenshift-merge-robot
authored andcommitted
kola/qemuexec: add --console-to-file
We want kola to be in control of what happens to the serial console. But `runvm` wants to redirect the console to a file. Add a flag to `qemuexec` to make that possible.
1 parent dbf3e60 commit 2851c65

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

mantle/cmd/kola/qemuexec.go

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ var (
6161

6262
devshell bool
6363
devshellConsole bool
64+
65+
consoleFile string
6466
)
6567

6668
func init() {
@@ -81,6 +83,7 @@ func init() {
8183
cmdQemuExec.Flags().StringArrayVar(&bindrw, "bind-rw", nil, "Same as above, but writable")
8284
cmdQemuExec.Flags().BoolVarP(&forceConfigInjection, "inject-ignition", "", false, "Force injecting Ignition config using guestfs")
8385
cmdQemuExec.Flags().BoolVar(&propagateInitramfsFailure, "propagate-initramfs-failure", false, "Error out if the system fails in the initramfs")
86+
cmdQemuExec.Flags().StringVarP(&consoleFile, "console-to-file", "", "", "Filepath in which to save serial console logs")
8487

8588
}
8689

@@ -114,6 +117,10 @@ func runQemuExec(cmd *cobra.Command, args []string) error {
114117

115118
if devshellConsole {
116119
devshell = true
120+
121+
if consoleFile != "" {
122+
return fmt.Errorf("Cannot use console devshell and --console-to-file")
123+
}
117124
}
118125
if devshell {
119126
if directIgnition {
@@ -244,6 +251,7 @@ func runQemuExec(cmd *cobra.Command, args []string) error {
244251
builder.EnableUsermodeNetworking(h)
245252
}
246253
builder.InheritConsole = true
254+
builder.ConsoleFile = consoleFile
247255
builder.Append(args...)
248256

249257
if devshell && !devshellConsole {

src/cmdlib.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ EOF
500500
echo "$@" > "${tmp_builddir}"/cmd.sh
501501

502502
touch "${runvm_console}"
503-
kola_args=(kola qemuexec -m 2048 --auto-cpus -U --workdir none)
503+
kola_args=(kola qemuexec -m 2048 --auto-cpus -U --workdir none \
504+
--console-to-file "${runvm_console}")
504505
base_qemu_args=(-drive 'if=none,id=root,format=raw,snapshot=on,file='"${vmbuilddir}"'/root,index=1' \
505506
-device 'virtio-blk,drive=root'
506507
-kernel "${vmbuilddir}/kernel" -initrd "${vmbuilddir}/initrd" \
@@ -518,7 +519,6 @@ EOF
518519

519520
if [ -z "${RUNVM_SHELL:-}" ]; then
520521
if ! "${kola_args[@]}" -- "${base_qemu_args[@]}" \
521-
-serial file:"${runvm_console}" \
522522
-device virtserialport,chardev=virtioserial0,name=cosa-cmdout \
523523
-chardev stdio,id=virtioserial0 \
524524
"${qemu_args[@]}" <&-; then # the <&- here closes stdin otherwise qemu waits forever

0 commit comments

Comments
 (0)