improve dev guide and validate guide steps

This commit is contained in:
Alex Zenla 2024-02-19 04:58:15 +00:00
parent 06561137fd
commit af50f1d996
No known key found for this signature in database
GPG Key ID: 067B238899B51269
4 changed files with 52 additions and 31 deletions

View File

@ -24,7 +24,7 @@ pvcalls is extremely interesting, and although it is certainly possible to utili
### Why is this prototype utilizing AGPL?
This repository is licensed under AGPL. This is because what is here is not intended for anything other than curiousity and research. Mycelium will utilize a different license for any production versions of hypha.
This repository is licensed under AGPL. This is because what is here is not intended for anything other than curiosity and research. Mycelium will utilize a different license for any production versions of hypha.
As such, no external contributions are accepted at this time.
@ -49,7 +49,7 @@ hypha is composed of three major executables:
| hyphactr | guest | none, guest init | N/A | container |
You will find the code to each executable available in the bin/ and src/ directories inside
it's coresponding code path from the above table.
it's corresponding code path from the above table.
### Environment
@ -58,31 +58,45 @@ it's coresponding code path from the above table.
| Architecture | x86_64 | aarch64 support requires minimal effort, but limited to x86 for research phase |
| Memory | At least 6GB | dom0 will need to be configured will lower memory limit to give hypha guests room |
| Xen | 4.17 | Temporary due to hardcoded interface version constants |
| Debian | sid / stable | Debian is recommended due to the ease of Xen setup |
| musl-gcc | any | hyphactr is built for musl to allow static linking, as initrd is a single file |
| Debian | stable / sid | Debian is recommended due to the ease of Xen setup |
| rustup | any | Install Rustup from https://rustup.rs |
### Setup
### Debian Setup
1. Install the specified Debian version on a x86_64 host _capable_ of KVM (NOTE: KVM is not used, Xen is a type-1 hypervisor).
2. Ensure you have installed Xen (apt install xen-system-amd64) and configure `/etc/default/grub.d/xen.cfg` to give hypha guests
some room:
2. Install required packages: `apt install git xen-system-amd64 flex bison libelf-dev libssl-dev bc`
3. Install [rustup](https://rustup.rs) for managing a Rust environment.
4. Configure `/etc/default/grub.d/xen.cfg` to give hypha guests some room:
```sh
# Configure dom0_mem to be 4GB, but leave the rest of the RAM for hypha guests.
GRUB_CMDLINE_XEN_DEFAULT="dom0_mem=4G,max:4G"
```
3. Build a guest kernel image:
After changing the grub config, update grub: `update-grub`
Then reboot to boot the system as a Xen dom0.
You can validate that Xen is setup by running `xl info` and ensuring it returns useful information about the Xen hypervisor.
5. Clone the hypha source code:
```sh
$ git clone https://github.com/mycelium-eng/hypha.git hypha
$ cd hypha
```
6. Build a guest kernel image:
```sh
$ ./kernel/build.sh -j4
```
4. Copy the guest kernel image at `kernel/target/kernel` to `/var/lib/hypha/default/kernel` to have it automatically detected by hyphactl.
5. Launch `./scripts/hyphanet-debug.sh` and keep it running in the foreground.
6. Run hyphactl to launch a container:
7. Copy the guest kernel image at `kernel/target/kernel` to `/var/lib/hypha/default/kernel` to have it automatically detected by hyphactl.
8. Launch `./scripts/hyphanet-debug.sh` and keep it running in the foreground.
9. Run hyphactl to launch a container:
```sh
$ ./scripts/hyphactl-debug.sh launch --attach mirror.gcr.io/library/alpine:latest /bin/busybox sh

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e
TARGET="x86_64-unknown-linux-musl"
TARGET="x86_64-unknown-linux-gnu"
export RUSTFLAGS="-Ctarget-feature=+crt-static"
cd "$(dirname "${0}")/.."

View File

@ -1,6 +1,6 @@
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 6.7.5 Kernel Configuration
# Linux/x86 6.7.3 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Debian 13.2.0-13) 13.2.0"
CONFIG_CC_IS_GCC=y
@ -120,6 +120,7 @@ CONFIG_BPF_JIT=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_BPF_JIT_DEFAULT_ON=y
CONFIG_BPF_UNPRIV_DEFAULT_OFF=y
CONFIG_USERMODE_DRIVER=y
# CONFIG_BPF_PRELOAD is not set
# CONFIG_BPF_LSM is not set
# end of BPF subsystem
@ -1199,8 +1200,9 @@ CONFIG_DEFAULT_CUBIC=y
# CONFIG_DEFAULT_RENO is not set
CONFIG_DEFAULT_TCP_CONG="cubic"
CONFIG_TCP_SIGPOOL=y
# CONFIG_TCP_AO is not set
CONFIG_TCP_MD5SIG=y
CONFIG_IPV6=m
CONFIG_IPV6=y
CONFIG_IPV6_ROUTER_PREF=y
CONFIG_IPV6_ROUTE_INFO=y
# CONFIG_IPV6_OPTIMISTIC_DAD is not set
@ -1237,7 +1239,7 @@ CONFIG_NET_PTP_CLASSIFY=y
CONFIG_NETWORK_PHY_TIMESTAMPING=y
CONFIG_NETFILTER=y
CONFIG_NETFILTER_ADVANCED=y
CONFIG_BRIDGE_NETFILTER=m
# CONFIG_BRIDGE_NETFILTER is not set
#
# Core Netfilter Configuration
@ -1245,7 +1247,7 @@ CONFIG_BRIDGE_NETFILTER=m
CONFIG_NETFILTER_INGRESS=y
CONFIG_NETFILTER_EGRESS=y
CONFIG_NETFILTER_SKIP_EGRESS=y
CONFIG_NETFILTER_NETLINK=m
CONFIG_NETFILTER_NETLINK=y
CONFIG_NETFILTER_FAMILY_BRIDGE=y
CONFIG_NETFILTER_FAMILY_ARP=y
CONFIG_NETFILTER_BPF_LINK=y
@ -1404,7 +1406,6 @@ CONFIG_NETFILTER_XT_MATCH_NFACCT=m
CONFIG_NETFILTER_XT_MATCH_OSF=m
CONFIG_NETFILTER_XT_MATCH_OWNER=m
CONFIG_NETFILTER_XT_MATCH_POLICY=m
CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
CONFIG_NETFILTER_XT_MATCH_QUOTA=m
CONFIG_NETFILTER_XT_MATCH_RATEEST=m
@ -1420,7 +1421,7 @@ CONFIG_NETFILTER_XT_MATCH_TIME=m
CONFIG_NETFILTER_XT_MATCH_U32=m
# end of Core Netfilter Configuration
CONFIG_IP_SET=m
CONFIG_IP_SET=y
CONFIG_IP_SET_MAX=256
CONFIG_IP_SET_BITMAP_IP=m
CONFIG_IP_SET_BITMAP_IPMAC=m
@ -1589,7 +1590,8 @@ CONFIG_BRIDGE_EBT_REDIRECT=m
CONFIG_BRIDGE_EBT_SNAT=m
CONFIG_BRIDGE_EBT_LOG=m
CONFIG_BRIDGE_EBT_NFLOG=m
# CONFIG_BPFILTER is not set
CONFIG_BPFILTER=y
CONFIG_BPFILTER_UMH=m
CONFIG_IP_DCCP=m
CONFIG_INET_DCCP_DIAG=m
@ -1624,18 +1626,18 @@ CONFIG_L2TP=m
CONFIG_L2TP_V3=y
CONFIG_L2TP_IP=m
CONFIG_L2TP_ETH=m
CONFIG_STP=m
CONFIG_MRP=m
CONFIG_BRIDGE=m
CONFIG_STP=y
CONFIG_MRP=y
CONFIG_BRIDGE=y
CONFIG_BRIDGE_IGMP_SNOOPING=y
CONFIG_BRIDGE_VLAN_FILTERING=y
# CONFIG_BRIDGE_MRP is not set
# CONFIG_BRIDGE_CFM is not set
# CONFIG_NET_DSA is not set
CONFIG_VLAN_8021Q=m
CONFIG_VLAN_8021Q=y
# CONFIG_VLAN_8021Q_GVRP is not set
CONFIG_VLAN_8021Q_MVRP=y
CONFIG_LLC=m
CONFIG_LLC=y
CONFIG_LLC2=m
# CONFIG_ATALK is not set
# CONFIG_X25 is not set
@ -1773,7 +1775,7 @@ CONFIG_NET_FLOW_LIMIT=y
# Network testing
#
CONFIG_NET_PKTGEN=m
# CONFIG_NET_DROP_MONITOR is not set
CONFIG_NET_DROP_MONITOR=y
# end of Network testing
# end of Networking options
@ -3360,6 +3362,7 @@ CONFIG_BCMA_POSSIBLE=y
# CONFIG_MFD_SM501 is not set
# CONFIG_MFD_SKY81452 is not set
# CONFIG_MFD_SYSCON is not set
# CONFIG_MFD_TI_AM335X_TSCADC is not set
# CONFIG_MFD_LP3943 is not set
# CONFIG_MFD_TI_LMU is not set
# CONFIG_TPS6105X is not set

View File

@ -676,13 +676,17 @@ impl XenClient {
pub fn open_console(&mut self, domid: u32) -> Result<(File, File)> {
let dom_path = self.store.get_domain_path(domid)?;
let console_tty_path = format!("{}/console/tty", dom_path);
let tty = self
.store
.read_string_optional(&console_tty_path)?
.unwrap_or("".to_string());
if tty.is_empty() {
return Err(Error::TtyNotFound);
let mut tty: Option<String> = None;
for _ in 0..5 {
tty = self.store.read_string_optional(&console_tty_path)?;
if tty.is_some() {
break;
}
thread::sleep(Duration::from_millis(200));
}
let Some(tty) = tty else {
return Err(Error::TtyNotFound);
};
let read = OpenOptions::new().read(true).write(false).open(&tty)?;
let write = OpenOptions::new().read(false).write(true).open(&tty)?;
Ok((read, write))