hypha: move components into separate crates

This commit is contained in:
Alex Zenla 2024-02-06 09:07:18 +00:00
parent 0c11744c50
commit e000ab2919
No known key found for this signature in database
GPG Key ID: 067B238899B51269
22 changed files with 101 additions and 27 deletions

View File

@ -6,7 +6,10 @@ members = [
"libs/xen/xenclient",
"libs/advmac",
"libs/loopdev",
"hypha",
"shared",
"container",
"network",
"controller",
]
resolver = "2"
@ -30,7 +33,6 @@ errno = "0.3.0"
oci-spec = "0.6.4"
backhand = "0.14.2"
sha256 = "1.5.0"
serde = "1.0.196"
serde_json = "1.0.113"
walkdir = "2"
directories = "5.0.1"
@ -64,3 +66,7 @@ features = ["derive"]
[workspace.dependencies.tokio]
version = "1.35.1"
features = ["macros", "rt", "rt-multi-thread"]
[workspace.dependencies.serde]
version = "1.0.196"
features = ["derive"]

33
container/Cargo.toml Normal file
View File

@ -0,0 +1,33 @@
[package]
name = "hyphactr"
version.workspace = true
edition = "2021"
resolver = "2"
[dependencies]
anyhow = { workspace = true }
log = { workspace = true }
env_logger = { workspace = true }
walkdir = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sys-mount = { workspace = true }
oci-spec = { workspace = true }
rtnetlink = { workspace = true }
tokio = { workspace = true }
futures = { workspace = true }
ipnetwork = { workspace = true }
[dependencies.nix]
workspace = true
features = ["process"]
[dependencies.hypha]
path = "../shared"
[lib]
path = "src/lib.rs"
[[bin]]
name = "hyphactr"
path = "bin/init.rs"

View File

@ -1,6 +1,6 @@
use anyhow::{anyhow, Result};
use env_logger::Env;
use hypha::container::init::ContainerInit;
use hyphactr::init::ContainerInit;
use std::env;
#[tokio::main]

View File

@ -1,6 +1,6 @@
use crate::shared::{LaunchInfo, LaunchNetwork};
use anyhow::{anyhow, Result};
use futures::stream::TryStreamExt;
use hypha::{LaunchInfo, LaunchNetwork};
use ipnetwork::IpNetwork;
use log::{trace, warn};
use nix::libc::{c_int, dup2, wait};

View File

@ -1,5 +1,5 @@
[package]
name = "hypha"
name = "hyphactrl"
version.workspace = true
edition = "2021"
resolver = "2"
@ -22,16 +22,13 @@ path-clean = { workspace = true }
termion = { workspace = true }
cli-tables = { workspace = true }
clap = { workspace = true }
sys-mount = { workspace = true }
oci-spec = { workspace = true }
backhand = { workspace = true }
uuid = { workspace = true }
rtnetlink = { workspace = true }
netlink-packet-route = { workspace = true }
tokio = { workspace = true }
futures = { workspace = true }
ipnetwork = { workspace = true }
smoltcp = { workspace = true }
[dependencies.hypha]
path = "../shared"
[dependencies.nix]
workspace = true
@ -54,12 +51,4 @@ path = "src/lib.rs"
[[bin]]
name = "hyphactl"
path = "bin/controller.rs"
[[bin]]
name = "hyphactr"
path = "bin/container.rs"
[[bin]]
name = "hyphanet"
path = "bin/network.rs"
path = "bin/control.rs"

View File

@ -1,7 +1,7 @@
use anyhow::{anyhow, Result};
use clap::{Parser, Subcommand};
use env_logger::Env;
use hypha::ctl::Controller;
use hyphactrl::ctl::Controller;
use std::path::PathBuf;
#[derive(Parser, Debug)]

View File

@ -1,6 +1,4 @@
pub mod autoloop;
pub mod container;
pub mod ctl;
pub mod image;
pub mod network;
pub mod shared;

View File

@ -21,9 +21,6 @@ path = "../xencall"
[dependencies.xenstore]
path = "../xenstore"
[dependencies.xenevtchn]
path = "../xenevtchn"
[dev-dependencies]
env_logger = { workspace = true }

26
network/Cargo.toml Normal file
View File

@ -0,0 +1,26 @@
[package]
name = "hyphanet"
version.workspace = true
edition = "2021"
resolver = "2"
[dependencies]
anyhow = { workspace = true }
clap = { workspace = true }
log = { workspace = true }
env_logger = { workspace = true }
rtnetlink = { workspace = true }
netlink-packet-route = { workspace = true }
tokio = { workspace = true }
futures = { workspace = true }
smoltcp = { workspace = true }
[dependencies.advmac]
path = "../libs/advmac"
[lib]
path = "src/lib.rs"
[[bin]]
name = "hyphanet"
path = "bin/network.rs"

View File

@ -1,7 +1,7 @@
use anyhow::Result;
use clap::Parser;
use env_logger::Env;
use hypha::network::NetworkService;
use hyphanet::NetworkService;
#[derive(Parser, Debug)]
struct NetworkArgs {

11
shared/Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "hypha"
version.workspace = true
edition = "2021"
resolver = "2"
[dependencies]
serde = { workspace = true }
[lib]
path = "src/lib.rs"

14
shared/src/lib.rs Normal file
View File

@ -0,0 +1,14 @@
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct LaunchNetwork {
pub link: String,
pub ipv4: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct LaunchInfo {
pub network: Option<LaunchNetwork>,
pub env: Option<Vec<String>>,
pub run: Option<Vec<String>>,
}