From a2d362cf70ee73d0c0e96f0d86f8cb61b4596a0b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 24 Jun 2023 13:19:08 +0000 Subject: 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 --- release/checks/pkg-tests.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'release/checks') diff --git a/release/checks/pkg-tests.nix b/release/checks/pkg-tests.nix index f51ba42..7a41e8d 100644 --- a/release/checks/pkg-tests.nix +++ b/release/checks/pkg-tests.nix @@ -2,14 +2,14 @@ # SPDX-FileCopyrightText: 2023 Alyssa Ross import ../../lib/call-package.nix ( -{ callSpectrumPackage, lseek, start-vm, lib }: +{ callSpectrumPackage, lseek, start-vmm, lib }: { recurseForDerivations = true; lseek = lib.recurseIntoAttrs lseek.tests; - start-vm = lib.recurseIntoAttrs start-vm.tests; + start-vmm = lib.recurseIntoAttrs start-vmm.tests; run-spectrum-vm = lib.recurseIntoAttrs (callSpectrumPackage ../../scripts/run-spectrum-vm.nix {}).tests; -- cgit 1.4.1