-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiplexing of VNC and local TTY for the shim console #4593
Conversation
Wow, it looks like we really are an open-source project with a lively community and great PRs from contributors! =D |
Thanks for this great contribution @rouming , good to see you here as well...We will test it and please, join our LF-Edge channel on slack so you can syncup on our lf-edge calls: https://lfedge.slack.com/archives/CHMEEC0MP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Just to confirm, would a comprehensive test for this change be:
- Running an application
- Attaching to it using our eve attach-console command
- Running VNC to the application
I’d like to have a test scenario ready to verify it. Let me know if I’m missing anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to reflect the change of the name in the documentation as well:
Line 143 in 8c5b27a
In order to attach to the console of the hosting Vm of the Container application another console ID should be used which is named `prime-cons`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there are some references to prime-cons
on this doc. file...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll change the doc accordingly.
And yeah, the unit test still should be fixed to reflect the changes =) |
There is an EVE call next Thursday. Should we put you on the agenda? |
hi @rouming great to meet you here :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rouming , LGTM, pls, fix the tests and the comments... just minor stuff...
I ran this EVE version with a container app with the following DomainConfig
VNC to the container itself works well, but attaching to a serial console doesn't:
the shim console is missing and connection to the regular console fails.
I think there is something wrong with the xen1.cfg, that's probably also why the unit tests fail. I'll take a closer look a little later. |
@eriknordmark Yes, please. |
@naiming-zededa hi Naiming, right, nothing changes on this matter. I replaced |
hey Rene, will do. I tried to fix unit tests blindly, but missed :) |
yes, easily can be, did the change blindly, unfortunately, due to missing container deployment. Thanks for running this. If you folks can remind me how to use eden in order to start a random container, I will appreciate. Anyway this is not urgent. I'll play myself later. |
Right, the 2. and 3. should have similar output, basically leading you to a same virtio console device. |
@rouming in order to test the container application, you can also use LF-Edge Sandbox: https://lfedge.org/resources/lf-edge-sandbox/ |
Difference to the previous version:
|
@rouming , it looks like the new patches are broken: https://github.com/lf-edge/eve/actions/runs/13203300686/job/36860327193?pr=4593#step:9:826 |
Right, thanks, forgot to change the path to reflect qemu-xen, was testing them manually. |
Difference to the previous version:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4593 +/- ##
=======================================
Coverage 20.90% 20.90%
=======================================
Files 13 13
Lines 2894 2894
=======================================
Hits 605 605
Misses 2163 2163
Partials 126 126 ☔ View full report in Codecov by Sentry. |
@europaul, ah, sorry, I thought it was a test attempt before the patches were fixed. |
Folks, I will return to this. Please don´t merge. |
Ok. Converted to draft. |
I have tried the latest patch last week, I only observed one 'cons' from the container app, I don't see the 'shim-cons' item. |
The name 'prime' for a hosting Vm is non-standard name in the industry. The established and familiar is 'shim'. Let's stick to something which is common and rename 'prime-cons' to a 'shim-cons'. Hopefully nobody depends on the old naming. Signed-off-by: Roman Penyaev <[email protected]>
Just a few replacements. Signed-off-by: Roman Penyaev <[email protected]>
This is a backport of QEMU upstreamed work, related to aggregator `hub` chardev implementation. The work implements a new chardev backend `hub` device, which aggregates input from multiple backend devices and forwards it to a single frontend device. Additionally, `hub` device takes the output from the frontend device and sends it back to all the connected backend devices. This allows for seamless interaction between different backend devices and a single frontend interface. The motivation is the EVE project [2], where it would be very convenient to have a virtio console frontend device on the guest that can be controlled from multiple backend devices, namely VNC and local TTY emulator. The following is an example of the QEMU command line: -chardev pty,path=/tmp/pty,id=pty0 \ -chardev vc,id=vc0 \ -chardev hub,id=hub0,chardevs.0=pty0,chardevs.1=vc0 \ -device virtconsole,chardev=hub0 \ -vnc 0.0.0.0:0 Which creates two backend devices: * Text virtual console (`vc0`) * A pseudo TTY (`pty0`) connected to the single virtio hvc console with the help of a new backend aggregator (`hub0`) `vc0` renders text to an image, which can be shared over the VNC protocol. `pty0` is a pseudo TTY backend which provides bidirectional communication to the virtio hvc console. Once QEMU starts, the VNC client and any TTY emulator can be used to control a single hvc console. For example, these two different consoles should have similar input and output due to the buffer aggregation: # Start TTY emulator tio /tmp/pty # Start VNC client and switch to virtual console Ctrl-Alt-2 vncviewer :0 Signed-off-by: Roman Penyaev <[email protected]>
…evice Starting from QEMU 10 (patches already backported to EVE) there is support of an aggregator hub chardev, which aggregates input from multiple backend devices and forwards it to a single frontend device. For a shim console we have a local pseudo TTY (so called shim-cons, available on `eve list-app-consoles`) and a VNC (should be explicitly enabled by the `debug.enable.vnc.shim.vm` flag). Input from both chardevs will be aggregated with the `hub` help and forwarded to a virtual console `hvc1`. This gives a user possibility to control shim VM with one virtual console from several (pty and vnc) backends. Signed-off-by: Roman Penyaev <[email protected]>
Make tests pass. Signed-off-by: Roman Penyaev <[email protected]>
Difference to the previous version:
Thanks @europaul for this list of eden commands, completely forgot how to run this beast. If you, guys, would like to test on your side, don't forget to switch the VNC main console to shim console, with Alt-Ctrl-2. I noticed, that VNC shim console has nasty escape symbols at the end of each prompt. This is not due to this patch, but presumably because of the incorrect rendering of escape symbols inside the ui/console-vc.c (like vc_chr_write()). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run tests
@eriknordmark, we still need confirmation from proper manual testing. |
@OhmSpectator i have tried the latest patch, and i can use the VNC to switch between the two consoles, with my 'realVNC' client |
@naiming-zededa That's great. While using VNC on the second console, please do |
yes, @rouming i saw that, both VNC's 2nd console and the attach-app-console to the shim-cons, see the same input and output of each other. |
Thanks, @naiming-zededa for verifying that. |
@rouming I tested the patch using the aforementioned eden setup:
|
@europaul Cool, thanks for testing.
VNC and "cons" occupy different console devices. If no VNC is set, then "cons" is attached to the container stdin/stdout. If you start VNC, then VNC is attached to the container stdin/stdout, and "cons" occupy another console device, which is dangling and not used. I see this behavior on the latest master. Did you mean something different? btw, did you notice nasty terminal sequence ^[[nn;mmR] at the end of the prompt in the VNC for the second console (Alt-Ctrl-2)? There is a bug in qemu in the vc terminal emulation: instead of sending cursor position response (CPR) to the application, the CPR is rendered in the VNC window. |
So if we just switch to that other console device, then cons should also work with VNC enabled? That would be cool!
Yes, I noticed this. Good to know the reason! |
It turns out to be that logic is quite hairy. When you start a container with the VNC enabled, there is the following branch:
which adds the So there are two cases: VNC enabled and VNC is disabled. For these cases the cmdline is different:
Then there is the following code:
For the VNC case For non VNC case there is full interaction with the /dev/console because of this To summarize, once VNC is enabled, it becomes the control terminal and "cons" becomes just an stdout for a started container. Wanna fix this? :) Update
so it can accept input/output from several consoles. There is
and also qemu cmdline itself contains a serial device:
so Easy to check. From the
On the |
@rouming @OhmSpectator @europaul @rene throw more into this topic :-) |
Hi EVE, long time no see :)
This series implements the long-standing feature namely multiplexing of VNC and local TTY for a single shim console. Feature was discussed many times with @europaul (here is his attempt to do that #4163, but seems abandoned). My approach is different to what Paul started: instead of tweaking the chroot2.c starter, better to leverage this to QEMU itself. My patches to QEMU were recently taken upstream (https://patchew.org/QEMU/[email protected]/) and should appear in QEMU 10. Due to this I would like to finish this work in EVE, which I started a few months back.
There are a couple of changes in this series, namely:
Use PTY chardev for QEMU console chardev devices, instead of socket, which simplifies wrappers around these tools.hub
chardev (including one fix for the PTY device)In short, the new
hub
character device in QEMU combines input from several backend devices (VNC, tty, socket, etc.) into a single frontend console device (actual virtio-console guest device), so that the user can control a guest console from a remote VNC and a local TTY console.The QEMU part was tested during the implementation, but with EVE I could test compilation only and straggle with container deployment (all zededa controller keys were expired, and back then it was my only way to start a container, to my shame). I would appreciate if someone from EVE can help me with running the stuff and testing the whole integration.
Also, I would like to join an lf-edge call, so can explain everything related to this series.