Skip to content

Queue Rng device events only when active#643

Open
Golui wants to merge 1 commit intocontainers:mainfrom
Golui:user/golui/fix-rng-panic
Open

Queue Rng device events only when active#643
Golui wants to merge 1 commit intocontainers:mainfrom
Golui:user/golui/fix-rng-panic

Conversation

@Golui
Copy link
Copy Markdown

@Golui Golui commented Apr 20, 2026

When an Rng virtio device is deactivated, its event queues are set to None.

However, Subscribers may still attempt to queue events to the device, resulting in a panic.

This pull request addresses the issue by simply moving the event queueing logic only if the device is active, otherwise warns about a spurious event.

This happens when launching a FreeBSD guest with krunkit*, which results in ~80% of boots failing. I may have had a similar issue with alpine 3.23.3 once, but my memory is a bit fuzzy.

Updated the code to allow the device to be re-activated.

*to get FreeBSD to boot in krunkit at all, legacy console needs to be used (wip), and the GPU needs to be explicitly disabled. Came across this when looking into that.

@mtjhrc
Copy link
Copy Markdown
Collaborator

mtjhrc commented Apr 20, 2026

Please add a Signed-off-by: ... to the commit message (git commit --signoff).

Otherwise change looks good, thanks for the fix!

@mtjhrc mtjhrc added the 1.x label Apr 20, 2026
When an Rng virtio device is deactivated, its event queues are set to
None, but the remaining Subscribers may still attempt to queue events to
the device, resulting in a panic.

Signed-off-by: Golui <golui889@gmail.com>
@Golui Golui force-pushed the user/golui/fix-rng-panic branch from 904ef73 to e7450bf Compare April 20, 2026 22:59
@Golui
Copy link
Copy Markdown
Author

Golui commented Apr 20, 2026

Done, thanks!

@slp
Copy link
Copy Markdown
Collaborator

slp commented Apr 21, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the process method in the VirtIO RNG event handler to prioritize activation events and defer request queue access until the device is activated. A potential race condition was identified where the activation handler might be invoked before the device queues are fully initialized, which could lead to a panic; adding a check for the existence of queues before handling the activation event is recommended.

Comment thread src/devices/src/virtio/rng/event_handler.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants