mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-11 04:26:38 +00:00
devices: move lib.rs common functions
BUG=b:213149155 TEST=presubmit Change-Id: Id73ceac4102e14fd0c499da9441268776147f882 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3760147 Commit-Queue: Vikram Auradkar <auradkar@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
f234eaf752
commit
f6908a8bcc
1 changed files with 40 additions and 39 deletions
|
@ -101,45 +101,6 @@ cfg_if::cfg_if! {
|
|||
pub use self::vfio::{VfioContainer, VfioDevice};
|
||||
pub use self::virtio::{vfio_wrapper, VirtioPciDevice};
|
||||
|
||||
/// Request CoIOMMU to unpin a specific range.
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct UnpinRequest {
|
||||
/// The ranges presents (start gfn, count).
|
||||
ranges: Vec<(u64, u64)>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum UnpinResponse {
|
||||
Success,
|
||||
Failed,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ParseIommuDevTypeResult {
|
||||
NoSuchType,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub enum IommuDevType {
|
||||
NoIommu,
|
||||
VirtioIommu,
|
||||
CoIommu,
|
||||
}
|
||||
|
||||
use std::str::FromStr;
|
||||
impl FromStr for IommuDevType {
|
||||
type Err = ParseIommuDevTypeResult;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"off" => Ok(IommuDevType::NoIommu),
|
||||
"viommu" => Ok(IommuDevType::VirtioIommu),
|
||||
"coiommu" => Ok(IommuDevType::CoIommu),
|
||||
_ => Err(ParseIommuDevTypeResult::NoSuchType),
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if #[cfg(windows)] {
|
||||
// We define Minijail as an empty struct on Windows because the concept
|
||||
// of jailing is baked into a bunch of places where it isn't easy
|
||||
|
@ -150,3 +111,43 @@ cfg_if::cfg_if! {
|
|||
compile_error!("Unsupported platform");
|
||||
}
|
||||
}
|
||||
|
||||
/// Request CoIOMMU to unpin a specific range.
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct UnpinRequest {
|
||||
/// The ranges presents (start gfn, count).
|
||||
ranges: Vec<(u64, u64)>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum UnpinResponse {
|
||||
Success,
|
||||
Failed,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ParseIommuDevTypeResult {
|
||||
NoSuchType,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub enum IommuDevType {
|
||||
NoIommu,
|
||||
VirtioIommu,
|
||||
CoIommu,
|
||||
}
|
||||
|
||||
use std::str::FromStr;
|
||||
impl FromStr for IommuDevType {
|
||||
type Err = ParseIommuDevTypeResult;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"off" => Ok(IommuDevType::NoIommu),
|
||||
"viommu" => Ok(IommuDevType::VirtioIommu),
|
||||
"coiommu" => Ok(IommuDevType::CoIommu),
|
||||
_ => Err(ParseIommuDevTypeResult::NoSuchType),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue