-
Notifications
You must be signed in to change notification settings - Fork 28
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
Access guest console when it is running #48
Comments
hyperkit has such support, I think the code they use for this is https://github.com/moby/hyperkit/blob/3cb0d5475244761c61e6fd4a562702c26b46f846/src/lib/uart_emul.c#L738-L784 The code for https://pkg.go.dev/github.com/pkg/term/termios#Pty is very similar: https://github.com/pkg/term/blob/v1.1.0/termios/pty.go#L22 |
Seems to be relatively easy to do https://github.com/cfergeau/vfkit/tree/pty |
Testing with https://github.com/cfergeau/vfkit/tree/pty I made some awesome progress on integrating some of this within PD! I did encounter some issues however:
Start VM 1 ./vfkit-arm64 --cpus 2 --memory 2048 \
--bootloader efi,variable-store=./efi-variable-store,create \
--device virtio-blk,path=/Users/cdrage/bootc/image/disk.raw \
--device virtio-serial,pty \
--device virtio-net,nat,mac=72:20:43:d4:38:62 \
--device virtio-rng \
--device virtio-input,keyboard \
--device virtio-input,pointing Start VM 2 ./vfkit-arm64 --cpus 2 --memory 2048 \
--bootloader efi,variable-store=./efi-variable-store,create \
--device virtio-blk,path=/Users/cdrage/bootc/image/disk2.raw \
--device virtio-serial,pty \
--device virtio-net,nat,mac=72:20:43:d4:38:62 \
--device virtio-rng \
--device virtio-input,keyboard \
--device virtio-input,pointing You should get two ttys. One is /dev/ttys003 The other would be random (mine was /dev/ttys010). If you do If you do Video is below! Screen.Recording.2024-01-24.at.10.02.31.AM.mov
|
You can remove
from your commandline, they are only needed if you use the --gui flag. |
Thanks! I shouldn't of added those inputs haha. I did try it again without those inputs and I can now "load" the screen, but I get a different error. It's now completely blank / wont load anything. Screen.Recording.2024-01-25.at.9.21.30.AM.mov |
This is one issue with the current branch, there is no nice way of providing the pty name to vfkit users. It's printed in the logs and that's it. I'm not sure it's possible to choose which tty will be allocated, I'll need to look more closely. hyperkit allows to specify a file when using the I hope to be able to give this info through vfkit REST API, calling |
The low-level kernel/libc API is definitely of the form "allocate a pty for me, and give me its name", it does not seem possibe to control this and choose a name. However https://github.com/cfergeau/vfkit/tree/pty now exposes the pty name in the REST API
|
I have been investigating a bunch of similar issues, sometimes even after killing/starting again the same VM, I can't connect. My current suspicion is that it's related to my non-handling of Close() on the PTY sockets. They are leaked, and go closes them as it sees fit when garbage collection happens. If I assign them to global variables so that they are not garbage collected, behaviour is more predictible so far (I can kill/start/kill/start with no problems, I can run 2 VMs side by side and connect to both, ..) |
This new virtio-serial option allocates a pseudo-tty for the VM console. It can then be accessed using `screen` for example. This is a bit similar to the `--device virtio-serial,stdio` option, except that the console is not tied to the terminal running vfkit, it's possible to connect/disconnect from the pseudo-tty from any terminal. This fixes crc-org#48 Signed-off-by: Christophe Fergeau <[email protected]>
Conclusion of the investigations is that it was all related, closing the |
Are you waiting for peer-review/confirmation? If so, from whom? |
The associated PR will need a review #113 |
This new virtio-serial option allocates a pseudo-tty for the VM console. It can then be accessed using `screen` for example. This is a bit similar to the `--device virtio-serial,stdio` option, except that the console is not tied to the terminal running vfkit, it's possible to connect/disconnect from the pseudo-tty from any terminal. This fixes crc-org#48 Signed-off-by: Christophe Fergeau <[email protected]>
As of now we
vfkit/pkg/vf/virtio.go
Lines 272 to 276 in c9a4b08
https://developer.apple.com/documentation/virtualization/vzfilehandleserialportattachment?language=objc => this api allows bidirectional communication using file handles but we don't know how to consume it.
This is important for crc side to debug some of the issues when ssh connection is broken.
The text was updated successfully, but these errors were encountered: