Skip to content

Commit

Permalink
Merge pull request #273 from stlankes/devel
Browse files Browse the repository at this point in the history
add KVM check
  • Loading branch information
stlankes authored Sep 22, 2023
2 parents b5a6957 + 84953e7 commit 9e9c1e3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@ jobs:
apt-get install -f -y cri-o cri-o-runc
crio config --default 1> /etc/crio/crio.conf
systemctl start crio.service
cat << END > /etc/crictl.yaml
runtime-endpoint: "unix:///var/run/crio/crio.sock"
image-endpoint: "unix:///var/run/crio/crio.sock"
timeout: 2
debug: false
END
- name: Install crictl
shell: sudo bash --noprofile --norc -eo pipefail {0}
run: apt-get install cri-tools
- name: Check CRI-O status
shell: sudo bash --noprofile --norc -eo pipefail {0}
run: systemctl status crio
run: |
systemctl status crio
sudo crictl version
- name: Pull images
run: |
docker pull ghcr.io/hermit-os/hermit_env:latest
Expand Down Expand Up @@ -82,7 +90,9 @@ jobs:
- name: Build runh
run: |
cargo install --locked --path .
sudo ln -s /home/runner/.cargo/bin/runh /bin/runh
sudo cp /home/runner/.cargo/bin/runh /usr/sbin/runh
sudo chown root:root /usr/sbin/runh
sudo chmod a+rx /usr/sbin/runh
- name: Setup runh with Docker
shell: sudo bash --noprofile --norc -eo pipefail {0}
run: |
Expand All @@ -95,7 +105,7 @@ jobs:
id: runh-crio-setup
shell: sudo bash --noprofile --norc -eo pipefail {0}
run: |
sed -i 's/\[crio.runtime.runtimes.runc\]/\[crio.runtime.runtimes.runh\]\nruntime_path = "\/home\/runner\/.cargo\/bin\/runh"\nruntime_type = "oci"\nruntime_root = "\/run\/runh"\n\n\[crio.runtime.runtimes.runc\]/g' /etc/crio/crio.conf
sed -i 's/\[crio.runtime.runtimes.runc\]/\[crio.runtime.runtimes.runh\]\nruntime_path = ""\nruntime_type = "oci"\nruntime_root = "\/run\/runh"\nprivileged_without_host_devices = false\n\n\[crio.runtime.runtimes.runc\]/g' /etc/crio/crio.conf
systemctl restart crio || systemctl status crio
>&2 cat /etc/crio/crio.conf
- name: Test runh standalone
Expand All @@ -117,6 +127,7 @@ jobs:
export PODID=$(cat pod.id)
crictl create $PODID /home/runner/container.json /home/runner/pod.json > container.id
export CONTAINERID=$(cat container.id)
echo "CONTAINERID: $CONTAINERID"
crictl start $CONTAINERID
sleep 5
crictl logs $CONTAINERID
Expand Down
15 changes: 9 additions & 6 deletions src/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,17 @@ pub fn create_tun(rootfs: &Path, uid: Uid, gid: Gid) {
}

pub fn mount_hermit_devices(rootfs: &Path) {
let kvm: u32 = std::env::var("RUNH_KVM")
.unwrap_or_else(|_| "0".to_string())
.parse()
.expect("RUNH_KVM was not an unsigned integer!");
if kvm > 0 {
if std::fs::metadata("/dev/kvm").is_ok() {
mount_device(rootfs, &PathBuf::from("/dev/kvm"), 10, 232);
} else {
warn!("/dev/kvm doesn't exist and is consequently not supported!");
}

if std::fs::metadata("/dev/vhost-net").is_ok() {
mount_device(rootfs, &PathBuf::from("/dev/vhost-net"), 10, 238);
} else {
warn!("/dev/vhost-net doesn't exist and is consequently not supported!");
}
mount_device(rootfs, &PathBuf::from("/dev/vhost-net"), 10, 238);
}

fn mount_device(rootfs: &Path, destination_rel: &Path, major: u64, minor: u64) {
Expand Down
4 changes: 2 additions & 2 deletions src/hermit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ pub fn get_qemu_args(
"1G",
"-serial",
"stdio",
"-device",
"isa-debug-exit,iobase=0xf4,iosize=0x04",
"-kernel",
kernel,
"-initrd",
Expand Down Expand Up @@ -99,8 +101,6 @@ pub fn get_qemu_args(
"virtio-mmio.force-legacy=off",
"-nodefaults",
"-no-user-config",
"-device",
"isa-debug-exit,iobase=0xf4,iosize=0x04",
]
.iter()
.map(|s| s.to_string())
Expand Down
8 changes: 2 additions & 6 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,8 @@ fn init_stage_child(args: SetupArgs) -> ! {
.to_owned();
let kernel_path = app_root.join("rusty-loader");
let kernel = kernel_path.as_os_str().to_str().unwrap();
let kvm: u32 = env::var("RUNH_KVM")
.unwrap_or_else(|_| "0".to_string())
.parse()
.expect("RUNH_KVM was not an unsigned integer!");
let micro_vm: u32 = env::var("RUNH_MICRO_VM")
.unwrap_or_else(|_| "1".to_string())
.unwrap_or_else(|_| "0".to_string())
.parse()
.expect("RUNH_MICRO_VM was not an unsigned integer!");

Expand Down Expand Up @@ -560,7 +556,7 @@ fn init_stage_child(args: SetupArgs) -> ! {
.as_ref()
.unwrap(),
micro_vm > 0,
kvm > 0,
std::fs::metadata("/dev/kvm").is_ok(),
&tap_fd,
)
} else {
Expand Down

0 comments on commit 9e9c1e3

Please sign in to comment.