1

I currently am launching a RISC-V qemu session as follows:

/usr/bin/qemu-system-riscv64 -machine virt -m 4G -smp cpus=2 -nographic \
    -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin \
    -kernel /usr/lib/u-boot/qemu-riscv64_smode/u-boot.bin \
    -netdev user,id=net0 \
    -device virtio-net-device,netdev=net0 \
    -drive file=qemu_disk.bin,format=raw,if=virtio \
    -device virtio-rng-pci \
    -vga virtio \
    -no-reboot

The -vga virtio in particular was necessary to get it to use the full terminal width at boot time, as shown below: enter image description here

However, if I open an application like nano or gdb from within the qemu VM, it stops using the full width of the enclosing terminal window, as shown below: enter image description here

How can I tell QEMU to behave as if it has more space, so that applications like nano and gdb recognize this when launched?

(Note: I subsequently found I can install the "resize" tool, and manually run it, but I'm wondering if there's a way to just have qemu handle this automatically.)

3
  • In the terminal window what does stty -a | grep -oP 'columns \K\d+' return? What about echo $COLUMNS? Jul 28 at 18:42
  • The first screenshot shows only output from programs that don't attempt to use the terminal's characteristics, while the second shows an attempt -- and lack of underlying configuration information -- so you get the default 24x80. Jul 28 at 18:55
  • @roaima both commands show "80".
    – JRR
    Jul 28 at 22:57

1 Answer 1

4

Answering "why":

nano and gdb use the same information that stty shows, since that usually is good enough.

The first screenshot shows only output from programs that don't attempt to use the terminal's characteristics, while the second shows an attempt -- and lack of underlying configuration information -- so you get the default (looks like 25x80).

If you look closer, qemu doesn't own the console, and can't get good information. For instance, it might actually be connected via a pseudo terminal. That's easy to see in other programs. Here's an example where I'm using screen. The stty program gives the right size, but lets me pretend that it's a different size. That (in reverse) is what resize does: calculate the correct size using the terminal's escape sequences and update the settings used by stty.

example of stty ignored

If qemu doesn't have a workaround built-in, using resize (or something like it) is the solution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .