-
Notifications
You must be signed in to change notification settings - Fork 103
Add granular console APIs #363
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
base: main
Are you sure you want to change the base?
Conversation
21d9f1a
to
0523151
Compare
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.
LGTM, though I wonder if it makes sense for this to be krun_set_console
and the input to be an enum with two supported options:
KRUN_CONSOLE_SERIAL
KRUN_CONSOLE_VIRTIO
Leaves open the possibility of adding other options. Just something to consider.
It's even more complex. You might want to enable one of them, or both. But, in addition of that, for the non-EFI case and when the kernel command line is not specified with Perhaps something like...
...? |
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.
Let's rethink about the configuration options.
Yeah I agree we should be more flexible whether you want both, but I'm not really a fan of having an enum like this. I feel like ideally we should not have a console at all and let the user attach SERIAL/VIRTIO console(s) explicitly. Perhaps we could retrofit it to the current API... Can we maybe add an int32_t ctx = krun_create_ctx();
krun_no_implicit_consoles(ctx);
krun_add_serial_console(/*console id*/ 1, ...);
krun_add_virtio_console(/*console id*/ 2, ...);
krun_set_kernel_console(/*console id*/ 1); // console= in the kernel command line. This would also make future API for attaching multiple virtio-console(s) nicer. Though this requires bigger changes in libkrun, I feel like it makes the API much more sane for the users (and extensible for us!). |
Yes, this is probably the way. We know we're going to need a much more flexible console configuration for Android support (Android is a heavy user of virtio-console to communicate the guests with various processes in the host), and this would be a step in the right direction. That said, perhaps it'd be safer to wait a bit to see exactly what the requirements are on the Android side and then propose an API? |
Yeah maybe, but I don't think it will really be a problem. For now we could just have the same functionality as we already do just make it more explicit. We can also have multiple Details of how to configure the console(s) for Android can still be figured out later. We could add a function like |
0d63be1
to
25d3650
Compare
krun_set_serial_console
APIa171452
to
0b7aa34
Compare
59c54a0
to
e337372
Compare
This should work. I did my best to test it on macOS and x86. I spent more time than I'd like to admit going back and forth on how this should all look, but I tried making a sane starting point that allows for future expansion (for Android, for example). If it doesn't work for someone, or I completely over looked something, let me know :) |
413b2b8
to
4523fe0
Compare
4523fe0
to
1f4e79b
Compare
Adds a new `krun_disable_implicit_console` API. This allows the user to prevent libkrun from implicitly adding a console to their guest. Signed-off-by: Jake Correnti <[email protected]>
Adds the `krun_set_kernel_console` API, which allows the user to specify the value of `console=` in the kernel commandline. Signed-off-by: Jake Correnti <[email protected]>
1f4e79b
to
d184dac
Compare
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.
LGTM, I added a suggestion to clarify the doc comment a bit more though
Adds the new `krun_add_virtio_console_default` and `krun_add_serial_console_default` APIs. They allow the user to manually create a console device that will then be attached to the guest. Signed-off-by: Jake Correnti <[email protected]>
Signed-off-by: Jake Correnti <[email protected]>
d184dac
to
166aeb7
Compare
Currently, libkrun forces the user to manually change the source code if they are not building with EFI=1 and want to use the serial console instead of the virtio-console.
Provide an API,
krun_set_serial_console
, allowing the user to specify whether the serial console should be enabled. The serial console remains the default on EFI=1 use cases.