Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dac80b487 | ||
|
|
aa4bc0401b |
No files matched your search
+1
-7
@@ -245,13 +245,7 @@ fn setup_virtiofs_shares(workdir: &str) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try_io(&format!("mkdir {dest}"), || fs::create_dir_all(&dest));
|
try_io(&format!("mkdir {dest}"), || fs::create_dir_all(&dest));
|
||||||
try_mount(
|
try_mount(Some(tag), &dest, Some("virtiofs"), MsFlags::empty(), None);
|
||||||
Some(tag),
|
|
||||||
&dest,
|
|
||||||
Some("virtiofs"),
|
|
||||||
MsFlags::empty(),
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-13
@@ -1,13 +1,4 @@
|
|||||||
//! QEMU: boot a registry entry with qemu-system-x86_64 using direct kernel
|
//! See [`boot`]
|
||||||
//! boot (-kernel/-initrd or -drive). The kernel is shared across all VMs
|
|
||||||
//! at $XDG_DATA_HOME/boco/registry/vmlinuz. A universal /boco/init script (injected
|
|
||||||
//! at build time) handles VM bootstrap; /boco/exec runs the container's
|
|
||||||
//! CMD/ENTRYPOINT. Runtime overrides are delivered as `boco.cmd=<base64>`
|
|
||||||
//! on the kernel cmdline. Host directories are shared into the guest via
|
|
||||||
//! virtio-fs: one virtiofsd daemon (under `podman unshare` for rootless
|
|
||||||
//! UID mapping) per `--mount`, plus a `-chardev socket` + `-device
|
|
||||||
//! vhost-user-fs-pci` pair on the QEMU side. The guest mounts each share
|
|
||||||
//! with `mount -t virtiofs <tag> <dest>` (see `boco.mount=` cmdline).
|
|
||||||
|
|
||||||
use anyhow::{Context, Result, bail};
|
use anyhow::{Context, Result, bail};
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
@@ -16,7 +7,7 @@ use std::{fmt::Write as _, process::Command};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
forward::PortForward,
|
forward::PortForward,
|
||||||
registry::{registry_base_dir, registry_dir},
|
registry::{registry_dir, vmlinuz_path},
|
||||||
virtiofs::{self, VirtiofsShare},
|
virtiofs::{self, VirtiofsShare},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -46,6 +37,10 @@ pub struct BootCmd {
|
|||||||
mount: Vec<String>,
|
mount: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Invoke `qemu` to boot a boco image. See [`BootCmd`] for options
|
||||||
|
///
|
||||||
|
/// This uses qemu's direct-kernel-boot with `-kernel`, so it does not require a bootloader.
|
||||||
|
/// The boco image is just an ext4 rootfs.
|
||||||
pub(crate) fn boot(
|
pub(crate) fn boot(
|
||||||
BootCmd {
|
BootCmd {
|
||||||
name,
|
name,
|
||||||
@@ -56,13 +51,13 @@ pub(crate) fn boot(
|
|||||||
}: BootCmd,
|
}: BootCmd,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let reg_dir = registry_dir(&name)?;
|
let reg_dir = registry_dir(&name)?;
|
||||||
let vmlinuz_path = registry_base_dir()?.join("vmlinuz");
|
let vmlinuz_path = vmlinuz_path()?;
|
||||||
let initrd_path = reg_dir.join("initrd");
|
let initrd_path = reg_dir.join("initrd");
|
||||||
let qcow2_path = reg_dir.join("image.qcow2");
|
let qcow2_path = reg_dir.join("image.qcow2");
|
||||||
if !vmlinuz_path.exists() {
|
if !vmlinuz_path.exists() {
|
||||||
// TODO: guide user in how to set up a kernel
|
// TODO: guide user in how to set up a kernel
|
||||||
bail!(
|
bail!(
|
||||||
"No kernel available. Place a vmlinuz at {}",
|
"No kernel available. Expected vmlinuz at {}",
|
||||||
vmlinuz_path.display()
|
vmlinuz_path.display()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ pub(crate) fn validate_image_name(name: &str) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn vmlinuz_path() -> Result<PathBuf> {
|
||||||
|
let base = xdg::BaseDirectories::with_prefix("boco");
|
||||||
|
base.place_data_file("vmlinuz")
|
||||||
|
.context("Failed to create XDG_DATA_HOME subdirectory")
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn registry_base_dir() -> Result<PathBuf> {
|
pub(crate) fn registry_base_dir() -> Result<PathBuf> {
|
||||||
let base = xdg::BaseDirectories::with_prefix("boco");
|
let base = xdg::BaseDirectories::with_prefix("boco");
|
||||||
base.create_data_directory("registry")
|
base.create_data_directory("registry")
|
||||||
|
|||||||
Reference in new issue
Block a user