1 parent
8ad6754328
commit
aa4bc0401b
2 files changed
+14
-13
No files matched your search
+8
-13
@@ -1,13 +1,4 @@
|
||||
//! QEMU: boot a registry entry with qemu-system-x86_64 using direct kernel
|
||||
//! 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).
|
||||
//! See [`boot`]
|
||||
|
||||
use anyhow::{Context, Result, bail};
|
||||
use base64::Engine;
|
||||
@@ -16,7 +7,7 @@ use std::{fmt::Write as _, process::Command};
|
||||
|
||||
use crate::{
|
||||
forward::PortForward,
|
||||
registry::{registry_base_dir, registry_dir},
|
||||
registry::{registry_dir, vmlinuz_path},
|
||||
virtiofs::{self, VirtiofsShare},
|
||||
};
|
||||
|
||||
@@ -46,6 +37,10 @@ pub struct BootCmd {
|
||||
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(
|
||||
BootCmd {
|
||||
name,
|
||||
@@ -56,13 +51,13 @@ pub(crate) fn boot(
|
||||
}: BootCmd,
|
||||
) -> Result<()> {
|
||||
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 qcow2_path = reg_dir.join("image.qcow2");
|
||||
if !vmlinuz_path.exists() {
|
||||
// TODO: guide user in how to set up a kernel
|
||||
bail!(
|
||||
"No kernel available. Place a vmlinuz at {}",
|
||||
"No kernel available. Expected vmlinuz at {}",
|
||||
vmlinuz_path.display()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,12 @@ pub(crate) fn validate_image_name(name: &str) -> Result<()> {
|
||||
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> {
|
||||
let base = xdg::BaseDirectories::with_prefix("boco");
|
||||
base.create_data_directory("registry")
|
||||
|
||||
Reference in new issue
Block a user