Skip to contentSkip to conversation

handling SIGWINCH with qemu -nographic

Qemu-devel Jeff Carr 5 participants 8 messages Oct 16, 2007 – Oct 20, 2007

lore
Share & tools
lore

Jeff Carr

author
#0 lore raw

Has anyone looked into finding a way to pass SIGWINCH through to the guest? I started looking at linux-user/signal.c.

For those that might not be familiar with SIGWINCH, supporting it would allow qemu -nographic to tell when the terminal is a different size than 80x24.

#1 lore raw
Quoted 6 lines · Jeff Carr

Has anyone looked into finding a way to pass SIGWINCH through to the guest? I started looking at linux-user/signal.c.

For those that might not be familiar with SIGWINCH, supporting it would allow qemu -nographic to tell when the terminal is a different size than 80x24.

qemu emulates a real machine. Signals are an operating system concept, so your question makes no sense. Configure your guest OS exactly the same way you would a real machine with a serial console.

The linux-user code is for the userspace emulation. You're obviously using the full system emulation.

Paul

author
#2 lore raw
Quoted 3 lines · Paul Brook

qemu emulates a real machine. Signals are an operating system concept, so your question makes no sense. Configure your guest OS exactly the same way you would a real machine with a serial console.

OK. I thought there might be a way.

Quoted 2 lines

The linux-user code is for the userspace emulation. You're obviously using the full system emulation.

It seemed that's where the handler would have to go. I don't know if there is some way to pass that through a serial device. I wasn't sure if it would require some custom qemu serial driver for the guest.

#3 lore raw
Quoted 9 lines · Jeff Carr
Quoted 5 lines · Paul Brook

qemu emulates a real machine. Signals are an operating system concept, so your
question makes no sense. Configure your guest OS exactly the same way you
would a real machine with a serial console.

OK. I thought there might be a way.

I think your question is quite reasonable. Imagine a Linux host running X Windows and a terminal like xterm or kconsole. Then run a program like "top" or "less" in this terminal. When a user changes the size of the console window, top, less and other console applications get notified of this change by SIGWINCH.

Now run a similar program using QEMU's user mode emulation. Why should it not be possible to get SIGWINCH in QEMU and pass it on to the program in user mode emulation, so it can behave like a native Linux application and change its appearance?

I don't think that implementing this is very difficult, so it will be done.

Regards
Stefan

#4 lore raw
Quoted 6 lines

I think your question is quite reasonable. Imagine a Linux host running X Windows and a terminal like xterm or kconsole. Then run a program like "top" or "less" in this terminal. When a user changes the size of the console window, top, less and other console applications get notified of this change by SIGWINCH.

Quoted 7 lines

Now run a similar program using QEMU's user mode emulation. Why should it not be possible to get SIGWINCH in QEMU and pass it on to the program in user mode emulation, so it can behave like a native Linux application and change its appearance?

I don't think that implementing this is very difficult, so it will be done.

Try doing the same thing with a real machine connected via a serial port. It won't work.

The difference is that for local applications (and remote terminals via telnet or ssh) you have OOB mechanisms to transmit event data (e.g. terminal size). A UART only gives you a simple serial connection. If you want things like terminal resizing to work you need to run some more complicated protocol over the serial link, with appropriate tty emulation on either end.

Paul

#5 lore raw
In reply to Stefan Weil
Quoted 8 lines · Stefan Weil
Quoted 7 lines · Jeff Carr
Quoted 5 lines · Paul Brook

qemu emulates a real machine. Signals are an operating system concept, so your
question makes no sense. Configure your guest OS exactly the same way you
would a real machine with a serial console.

Quoted 4 lines
Quoted 1 line

OK. I thought there might be a way.

I think your question is quite reasonable. Imagine a Linux host running X Windows and a terminal like xterm or kconsole.

This is why ssh was invented. That passes through terminal information just fine. QEMU does have a virtual network...

Quoted 3 lines

Then run a program like "top" or "less" in this terminal. When a user changes the size of the console window, top, less and other console applications get notified of this change by SIGWINCH.

You can also set the environment variables COLUMNS and LINES to the appropriate values. Most things will parse that and use it if the tty info isn't available.

Rob

Signature · 2 lines
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.
#6 lore raw
In reply to Jeff Carr
Quoted 3 lines · Jeff Carr

For those that might not be familiar with SIGWINCH, supporting it would allow qemu -nographic to tell when the terminal is a different size than 80x24.

That would need support on the remote side (the getty) as well as on the terminal (minicom/tip/qemu -nographic/whatever).

While this would be a nice feature (and support for propagating the TERM, LANG and LC_* variables might be nice, too), I'm doubtful as to whether this will ever happen.

Signature · 1 line
Stuart Brady
#7 lore raw
In reply to Jeff Carr
Quoted 6 lines · Jeff Carr

Has anyone looked into finding a way to pass SIGWINCH through to the guest? I started looking at linux-user/signal.c.

For those that might not be familiar with SIGWINCH, supporting it would allow qemu -nographic to tell when the terminal is a different size than 80x24.

The problem is a serial port is essentially a pipe. You don't get tty information about the terminal plugged into the other side, because that's a separate machine on the other side of a piece of hardware which doesn't pass through that info. (What _is_ the width and height of a modem?)

Have your program send an ansi probe sequence:

echo -e "\e[s\e[999C\e[999B\e[6n\e[u"

Then parse the return string, which should look something like escape left bracket 25 semicolon 80 capital R, and use it to set $LINES=25 and $COLUMNS=80.

Any modern terminal program should handle that and spit back a result telling you big the tty is (although it doesn't tell you when it _changes_, you have to re-probe). Yes, it's in-band signalling but over a serial connection that's all you've got.

Rob

Signature · 2 lines
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.