From 0f727127d55e0f83b035ebd3990f5f1f87291645 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Tue, 14 Jan 2020 12:02:42 +0100 Subject: [PATCH] vmm: Implement InterruptSourceGroup and InterruptManager skeleton This commit introduces an empty implementation of both InterruptManager and InterruptSourceGroup traits, as a proper basis for further implementation. Signed-off-by: Sebastien Boeuf --- vmm/src/interrupt.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++ vmm/src/lib.rs | 1 + 2 files changed, 49 insertions(+) create mode 100644 vmm/src/interrupt.rs diff --git a/vmm/src/interrupt.rs b/vmm/src/interrupt.rs new file mode 100644 index 000000000..e48c60a20 --- /dev/null +++ b/vmm/src/interrupt.rs @@ -0,0 +1,48 @@ +// Copyright © 2019 Intel Corporation +// +// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause +// + +use std::sync::Arc; +use vm_device::interrupt::{ + InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup, InterruptType, +}; + +/// Reuse std::io::Result to simplify interoperability among crates. +pub type Result = std::io::Result; + +pub struct MsiInterruptGroup {} + +impl MsiInterruptGroup { + fn new() -> Self { + MsiInterruptGroup {} + } +} + +impl InterruptSourceGroup for MsiInterruptGroup { + fn trigger(&self, _index: InterruptIndex) -> Result<()> { + Ok(()) + } + + fn update(&self, _index: InterruptIndex, _config: InterruptSourceConfig) -> Result<()> { + Ok(()) + } +} + +pub struct KvmInterruptManager {} + +impl InterruptManager for KvmInterruptManager { + fn create_group( + &self, + _interrupt_type: InterruptType, + _base: InterruptIndex, + _count: InterruptIndex, + ) -> Result>> { + let interrupt_source_group = MsiInterruptGroup::new(); + Ok(Arc::new(Box::new(interrupt_source_group))) + } + + fn destroy_group(&self, _group: Arc>) -> Result<()> { + Ok(()) + } +} diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 0416ac127..783ff175b 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -30,6 +30,7 @@ pub mod api; pub mod config; pub mod cpu; pub mod device_manager; +pub mod interrupt; pub mod memory_manager; pub mod vm;