mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-02 21:00:55 +00:00
hypha: begin working on network support
This commit is contained in:
parent
dc5adcb413
commit
e73cfa92c8
@ -15,7 +15,7 @@ use std::str::FromStr;
|
|||||||
use std::{fs, io, thread};
|
use std::{fs, io, thread};
|
||||||
use termion::raw::IntoRawMode;
|
use termion::raw::IntoRawMode;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use xenclient::{DomainConfig, DomainDisk, XenClient};
|
use xenclient::{DomainConfig, DomainDisk, DomainNetworkInterface, XenClient};
|
||||||
use xenstore::client::{XsdClient, XsdInterface};
|
use xenstore::client::{XsdClient, XsdInterface};
|
||||||
|
|
||||||
pub struct Controller {
|
pub struct Controller {
|
||||||
@ -121,6 +121,12 @@ impl Controller {
|
|||||||
writable: false,
|
writable: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
vifs: vec![DomainNetworkInterface {
|
||||||
|
mac: "00:16:3E:46:0C:1B",
|
||||||
|
mtu: 1500,
|
||||||
|
bridge: "xenbr0",
|
||||||
|
script: "/etc/xen/scripts/vif-bridge",
|
||||||
|
}],
|
||||||
filesystems: vec![],
|
filesystems: vec![],
|
||||||
extra_keys: vec![
|
extra_keys: vec![
|
||||||
("hypha/uuid".to_string(), uuid.to_string()),
|
("hypha/uuid".to_string(), uuid.to_string()),
|
||||||
|
@ -22,6 +22,7 @@ fn main() -> Result<()> {
|
|||||||
initrd_path: initrd_path.as_str(),
|
initrd_path: initrd_path.as_str(),
|
||||||
cmdline: "debug elevator=noop",
|
cmdline: "debug elevator=noop",
|
||||||
disks: vec![],
|
disks: vec![],
|
||||||
|
vifs: vec![],
|
||||||
filesystems: vec![],
|
filesystems: vec![],
|
||||||
extra_keys: vec![],
|
extra_keys: vec![],
|
||||||
};
|
};
|
||||||
|
@ -48,6 +48,14 @@ pub struct DomainFilesystem<'a> {
|
|||||||
pub tag: &'a str,
|
pub tag: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct DomainNetworkInterface<'a> {
|
||||||
|
pub mac: &'a str,
|
||||||
|
pub mtu: u32,
|
||||||
|
pub bridge: &'a str,
|
||||||
|
pub script: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DomainConfig<'a> {
|
pub struct DomainConfig<'a> {
|
||||||
pub backend_domid: u32,
|
pub backend_domid: u32,
|
||||||
@ -58,6 +66,7 @@ pub struct DomainConfig<'a> {
|
|||||||
pub initrd_path: &'a str,
|
pub initrd_path: &'a str,
|
||||||
pub cmdline: &'a str,
|
pub cmdline: &'a str,
|
||||||
pub disks: Vec<DomainDisk<'a>>,
|
pub disks: Vec<DomainDisk<'a>>,
|
||||||
|
pub vifs: Vec<DomainNetworkInterface<'a>>,
|
||||||
pub filesystems: Vec<DomainFilesystem<'a>>,
|
pub filesystems: Vec<DomainFilesystem<'a>>,
|
||||||
pub extra_keys: Vec<(String, String)>,
|
pub extra_keys: Vec<(String, String)>,
|
||||||
}
|
}
|
||||||
@ -352,6 +361,7 @@ impl XenClient {
|
|||||||
disk,
|
disk,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index, filesystem) in config.filesystems.iter().enumerate() {
|
for (index, filesystem) in config.filesystems.iter().enumerate() {
|
||||||
self.fs_9p_device_add(
|
self.fs_9p_device_add(
|
||||||
&dom_path,
|
&dom_path,
|
||||||
@ -362,6 +372,17 @@ impl XenClient {
|
|||||||
filesystem,
|
filesystem,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (index, vif) in config.vifs.iter().enumerate() {
|
||||||
|
self.vif_device_add(
|
||||||
|
&dom_path,
|
||||||
|
&backend_dom_path,
|
||||||
|
config.backend_domid,
|
||||||
|
domid,
|
||||||
|
index,
|
||||||
|
vif,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
self.call.unpause_domain(domid)?;
|
self.call.unpause_domain(domid)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -493,6 +514,49 @@ impl XenClient {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn vif_device_add(
|
||||||
|
&mut self,
|
||||||
|
dom_path: &str,
|
||||||
|
backend_dom_path: &str,
|
||||||
|
backend_domid: u32,
|
||||||
|
domid: u32,
|
||||||
|
index: usize,
|
||||||
|
vif: &DomainNetworkInterface,
|
||||||
|
) -> Result<()> {
|
||||||
|
let id = 20 + index as u64;
|
||||||
|
let backend_items: Vec<(&str, String)> = vec![
|
||||||
|
("frontend-id", domid.to_string()),
|
||||||
|
("online", "1".to_string()),
|
||||||
|
("state", "1".to_string()),
|
||||||
|
("mac", vif.mac.to_string()),
|
||||||
|
("mtu", vif.mtu.to_string()),
|
||||||
|
("type", "vif".to_string()),
|
||||||
|
("bridge", vif.bridge.to_string()),
|
||||||
|
("handle", id.to_string()),
|
||||||
|
("script", vif.script.to_string()),
|
||||||
|
("hotplug-status", "".to_string()),
|
||||||
|
];
|
||||||
|
|
||||||
|
let frontend_items: Vec<(&str, String)> = vec![
|
||||||
|
("backend-id", backend_domid.to_string()),
|
||||||
|
("state", "1".to_string()),
|
||||||
|
("mac", vif.mac.to_string()),
|
||||||
|
("trusted", "1".to_string()),
|
||||||
|
];
|
||||||
|
|
||||||
|
self.device_add(
|
||||||
|
"vif",
|
||||||
|
id,
|
||||||
|
dom_path,
|
||||||
|
backend_dom_path,
|
||||||
|
backend_domid,
|
||||||
|
domid,
|
||||||
|
frontend_items,
|
||||||
|
backend_items,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn device_add(
|
fn device_add(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
Loading…
Reference in New Issue
Block a user