summary refs log tree commit diff
path: root/host
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-02-19 15:58:07 +0000
committerAlyssa Ross <hi@alyssa.is>2022-02-19 15:58:07 +0000
commit58204aedb6ec5a2e4e7bb79cca33eef1d672f476 (patch)
treec9dfaaa2f38e7e5f841be57cea95c96bd0623a3e /host
parent50917fa16aa1984295be080d195792ef8b660b2a (diff)
downloadspectrum-58204aedb6ec5a2e4e7bb79cca33eef1d672f476.tar
spectrum-58204aedb6ec5a2e4e7bb79cca33eef1d672f476.tar.gz
spectrum-58204aedb6ec5a2e4e7bb79cca33eef1d672f476.tar.bz2
spectrum-58204aedb6ec5a2e4e7bb79cca33eef1d672f476.tar.lz
spectrum-58204aedb6ec5a2e4e7bb79cca33eef1d672f476.tar.xz
spectrum-58204aedb6ec5a2e4e7bb79cca33eef1d672f476.tar.zst
spectrum-58204aedb6ec5a2e4e7bb79cca33eef1d672f476.zip
host/rootfs: don't autostart VM consoles
Aside from the experience benefit of not popping the netvm console
open when it's not required, this also simplifies the implementation a
lot, because it means each VM only has to be a single service.
Diffstat (limited to 'host')
-rw-r--r--host/rootfs/Makefile2
-rwxr-xr-xhost/rootfs/etc/graphical-console18
-rwxr-xr-xhost/rootfs/etc/mdev/net/add4
-rw-r--r--host/rootfs/etc/s6-rc/ext-rc-init/up25
-rwxr-xr-xhost/rootfs/usr/bin/lsvm4
-rwxr-xr-xhost/rootfs/usr/bin/vm-console10
-rwxr-xr-xhost/rootfs/usr/bin/vm-stop2
-rw-r--r--host/start-vm/ch.rs2
-rw-r--r--host/start-vm/start-vm.rs3
9 files changed, 25 insertions, 45 deletions
diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile
index 4fe23d6..87bc15e 100644
--- a/host/rootfs/Makefile
+++ b/host/rootfs/Makefile
@@ -16,7 +16,6 @@ build/rootfs.ext4: build/rootfs.tar
 FILES = \
 	etc/fonts/fonts.conf \
 	etc/fstab \
-	etc/graphical-console \
 	etc/group \
 	etc/init \
 	etc/login \
@@ -35,6 +34,7 @@ FILES = \
 	etc/xdg/weston/autolaunch \
 	etc/xdg/weston/weston.ini \
 	usr/bin/lsvm \
+	usr/bin/vm-console \
 	usr/bin/vm-start \
 	usr/bin/vm-stop
 
diff --git a/host/rootfs/etc/graphical-console b/host/rootfs/etc/graphical-console
deleted file mode 100755
index 94a6726..0000000
--- a/host/rootfs/etc/graphical-console
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/execlineb -P
-# SPDX-License-Identifier: EUPL-1.2
-# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
-
-export WAYLAND_DISPLAY wayland-1
-export XDG_RUNTIME_DIR /run/user/0
-
-backtick -E name {
-  backtick -E pwd { pwd }
-  basename $pwd
-}
-
-backtick -E pty {
-  pipeline -w { jq -r .config.console.file }
-  ch-remote --api-socket ../${name}-vmm/env/cloud-hypervisor.sock info
-}
-
-foot -T $name --pty $pty
diff --git a/host/rootfs/etc/mdev/net/add b/host/rootfs/etc/mdev/net/add
index e7a5fab..959d73a 100755
--- a/host/rootfs/etc/mdev/net/add
+++ b/host/rootfs/etc/mdev/net/add
@@ -34,8 +34,8 @@ foreground {
 background {
   # Wait for the VM to be up.
   foreground { s6-rc -bu change ext-rc-init }
-  if { s6-svwait -U /run/service/ext-netvm-vmm }
+  if { s6-svwait -U /run/service/ext-netvm }
 
-  ch-remote --api-socket /run/service/ext-netvm-vmm/env/cloud-hypervisor.sock
+  ch-remote --api-socket /run/service/ext-netvm/env/cloud-hypervisor.sock
     add-device path=/sys${devpath}
 }
diff --git a/host/rootfs/etc/s6-rc/ext-rc-init/up b/host/rootfs/etc/s6-rc/ext-rc-init/up
index 80cf932..8fcbd1d 100644
--- a/host/rootfs/etc/s6-rc/ext-rc-init/up
+++ b/host/rootfs/etc/s6-rc/ext-rc-init/up
@@ -10,24 +10,15 @@ if {
 
   cd /run/s6-rc.ext.src
 
-  if {
-    mkdir -- $name ${name}/dependencies.d ${name}-vmm ${name}-vmm/dependencies.d
-      ${name}-vmm/env
-  }
-  if { redirfd -w 1 ${name}-vmm/type echo longrun }
-  if { redirfd -w 1 ${name}-vmm/notification-fd echo 3 }
-  if { ln -s -- /bin/start-vm ${name}-vmm/run }
-
-  if {
-    elglob -0 paths /ext/svc/data/${name}/providers/net/*
-    forx -pE path { $paths }
-    backtick -E dep { basename -- $path }
-    touch -- ${name}-vmm/dependencies.d/${dep}
-  }
-
+  if { mkdir -- ${name} ${name}/dependencies.d ${name}/env }
   if { redirfd -w 1 ${name}/type echo longrun }
-  if { ln -s -- /etc/graphical-console ${name}/run }
-  if { touch -- ${name}/dependencies.d/${name}-vmm }
+  if { redirfd -w 1 ${name}/notification-fd echo 3 }
+  if { ln -s -- /bin/start-vm ${name}/run }
+
+  elglob -0 paths /ext/svc/data/${name}/providers/net/*
+  forx -pE path { $paths }
+  backtick -E dep { basename -- $path }
+  touch -- ${name}/dependencies.d/${dep}
 }
 
 if { s6-rc-compile /run/s6-rc.ext.db /run/s6-rc.ext.src }
diff --git a/host/rootfs/usr/bin/lsvm b/host/rootfs/usr/bin/lsvm
index 4f7cfcb..8198752 100755
--- a/host/rootfs/usr/bin/lsvm
+++ b/host/rootfs/usr/bin/lsvm
@@ -11,7 +11,7 @@ if { printf "%-20s\t" $vm }
 ifte {
   ifte { echo "STOPPED" }
   { echo "RUNNING" }
-  test -f /run/service/ext-${vm}-vmm/down
+  test -f /run/service/ext-${vm}/down
 }
 { echo "UNKNOWN" }
-test -d /run/service/ext-${vm}-vmm
+test -d /run/service/ext-${vm}
diff --git a/host/rootfs/usr/bin/vm-console b/host/rootfs/usr/bin/vm-console
new file mode 100755
index 0000000..47a5d63
--- /dev/null
+++ b/host/rootfs/usr/bin/vm-console
@@ -0,0 +1,10 @@
+#!/bin/execlineb -S1
+# SPDX-License-Identifier: EUPL-1.2
+# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
+
+backtick -E pty {
+  pipeline -w { jq -r .config.console.file }
+  ch-remote --api-socket /run/service/ext-${1}/env/cloud-hypervisor.sock info
+}
+
+foot -T $1 --pty $pty
diff --git a/host/rootfs/usr/bin/vm-stop b/host/rootfs/usr/bin/vm-stop
index b39bc3b..a7ab970 100755
--- a/host/rootfs/usr/bin/vm-stop
+++ b/host/rootfs/usr/bin/vm-stop
@@ -2,4 +2,4 @@
 # SPDX-License-Identifier: EUPL-1.2
 # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
 
-s6-rc -l /run/s6-rc.ext -d change ${1}-vmm
+s6-rc -l /run/s6-rc.ext -d change $1
diff --git a/host/start-vm/ch.rs b/host/start-vm/ch.rs
index 04da710..7cba50e 100644
--- a/host/start-vm/ch.rs
+++ b/host/start-vm/ch.rs
@@ -16,7 +16,7 @@ const EPROTO: NonZeroI32 = unsafe { NonZeroI32::new_unchecked(71) };
 fn command(vm_name: &OsStr, s: impl AsRef<OsStr>) -> Command {
     let mut api_socket_path = OsString::from("/run/service/ext-");
     api_socket_path.push(vm_name);
-    api_socket_path.push("-vmm/env/cloud-hypervisor.sock");
+    api_socket_path.push("/env/cloud-hypervisor.sock");
 
     let mut command = Command::new("ch-remote");
     command.stdin(Stdio::null());
diff --git a/host/start-vm/start-vm.rs b/host/start-vm/start-vm.rs
index a68a669..26dd6e8 100644
--- a/host/start-vm/start-vm.rs
+++ b/host/start-vm/start-vm.rs
@@ -45,9 +45,6 @@ fn main() {
         .into_os_string()
         .into_vec();
 
-    if dir.ends_with(b"-vmm") && !dir.ends_with(b"/-vmm") {
-        dir.truncate(dir.len() - b"-vmm".len());
-    }
     let dir = PathBuf::from(OsString::from_vec(dir));
 
     let vm_name = dir