mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 05:10:55 +00:00
chore(xen): split platform support into separate crate (#195)
This commit is contained in:
32
Cargo.lock
generated
32
Cargo.lock
generated
@ -1584,6 +1584,7 @@ dependencies = [
|
|||||||
"krata-xenclient",
|
"krata-xenclient",
|
||||||
"krata-xenevtchn",
|
"krata-xenevtchn",
|
||||||
"krata-xengnt",
|
"krata-xengnt",
|
||||||
|
"krata-xenplatform",
|
||||||
"krata-xenstore",
|
"krata-xenstore",
|
||||||
"log",
|
"log",
|
||||||
"loopdev-3",
|
"loopdev-3",
|
||||||
@ -1626,23 +1627,17 @@ name = "krata-xenclient"
|
|||||||
version = "0.0.10"
|
version = "0.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"c2rust-bitfields",
|
|
||||||
"elf",
|
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"flate2",
|
|
||||||
"indexmap 2.2.6",
|
"indexmap 2.2.6",
|
||||||
"krata-xencall",
|
"krata-xencall",
|
||||||
|
"krata-xenplatform",
|
||||||
"krata-xenstore",
|
"krata-xenstore",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"memchr",
|
|
||||||
"nix 0.28.0",
|
|
||||||
"regex",
|
"regex",
|
||||||
"slice-copy",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"uuid",
|
"uuid",
|
||||||
"xz2",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1665,6 +1660,29 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "krata-xenplatform"
|
||||||
|
version = "0.0.10"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"c2rust-bitfields",
|
||||||
|
"elf",
|
||||||
|
"env_logger",
|
||||||
|
"flate2",
|
||||||
|
"indexmap 2.2.6",
|
||||||
|
"krata-xencall",
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
|
"memchr",
|
||||||
|
"nix 0.28.0",
|
||||||
|
"regex",
|
||||||
|
"slice-copy",
|
||||||
|
"thiserror",
|
||||||
|
"tokio",
|
||||||
|
"uuid",
|
||||||
|
"xz2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "krata-xenstore"
|
name = "krata-xenstore"
|
||||||
version = "0.0.10"
|
version = "0.0.10"
|
||||||
|
@ -12,6 +12,7 @@ members = [
|
|||||||
"crates/xen/xenclient",
|
"crates/xen/xenclient",
|
||||||
"crates/xen/xenevtchn",
|
"crates/xen/xenevtchn",
|
||||||
"crates/xen/xengnt",
|
"crates/xen/xengnt",
|
||||||
|
"crates/xen/xenplatform",
|
||||||
"crates/xen/xenstore",
|
"crates/xen/xenstore",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
@ -32,6 +33,7 @@ backhand = "0.15.0"
|
|||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
bytes = "1.5.0"
|
bytes = "1.5.0"
|
||||||
|
c2rust-bitfields = "0.18.0"
|
||||||
cgroups-rs = "0.3.4"
|
cgroups-rs = "0.3.4"
|
||||||
circular-buffer = "0.1.7"
|
circular-buffer = "0.1.7"
|
||||||
comfy-table = "7.1.1"
|
comfy-table = "7.1.1"
|
||||||
|
@ -31,10 +31,7 @@ use self::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(
|
#[command(version, about = "Control the krata isolation engine")]
|
||||||
version,
|
|
||||||
about = "Control the krata isolation engine"
|
|
||||||
)]
|
|
||||||
pub struct ControlCommand {
|
pub struct ControlCommand {
|
||||||
#[arg(
|
#[arg(
|
||||||
short,
|
short,
|
||||||
|
@ -23,6 +23,7 @@ uuid = { workspace = true }
|
|||||||
krata-xenclient = { path = "../xen/xenclient", version = "^0.0.10" }
|
krata-xenclient = { path = "../xen/xenclient", version = "^0.0.10" }
|
||||||
krata-xenevtchn = { path = "../xen/xenevtchn", version = "^0.0.10" }
|
krata-xenevtchn = { path = "../xen/xenevtchn", version = "^0.0.10" }
|
||||||
krata-xengnt = { path = "../xen/xengnt", version = "^0.0.10" }
|
krata-xengnt = { path = "../xen/xengnt", version = "^0.0.10" }
|
||||||
|
krata-xenplatform = { path = "../xen/xenplatform", version = "^0.0.10" }
|
||||||
krata-xenstore = { path = "../xen/xenstore", version = "^0.0.10" }
|
krata-xenstore = { path = "../xen/xenstore", version = "^0.0.10" }
|
||||||
walkdir = { workspace = true }
|
walkdir = { workspace = true }
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ pub mod ip;
|
|||||||
pub mod launch;
|
pub mod launch;
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
type RuntimePlatform = xenclient::x86pv::X86PvPlatform;
|
type RuntimePlatform = xenplatform::x86pv::X86PvPlatform;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "x86_64"))]
|
#[cfg(not(target_arch = "x86_64"))]
|
||||||
type RuntimePlatform = xenclient::unsupported::UnsupportedPlatform;
|
type RuntimePlatform = xenplatform::unsupported::UnsupportedPlatform;
|
||||||
|
|
||||||
pub struct GuestLoopInfo {
|
pub struct GuestLoopInfo {
|
||||||
pub device: String,
|
pub device: String,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "krata-xencall"
|
name = "krata-xencall"
|
||||||
description = "An implementation of direct interfacing to xen privcmd for krata."
|
description = "An implementation of direct interfacing to Xen privcmd for krata"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "krata-xenclient"
|
name = "krata-xenclient"
|
||||||
description = "An implementation of Xen userspace for krata."
|
description = "An implementation of Xen userspace for krata"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
@ -10,22 +10,16 @@ resolver = "2"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
c2rust-bitfields = "0.18.0"
|
|
||||||
elf = { workspace = true }
|
|
||||||
flate2 = { workspace = true }
|
|
||||||
indexmap = { workspace = true }
|
indexmap = { workspace = true }
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
krata-xencall = { path = "../xencall", version = "^0.0.10" }
|
krata-xencall = { path = "../xencall", version = "^0.0.10" }
|
||||||
|
krata-xenplatform = { path = "../xenplatform", version = "^0.0.10" }
|
||||||
krata-xenstore = { path = "../xenstore", version = "^0.0.10" }
|
krata-xenstore = { path = "../xenstore", version = "^0.0.10" }
|
||||||
memchr = { workspace = true }
|
|
||||||
nix = { workspace = true }
|
|
||||||
regex = { workspace = true }
|
regex = { workspace = true }
|
||||||
slice-copy = { workspace = true }
|
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
uuid = { workspace = true }
|
uuid = { workspace = true }
|
||||||
xz2 = { workspace = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = { workspace = true }
|
env_logger = { workspace = true }
|
||||||
|
@ -4,10 +4,10 @@ use xenclient::error::Result;
|
|||||||
use xenclient::{DomainConfig, XenClient};
|
use xenclient::{DomainConfig, XenClient};
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
type RuntimePlatform = xenclient::x86pv::X86PvPlatform;
|
type RuntimePlatform = xenplatform::x86pv::X86PvPlatform;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "x86_64"))]
|
#[cfg(not(target_arch = "x86_64"))]
|
||||||
type RuntimePlatform = xenclient::unsupported::UnsupportedPlatform;
|
type RuntimePlatform = xenplatform::unsupported::UnsupportedPlatform;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
@ -20,12 +20,6 @@ pub enum Error {
|
|||||||
PathParentNotFound,
|
PathParentNotFound,
|
||||||
#[error("domain does not exist")]
|
#[error("domain does not exist")]
|
||||||
DomainNonExistent,
|
DomainNonExistent,
|
||||||
#[error("elf parse failed: {0}")]
|
|
||||||
ElfParseFailed(#[from] elf::ParseError),
|
|
||||||
#[error("mmap failed")]
|
|
||||||
MmapFailed,
|
|
||||||
#[error("munmap failed: {0}")]
|
|
||||||
UnmapFailed(nix::errno::Errno),
|
|
||||||
#[error("memory setup failed: {0}")]
|
#[error("memory setup failed: {0}")]
|
||||||
MemorySetupFailed(&'static str),
|
MemorySetupFailed(&'static str),
|
||||||
#[error("populate physmap failed: wanted={0}, received={1}, input_extents={2}")]
|
#[error("populate physmap failed: wanted={0}, received={1}, input_extents={2}")]
|
||||||
@ -46,6 +40,8 @@ pub enum Error {
|
|||||||
InvalidPciBdfString,
|
InvalidPciBdfString,
|
||||||
#[error("pci device {0} is not assignable")]
|
#[error("pci device {0} is not assignable")]
|
||||||
PciDeviceNotAssignable(PciBdf),
|
PciDeviceNotAssignable(PciBdf),
|
||||||
|
#[error("xen platform error: {0}")]
|
||||||
|
XenPlatform(#[from] xenplatform::error::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
pub mod boot;
|
|
||||||
pub mod elfloader;
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod mem;
|
|
||||||
pub mod sys;
|
|
||||||
|
|
||||||
use crate::boot::{BootDomain, BootSetup};
|
|
||||||
use crate::elfloader::ElfImageLoader;
|
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use boot::BootSetupPlatform;
|
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use log::{debug, trace, warn};
|
use log::{debug, trace, warn};
|
||||||
use pci::{PciBdf, XenPciBackend};
|
use pci::{PciBdf, XenPciBackend};
|
||||||
use sys::XEN_PAGE_SHIFT;
|
|
||||||
use tokio::time::timeout;
|
use tokio::time::timeout;
|
||||||
|
use xenplatform::boot::{BootDomain, BootSetup, BootSetupPlatform};
|
||||||
|
use xenplatform::elfloader::ElfImageLoader;
|
||||||
|
use xenplatform::sys::XEN_PAGE_SHIFT;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@ -28,10 +23,6 @@ use xenstore::{
|
|||||||
|
|
||||||
pub mod pci;
|
pub mod pci;
|
||||||
|
|
||||||
pub mod unsupported;
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
|
||||||
pub mod x86pv;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct XenClient<P: BootSetupPlatform> {
|
pub struct XenClient<P: BootSetupPlatform> {
|
||||||
pub store: XsdClient,
|
pub store: XsdClient,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "krata-xenevtchn"
|
name = "krata-xenevtchn"
|
||||||
description = "An implementation of xen evtchn for krata."
|
description = "An implementation of Xen evtchn for krata."
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "krata-xengnt"
|
name = "krata-xengnt"
|
||||||
description = "An implementation of xen grant interfaces for krata."
|
description = "An implementation of Xen grant interfaces for krata"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
|
34
crates/xen/xenplatform/Cargo.toml
Normal file
34
crates/xen/xenplatform/Cargo.toml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[package]
|
||||||
|
name = "krata-xenplatform"
|
||||||
|
description = "An implementation of Xen platforms for krata"
|
||||||
|
license.workspace = true
|
||||||
|
version.workspace = true
|
||||||
|
homepage.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
edition = "2021"
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
async-trait = { workspace = true }
|
||||||
|
c2rust-bitfields = { workspace = true }
|
||||||
|
elf = { workspace = true }
|
||||||
|
flate2 = { workspace = true }
|
||||||
|
indexmap = { workspace = true }
|
||||||
|
libc = { workspace = true }
|
||||||
|
log = { workspace = true }
|
||||||
|
krata-xencall = { path = "../xencall", version = "^0.0.10" }
|
||||||
|
memchr = { workspace = true }
|
||||||
|
nix = { workspace = true }
|
||||||
|
regex = { workspace = true }
|
||||||
|
slice-copy = { workspace = true }
|
||||||
|
thiserror = { workspace = true }
|
||||||
|
tokio = { workspace = true }
|
||||||
|
uuid = { workspace = true }
|
||||||
|
xz2 = { workspace = true }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
env_logger = { workspace = true }
|
||||||
|
tokio = { workspace = true }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "xenplatform"
|
43
crates/xen/xenplatform/src/error.rs
Normal file
43
crates/xen/xenplatform/src/error.rs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
use std::io;
|
||||||
|
|
||||||
|
#[derive(thiserror::Error, Debug)]
|
||||||
|
pub enum Error {
|
||||||
|
#[error("io issue encountered: {0}")]
|
||||||
|
Io(#[from] io::Error),
|
||||||
|
#[error("xencall issue encountered: {0}")]
|
||||||
|
XenCall(#[from] xencall::error::Error),
|
||||||
|
#[error("domain does not have a tty")]
|
||||||
|
TtyNotFound,
|
||||||
|
#[error("introducing the domain failed")]
|
||||||
|
IntroduceDomainFailed,
|
||||||
|
#[error("string conversion of a path failed")]
|
||||||
|
PathStringConversion,
|
||||||
|
#[error("parent of path not found")]
|
||||||
|
PathParentNotFound,
|
||||||
|
#[error("domain does not exist")]
|
||||||
|
DomainNonExistent,
|
||||||
|
#[error("elf parse failed: {0}")]
|
||||||
|
ElfParseFailed(#[from] elf::ParseError),
|
||||||
|
#[error("mmap failed")]
|
||||||
|
MmapFailed,
|
||||||
|
#[error("munmap failed: {0}")]
|
||||||
|
UnmapFailed(nix::errno::Errno),
|
||||||
|
#[error("memory setup failed: {0}")]
|
||||||
|
MemorySetupFailed(&'static str),
|
||||||
|
#[error("populate physmap failed: wanted={0}, received={1}, input_extents={2}")]
|
||||||
|
PopulatePhysmapFailed(usize, usize, usize),
|
||||||
|
#[error("unknown elf compression method")]
|
||||||
|
ElfCompressionUnknown,
|
||||||
|
#[error("expected elf image format not found")]
|
||||||
|
ElfInvalidImage,
|
||||||
|
#[error("provided elf image does not contain xen support")]
|
||||||
|
ElfXenSupportMissing,
|
||||||
|
#[error("regex error: {0}")]
|
||||||
|
RegexError(#[from] regex::Error),
|
||||||
|
#[error("error: {0}")]
|
||||||
|
GenericError(String),
|
||||||
|
#[error("failed to parse int: {0}")]
|
||||||
|
ParseIntError(#[from] std::num::ParseIntError),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type Result<T> = std::result::Result<T, Error>;
|
11
crates/xen/xenplatform/src/lib.rs
Normal file
11
crates/xen/xenplatform/src/lib.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
pub mod boot;
|
||||||
|
pub mod elfloader;
|
||||||
|
pub mod error;
|
||||||
|
pub mod mem;
|
||||||
|
pub mod sys;
|
||||||
|
|
||||||
|
use crate::error::Error;
|
||||||
|
|
||||||
|
pub mod unsupported;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
pub mod x86pv;
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "krata-xenstore"
|
name = "krata-xenstore"
|
||||||
description = "A client that interacts with xenstore for krata."
|
description = "A client that interacts with xenstore for krata"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
|
@ -36,6 +36,10 @@ semver_check = false
|
|||||||
name = "krata-xengnt"
|
name = "krata-xengnt"
|
||||||
semver_check = false
|
semver_check = false
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "krata-xenplatform"
|
||||||
|
semver_check = false
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "krata-xenstore"
|
name = "krata-xenstore"
|
||||||
semver_check = false
|
semver_check = false
|
||||||
|
Reference in New Issue
Block a user