coreos/coreos-assembler

`--console-to-file` not working with `cosa run`

Closed this issue · 3 comments

When running command cosa run --qemu-iso rhcos-live.x86_64.iso --kargs fips=1 -m 8192 --console-to-file console.txt, but find console.txt is null.

According to @jlebon 's guidance:

i think that option is incompatible with --devshell (which is implied by cosa run). both want to own serial output, but the devshell code could be adapted to also append it to the file in that case (looks like QEMU doesn't support outputting to the different chardevs).

--devshell uses ssh by default, so I think we can detect the case where --console-to-file is passed and just not try to intercept the console. (Or really, change to doing tail -f on the file)

Thanks @cgwalters for the suggestion.

Review Character device options, create multiplexing mode chardev -chardev stdio,id=char0,mux=on,logfile=console.txt,signal=off -serial chardev:char0 -mon chardev=char0 , which can redirect the serial to both terminal and logfile=console.txt.

If we have both --devshell and --console-to-file, then can change like above, not sure if this will make side effect on the existed functional.

The command:

qemu-system-x86_64 -machine memory-backend=mem,accel=kvm \
-cpu host \
-object memory-backend-memfd,id=mem,size=4096M,share=on \
-m 4096 -smp 8 \
-object rng-random,filename=/dev/urandom,id=rng0 \
-device virtio-rng-pci,rng=rng0 -nographic -nodefaults \
-boot order=c,strict=on \
-device virtio-serial -device virtio-blk-pci,drive=d1,serial=primary-disk,bootindex=1 \
-drive if=none,id=d1,file=test.qcow2,auto-read-only=off,cache=unsafe \
-netdev user,id=eth0,hostfwd=tcp:127.0.0.1:43123-:22,hostname=cosa-devsh \
-device virtio-net-pci,netdev=eth0 -chardev socket,id=qemu-qmp,path=/var/tmp/mantle-qemutest/qmp-1694764666334470091.sock,server=on,wait=off\
 -mon chardev=qemu-qmp,mode=control \
-chardev stdio,id=char0,mux=on,logfile=console.txt,signal=off \
-serial chardev:char0 -mon chardev=char0

Note: remove related -add-fd and virtserialport device, which maybe less important.

create multiplexing mode chardev -chardev stdio,id=char0,mux=on,logfile=console.txt,signal=off -serial chardev:char0 -mon chardev=char0 , which can redirect the serial to both terminal and logfile=console.txt.

If we have both --devshell and --console-to-file, then can change like above.

Not working if integrated in cosa.