Skip to content

vmm/linux/vstate: support KVM SystemEvents #302

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

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/vmm/src/linux/vstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ use kvm_bindings::{
KVM_CLOCK_TSC_STABLE, KVM_IRQCHIP_IOAPIC, KVM_IRQCHIP_PIC_MASTER, KVM_IRQCHIP_PIC_SLAVE,
KVM_MAX_CPUID_ENTRIES,
};
use kvm_bindings::{kvm_userspace_memory_region, KVM_API_VERSION};
use kvm_bindings::{
kvm_userspace_memory_region, KVM_API_VERSION, KVM_SYSTEM_EVENT_RESET, KVM_SYSTEM_EVENT_SHUTDOWN,
};
use kvm_ioctls::*;
use utils::eventfd::EventFd;
use utils::signal::{register_signal_handler, sigrtmin, Killable};
Expand Down Expand Up @@ -1129,6 +1131,14 @@ impl Vcpu {
error!("Received KVM_EXIT_INTERNAL_ERROR signal");
Err(Error::VcpuUnhandledKvmExit)
}
VcpuExit::SystemEvent(event, _reason) => {
Copy link
Member

@tylerfanelli tylerfanelli Apr 4, 2025

Choose a reason for hiding this comment

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

Should this be tagged behind #[cfg(target_arch = "aarch64")]? If not gaining anything from adding it, I'd say no, but just making sure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On x86_64 we don't hit that one right now, because we shut down with a triple fault, but it's valid a could eventually happen.

match event {
KVM_SYSTEM_EVENT_SHUTDOWN => info!("Received KVM_SYSTEM_EVENT_SHUTDOWN"),
KVM_SYSTEM_EVENT_RESET => info!("Received KVM_SYSTEM_EVENT_RESET"),
_ => error!("Received an unexpected System Event: {event}"),
}
Ok(VcpuEmulation::Stopped)
}
r => {
// TODO: Are we sure we want to finish running a vcpu upon
// receiving a vm exit that is not necessarily an error?
Expand Down
Loading