summary refs log tree commit diff
path: root/host/rootfs/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-06-24 13:19:08 +0000
committerAlyssa Ross <hi@alyssa.is>2024-02-23 15:28:00 +0100
commita2d362cf70ee73d0c0e96f0d86f8cb61b4596a0b (patch)
tree04b8afa29751c2480561581e1c4714751c2f5056 /host/rootfs/default.nix
parentbc1bcf6468072c00b3da0b6f23560f5060447705 (diff)
downloadspectrum-a2d362cf70ee73d0c0e96f0d86f8cb61b4596a0b.tar
spectrum-a2d362cf70ee73d0c0e96f0d86f8cb61b4596a0b.tar.gz
spectrum-a2d362cf70ee73d0c0e96f0d86f8cb61b4596a0b.tar.bz2
spectrum-a2d362cf70ee73d0c0e96f0d86f8cb61b4596a0b.tar.lz
spectrum-a2d362cf70ee73d0c0e96f0d86f8cb61b4596a0b.tar.xz
spectrum-a2d362cf70ee73d0c0e96f0d86f8cb61b4596a0b.tar.zst
spectrum-a2d362cf70ee73d0c0e96f0d86f8cb61b4596a0b.zip
host: allow VMs to be powered off
Before this change, the s6 services for cloud-hypervisor and virtiofsd
were only started when a VM was started, and vm-stop would bring the
service down.  The problem with this was that if a VM powered itself
off, instead of being stopped on the host using vm-stop, the VM would
instantly be restarted by s6.

To fix this, we disentangle keeping cloud-hypervisor running from
keeping the VM running.  cloud-hypervisor will now always be running,
so s6 will never restart it in normal operation, but it won't be
running a VM until it's told to.  Accomplishing this means having
start-vmm (renamed from start-vm to reflect its new purpose) configure
the VM in cloud-hypervisor without booting it, which is only possible
using the API, not the command line.  As a result, start-vm now
depends on miniserde so that it can construct the VM config JSON
object required by the API.

The build of start-vm has been adjusted to accomodate the complexity
stemming from the new dependencies.  Tests are moved into passthru,
because the start-vm used in Spectrum should have panic=abort, but
tests need panic=unwind, and we can't use both in the same Meson
instance without duplicating the non-native dependencies.

We can't use s6-rc dependencies to automatically boot provider VMs in
this setup, so vm-start has been modified to recurse into provider VMs.

lsvm has been updated to check the Cloud Hypervisor API to see whether
a VM is running, rather than just checking to see whether the s6
service is up.

Because cloud-hypervisor is now to be started as early as possible, we
need to make the dependencies of ext-rc-init more precise, so that
cloud-hypervisor does not attempt to start before /dev/kvm or
/dev/net/tun is available.

We're not using Meson's support for Cargo subprojects yet, because it
currently always builds crates with all features enabled.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
Diffstat (limited to 'host/rootfs/default.nix')
-rw-r--r--host/rootfs/default.nix4
1 files changed, 2 insertions, 2 deletions
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index 5bd2488..c6664bd 100644
--- a/host/rootfs/default.nix
+++ b/host/rootfs/default.nix
@@ -6,7 +6,7 @@ import ../../lib/call-package.nix (
 { callSpectrumPackage, lseek, src, pkgsMusl, pkgsStatic, linux_latest }:
 pkgsStatic.callPackage (
 
-{ start-vm
+{ start-vmm
 , lib, stdenvNoCC, nixos, runCommand, writeReferencesToFile, erofs-utils, s6-rc
 , busybox, cloud-hypervisor, cryptsetup, execline, e2fsprogs, jq, kmod
 , mdevd, s6, s6-linux-init, socat, util-linuxMinimal, virtiofsd, xorg
@@ -44,7 +44,7 @@ let
 
   packages = [
     cloud-hypervisor e2fsprogs execline jq kmod mdevd
-    s6 s6-linux-init s6-rc socat start-vm virtiofsd
+    s6 s6-linux-init s6-rc socat start-vmm virtiofsd
 
     (cryptsetup.override {
       programs = {