Skip to content

chore: Update to kvm-bindings 0.8.0 #4581

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 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
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
20 changes: 6 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,3 @@ panic = "abort"
[profile.release]
panic = "abort"
lto = true

[patch.crates-io]
kvm-bindings = { git = "https://github.com/firecracker-microvm/kvm-bindings", tag = "v0.7.0-2", features = ["fam-wrappers"] }
2 changes: 1 addition & 1 deletion src/cpu-template-helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ serde_json = "1.0.116"
thiserror = "1.0.59"

vmm = { path = "../vmm" }
vmm-sys-util = "0.12.1"
vmm-sys-util = { version = "0.12.1", features = ["with-serde"] }

[features]
tracing = ["log-instrument", "vmm/tracing"]
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ log-instrument = { path = "../log-instrument", optional = true }
serde = { version = "1.0.198", features = ["derive"] }
thiserror = "1.0.59"
vm-memory = { version = "0.14.1", features = ["backend-mmap", "backend-bitmap"] }
vmm-sys-util = "0.12.1"
vmm-sys-util = { version = "0.12.1", features = ["with-serde"] }

[dev-dependencies]
serde_json = "1.0.116"
Expand Down
4 changes: 2 additions & 2 deletions src/vmm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ crc64 = "2.0.0"
derive_more = { version = "0.99.17", default-features = false, features = ["from", "display"] }
displaydoc = "0.2.4"
event-manager = "0.4.0"
kvm-bindings = { version = "0.7.0", features = ["fam-wrappers"] }
kvm-ioctls = "0.16.0"
kvm-bindings = { version = "0.8.0", features = ["fam-wrappers", "serde"] }
kvm-ioctls = "0.17.0"
lazy_static = "1.4.0"
libc = "0.2.117"
linux-loader = "0.11.0"
Expand Down
38 changes: 23 additions & 15 deletions src/vmm/src/vstate/vcpu/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,19 @@ pub struct KvmVcpu {
pub index: u8,
/// KVM vcpu fd.
pub fd: VcpuFd,
/// Mmio bus.
pub mmio_bus: Option<crate::devices::Bus>,
/// Vcpu peripherals, such as buses
pub(super) peripherals: Peripherals,
mpidr: u64,
kvi: Option<kvm_bindings::kvm_vcpu_init>,
}

/// Vcpu peripherals
#[derive(Default, Debug)]
pub(super) struct Peripherals {
/// mmio bus.
pub mmio_bus: Option<crate::devices::Bus>,
}

impl KvmVcpu {
/// Constructs a new kvm vcpu with arch specific functionality.
///
Expand All @@ -76,7 +83,7 @@ impl KvmVcpu {
Ok(KvmVcpu {
index,
fd: kvm_vcpu,
mmio_bus: None,
peripherals: Default::default(),
mpidr: 0,
kvi: None,
})
Expand Down Expand Up @@ -222,18 +229,6 @@ impl KvmVcpu {

Ok(CpuConfiguration { regs })
}

/// Runs the vCPU in KVM context and handles the kvm exit reason.
///
/// Returns error or enum specifying whether emulation was handled or interrupted.
pub fn run_arch_emulation(&self, exit: VcpuExit) -> Result<VcpuEmulation, VcpuError> {
METRICS.vcpu.failures.inc();
// TODO: Are we sure we want to finish running a vcpu upon
// receiving a vm exit that is not necessarily an error?
error!("Unexpected exit reason on vcpu run: {:?}", exit);
Err(VcpuError::UnhandledKvmExit(format!("{:?}", exit)))
}

/// Initializes internal vcpufd.
fn init_vcpu(&self, kvi: &kvm_bindings::kvm_vcpu_init) -> Result<(), KvmVcpuError> {
self.fd.vcpu_init(kvi).map_err(KvmVcpuError::Init)?;
Expand All @@ -253,6 +248,19 @@ impl KvmVcpu {
}
}

impl Peripherals {
/// Runs the vCPU in KVM context and handles the kvm exit reason.
///
/// Returns error or enum specifying whether emulation was handled or interrupted.
pub fn run_arch_emulation(&self, exit: VcpuExit) -> Result<VcpuEmulation, VcpuError> {
METRICS.vcpu.failures.inc();
// TODO: Are we sure we want to finish running a vcpu upon
// receiving a vm exit that is not necessarily an error?
error!("Unexpected exit reason on vcpu run: {:?}", exit);
Err(VcpuError::UnhandledKvmExit(format!("{:?}", exit)))
}
}

/// Structure holding VCPU kvm state.
#[derive(Default, Clone, Serialize, Deserialize)]
pub struct VcpuState {
Expand Down
Loading
Loading