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 <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-01-14 12:02:42 +01:00 committed by Samuel Ortiz
parent 11d4d57c06
commit 0f727127d5
2 changed files with 49 additions and 0 deletions

48
vmm/src/interrupt.rs Normal file
View File

@ -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<T> = std::io::Result<T>;
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<Arc<Box<dyn InterruptSourceGroup>>> {
let interrupt_source_group = MsiInterruptGroup::new();
Ok(Arc::new(Box::new(interrupt_source_group)))
}
fn destroy_group(&self, _group: Arc<Box<dyn InterruptSourceGroup>>) -> Result<()> {
Ok(())
}
}

View File

@ -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;