Skip to content
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

virtme-ng: redirect kernel log to stderr in interactive mode #66

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

arighi
Copy link
Owner

@arighi arighi commented Feb 4, 2024

Redirect kernel messages to stderr when running in interactive mode, similar to what we do in command/script mode.

In this way it is possible, for example, to save kernel logs to a file even when running in interactive mode, such as:

$ vng -vr 2>/tmp/kernel.log

NOTE: unfortunately we can't redirect early boot kernel messages, earlyprintk doesn't seem to work with virconsole devices. So, early messages will be still sent to stdout, in this way we don't break the old behavior.

This addresses discussion #60.

Redirect kernel messages to stderr when running in interactive mode,
similar to what we do in command/script mode.

In this way it is possible, for example, to save kernel logs to a file
even when running in interactive mode, such as:

 $ vng -vr 2>/tmp/kernel.log

NOTE: unfortunately we can't redirect early boot kernel messages,
earlyprintk doesn't seem to work with virconsole devices. So, early
messages will be still sent to stdout, in this way we don't break the
old behavior.

This addresses discussion #60.

Signed-off-by: Andrea Righi <[email protected]>
@kuba-moo
Copy link
Contributor

kuba-moo commented Feb 5, 2024

Hm, this seems to break the ability to interact with the VM for me. Also the output of the user session goes to stderr, it seems because when I do 2>/tmp/file I see the prompt in that file.

@kuba-moo
Copy link
Contributor

kuba-moo commented Feb 5, 2024

My exact command line, FWIW:

../virtme-ng/vng -v -r ./build_mm/arch/x86_64/boot/bzImage  --disable-microvm

It may be the --disable-microvm? On my laptop with Fedora 39 Qemu microvm doesn't seem to work :(
The actual testing happens in AWS, tho, so for us it'd be fine if the stderr logs only worked with microvm.

@arighi
Copy link
Owner Author

arighi commented Feb 5, 2024

That's weird, on my box (ubuntu 24.04) it seems to work both with microvm enabled and disabled. Let me investigate a bit...

@arighi
Copy link
Owner Author

arighi commented Feb 8, 2024

Hm, this seems to break the ability to interact with the VM for me. Also the output of the user session goes to stderr, it seems because when I do 2>/tmp/file I see the prompt in that file.

I was able to (inadvertently) reproduce this on a different box. Basically I forgot to recompile virtme-ng-init, that also require a change to support this new stderr redirection. Maybe the same happened to you.

Basically I had to do:

$ git submodule update
$ BUILD_VIRTME_NG_INIT=1 pip install --break-system-packages .

Or run vng with --no-virtme-ng-init to use the bash init.

Can you double check if this is the same issue that you have? Thanks!

@kuba-moo
Copy link
Contributor

kuba-moo commented Feb 8, 2024

The pip build fails, so I tried with bash init. It works perfectly! Thank you!

@arighi
Copy link
Owner Author

arighi commented Feb 8, 2024

@kuba-moo awesome, thanks for testing!

I'll merge this, because I think it's really useful. I even used this today to dump the kernel log to a file during a test that was messing up the console (and I couldn't scroll back to see the entire kernel oops).

Therefore, let's merge this and if nobody is screaming I'll also cut a new version.

@arighi arighi merged commit a28ac8b into main Feb 8, 2024
8 checks passed
@jimc jimc mentioned this pull request May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants