diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-06-25 15:37:17 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2024-02-23 15:28:05 +0100 |
commit | 6d686439568acb41d92bceb8ad44276ffe1b3ca9 (patch) | |
tree | 7119fe86fe705533e53198c8152fdc245b9052c8 | |
parent | 4052b2283145e945d22ee74fb29725cf2a01a80a (diff) | |
download | spectrum-6d686439568acb41d92bceb8ad44276ffe1b3ca9.tar spectrum-6d686439568acb41d92bceb8ad44276ffe1b3ca9.tar.gz spectrum-6d686439568acb41d92bceb8ad44276ffe1b3ca9.tar.bz2 spectrum-6d686439568acb41d92bceb8ad44276ffe1b3ca9.tar.lz spectrum-6d686439568acb41d92bceb8ad44276ffe1b3ca9.tar.xz spectrum-6d686439568acb41d92bceb8ad44276ffe1b3ca9.tar.zst spectrum-6d686439568acb41d92bceb8ad44276ffe1b3ca9.zip |
host/rootfs: switch VMs to templated s6 services
Now that VMMs and vhost-user devices are started immediately, we don't need the complexity of s6-rc for them any more. VMMs still depend on the vhost-user sockets, but since those will be available almost immediately, it's fine to just wait for them in ext-rc-init. Since we're now using pure s6, we can use s6 instanced services for these, which cuts down a lot on how much work ext-rc-init's up script has to do directly, and provides some nice namespacing. Signed-off-by: Alyssa Ross <hi@alyssa.is>
35 files changed, 118 insertions, 71 deletions
diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile index fc61c09..c5e467d 100644 --- a/host/rootfs/Makefile +++ b/host/rootfs/Makefile @@ -23,25 +23,55 @@ FILES = \ etc/s6-linux-init/run-image/service/getty-tty3/run \ etc/s6-linux-init/run-image/service/getty-tty4/run \ etc/s6-linux-init/run-image/service/getty-ttyS0/run \ + etc/s6-linux-init/run-image/service/vhost-user-fs/notification-fd \ + etc/s6-linux-init/run-image/service/vhost-user-fs/run \ + etc/s6-linux-init/run-image/service/vhost-user-fs/template/notification-fd \ + etc/s6-linux-init/run-image/service/vhost-user-fs/template/run \ + etc/s6-linux-init/run-image/service/vhost-user-gpu/notification-fd \ + etc/s6-linux-init/run-image/service/vhost-user-gpu/run \ + etc/s6-linux-init/run-image/service/vhost-user-gpu/template/data/check \ + etc/s6-linux-init/run-image/service/vhost-user-gpu/template/notification-fd \ + etc/s6-linux-init/run-image/service/vhost-user-gpu/template/run \ + etc/s6-linux-init/run-image/service/vmm/notification-fd \ + etc/s6-linux-init/run-image/service/vmm/run \ + etc/s6-linux-init/run-image/service/vmm/template/notification-fd \ etc/s6-linux-init/scripts/rc.init \ - etc/template/fs/notification-fd \ - etc/template/fs/run \ - etc/template/fs/type \ - etc/template/gpu/data/check \ - etc/template/gpu/notification-fd \ - etc/template/gpu/run \ - etc/template/gpu/type \ + etc/shared-dir \ etc/xdg/weston/autolaunch \ etc/xdg/weston/weston.ini \ usr/bin/lsvm \ usr/bin/vm-console \ usr/bin/vm-start \ usr/bin/vm-stop -DIRS = dev etc/s6-linux-init/env etc/s6-linux-init/run-image/vm ext run proc sys + +DIRS = \ + dev \ + etc/s6-linux-init/env \ + etc/s6-linux-init/run-image/service/vhost-user-fs/instance \ + etc/s6-linux-init/run-image/service/vhost-user-fs/instances \ + etc/s6-linux-init/run-image/service/vhost-user-fs/template/data \ + etc/s6-linux-init/run-image/service/vhost-user-fs/template/env \ + etc/s6-linux-init/run-image/service/vhost-user-gpu/instance \ + etc/s6-linux-init/run-image/service/vhost-user-gpu/instances \ + etc/s6-linux-init/run-image/service/vhost-user-gpu/template/env \ + etc/s6-linux-init/run-image/service/vmm/instance \ + etc/s6-linux-init/run-image/service/vmm/instances \ + etc/s6-linux-init/run-image/service/vmm/template/data \ + etc/s6-linux-init/run-image/service/vmm/template/env \ + etc/s6-linux-init/run-image/vm \ + ext \ + run \ + proc \ + sys # These are separate because they need to be included, but putting # them as make dependencies would confuse make. -LINKS = bin etc/s6-linux-init/run-image/opengl-driver lib sbin +LINKS = \ + bin \ + etc/s6-linux-init/run-image/opengl-driver \ + etc/s6-linux-init/run-image/service/vmm/template/run \ + lib \ + sbin BUILD_FILES = build/etc/mdev/modalias.sh build/etc/s6-rc diff --git a/host/rootfs/etc/mdev/net/add b/host/rootfs/etc/mdev/net/add index 64d126c..52ccacf 100755 --- a/host/rootfs/etc/mdev/net/add +++ b/host/rootfs/etc/mdev/net/add @@ -31,8 +31,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-vm-netvm } + if { s6-svwait -U /run/service/vmm/instance/netvm } - ch-remote --api-socket /run/service/ext-vm-netvm/env/cloud-hypervisor.sock + ch-remote --api-socket /run/service/vmm/instance/netvm/env/cloud-hypervisor.sock add-device path=/sys${devpath} } diff --git a/host/rootfs/etc/template/fs/notification-fd b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/notification-fd index 00750ed..00750ed 100644 --- a/host/rootfs/etc/template/fs/notification-fd +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/notification-fd diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/notification-fd.license b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/notification-fd.license new file mode 100644 index 0000000..a941ca4 --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/notification-fd.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: CC0-1.0 +SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/run b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/run new file mode 100755 index 0000000..9041788 --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/run @@ -0,0 +1,5 @@ +#!/bin/execlineb -P +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> + +s6-svscan -d3 instance diff --git a/host/rootfs/etc/template/gpu/notification-fd b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/notification-fd index 00750ed..00750ed 100644 --- a/host/rootfs/etc/template/gpu/notification-fd +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/notification-fd diff --git a/host/rootfs/etc/template/fs/notification-fd.license b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/notification-fd.license index 5a40633..5a40633 100644 --- a/host/rootfs/etc/template/fs/notification-fd.license +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/notification-fd.license diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/run b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/run new file mode 100755 index 0000000..c055cc0 --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/run @@ -0,0 +1,12 @@ +#!/bin/execlineb -S1 +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is> + +s6-ipcserver-socketbinder -a 0700 -B env/virtiofsd.sock + +if { fdmove 1 3 echo } +fdclose 3 + +export TMPDIR /run +backtick -E shared_dir { /etc/shared-dir -v servicename=${1} } +virtiofsd --fd 0 --shared-dir $shared_dir diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/notification-fd b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/notification-fd @@ -0,0 +1 @@ +3 diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/notification-fd.license b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/notification-fd.license new file mode 100644 index 0000000..a941ca4 --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/notification-fd.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: CC0-1.0 +SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/run b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/run new file mode 100755 index 0000000..9041788 --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/run @@ -0,0 +1,5 @@ +#!/bin/execlineb -P +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> + +s6-svscan -d3 instance diff --git a/host/rootfs/etc/template/gpu/data/check b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/data/check index 113dcf0..113dcf0 100755 --- a/host/rootfs/etc/template/gpu/data/check +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/data/check diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/notification-fd b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/notification-fd @@ -0,0 +1 @@ +3 diff --git a/host/rootfs/etc/template/gpu/notification-fd.license b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/notification-fd.license index 2241beb..2241beb 100644 --- a/host/rootfs/etc/template/gpu/notification-fd.license +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/notification-fd.license diff --git a/host/rootfs/etc/template/gpu/run b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/run index eaac8d6..eaac8d6 100755 --- a/host/rootfs/etc/template/gpu/run +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/run diff --git a/host/rootfs/etc/template/fs/type b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/type index 5883cff..5883cff 100644 --- a/host/rootfs/etc/template/fs/type +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/type diff --git a/host/rootfs/etc/template/gpu/type.license b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/type.license index 2241beb..2241beb 100644 --- a/host/rootfs/etc/template/gpu/type.license +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-gpu/template/type.license diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vmm/notification-fd b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/notification-fd @@ -0,0 +1 @@ +3 diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vmm/notification-fd.license b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/notification-fd.license new file mode 100644 index 0000000..a941ca4 --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/notification-fd.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: CC0-1.0 +SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vmm/run b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/run new file mode 100755 index 0000000..9041788 --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/run @@ -0,0 +1,5 @@ +#!/bin/execlineb -P +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> + +s6-svscan -d3 instance diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vmm/template/notification-fd b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/template/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/template/notification-fd @@ -0,0 +1 @@ +3 diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vmm/template/notification-fd.license b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/template/notification-fd.license new file mode 100644 index 0000000..a941ca4 --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/template/notification-fd.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: CC0-1.0 +SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vmm/template/run b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/template/run new file mode 120000 index 0000000..5438b0a --- /dev/null +++ b/host/rootfs/etc/s6-linux-init/run-image/service/vmm/template/run @@ -0,0 +1 @@ +/bin/start-vmm \ No newline at end of file diff --git a/host/rootfs/etc/s6-rc/ext-rc-init/up b/host/rootfs/etc/s6-rc/ext-rc-init/up index 527ba3f..0214759 100644 --- a/host/rootfs/etc/s6-rc/ext-rc-init/up +++ b/host/rootfs/etc/s6-rc/ext-rc-init/up @@ -2,48 +2,34 @@ # SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is> # SPDX-FileCopyrightText: 2022 Unikie -if { mkdir -p /run/s6-rc.ext.src/ok-vmm/contents.d } -if { redirfd -w 1 /run/s6-rc.ext.src/ok-vmm/type echo bundle } -cd /run/s6-rc.ext.src +cd /ext/svc/data +elglob -0 names * if { - elglob -0 dirs /ext/svc/data/*/ - forx -po0 -E dir { $dirs } - backtick -E name { basename -- $dir } + forx -po0 -E name { $names } if { mkdir /run/vm/${name} } - if { ln -s $dir /run/vm/${name}/config } - - if { mkdir vm-${name} vm-${name}/dependencies.d vm-${name}/env } - if { redirfd -w 1 vm-${name}/type echo longrun } - if { redirfd -w 1 vm-${name}/notification-fd echo 3 } - if { redirfd -w 1 vm-${name}/run printf "#!/bin/execlineb -P\n/bin/start-vmm" } - if { chmod +x vm-${name}/run } - if { touch ok-vmm/contents.d/vm-${name} } + if { ln -s /ext/svc/data/${name} /run/vm/${name}/config } if { - elglob -0 paths ${dir}/shared-dirs/* - forx -po0 -E path { $paths } - backtick -E fsname { basename -- $path } - if { cp -R /etc/template/fs fs-${name}:${fsname} } - if { mkdir fs-${name}:${fsname}/data fs-${name}:${fsname}/env } - if { cp -P ${path}/dir fs-${name}:${fsname}/data/shared-dir } - touch vm-${name}/dependencies.d/fs-${name}:${fsname} + if -t { test -e ${name}/shared-dirs } + cd ${name}/shared-dirs + elglob -0 fsnames * + + if { + forx -po0 -E fsname { $fsnames } + s6-instance-create /run/service/vhost-user-fs ${name}:${fsname} + } + s6-svwait -U /run/service/vhost-user-fs/instance/${name}:${fsnames} } if { - if -t { test -e ${dir}/wayland } - if { cp -R -- /etc/template/gpu gpu-${name} } - if { mkdir -- gpu-${name}/env } - touch -- vm-${name}/dependencies.d/gpu-${name} + if -t { test -e ${name}/wayland } + if { s6-instance-create /run/service/vhost-user-gpu $name } + s6-svwait -U /run/service/vhost-user-gpu/instance/${name} } - elglob -0 paths /ext/svc/data/${name}/providers/net/* - forx -po0 -E path { $paths } - backtick -E dep { basename -- $path } - touch vm-${name}/dependencies.d/vm-${dep} + s6-instance-create /run/service/vmm $name } -if { s6-rc-compile /run/s6-rc.ext.db /run/s6-rc.ext.src } -if { s6-rc-init -c /run/s6-rc.ext.db -l /run/s6-rc.ext -p ext- /run/service } -s6-rc -ul /run/s6-rc.ext change ok-vmm +s6-svwait -U /run/service/vmm/instance/${names} diff --git a/host/rootfs/etc/shared-dir b/host/rootfs/etc/shared-dir new file mode 100755 index 0000000..9c9cf4b --- /dev/null +++ b/host/rootfs/etc/shared-dir @@ -0,0 +1,10 @@ +#!/bin/awk -f +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> + +# Usage: /etc/shared-dir -v servicename=[servicename] + +BEGIN { + split(servicename, names, ":") + print("/ext/svc/data/" names[1] "/shared-dirs/" names[2] "/dir") +} diff --git a/host/rootfs/etc/template/fs/run b/host/rootfs/etc/template/fs/run deleted file mode 100755 index 5ca214a..0000000 --- a/host/rootfs/etc/template/fs/run +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/execlineb -P -# SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> - -s6-ipcserver-socketbinder -a 0700 -B env/virtiofsd.sock - -if { fdmove 1 3 echo } -fdclose 3 - -export TMPDIR /run -virtiofsd --fd 0 --shared-dir data/shared-dir diff --git a/host/rootfs/etc/template/fs/type.license b/host/rootfs/etc/template/fs/type.license deleted file mode 100644 index 5a40633..0000000 --- a/host/rootfs/etc/template/fs/type.license +++ /dev/null @@ -1,2 +0,0 @@ -SPDX-License-Identifier: CC0-1.0 -SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is> diff --git a/host/rootfs/etc/template/gpu/type b/host/rootfs/etc/template/gpu/type deleted file mode 100644 index 5883cff..0000000 --- a/host/rootfs/etc/template/gpu/type +++ /dev/null @@ -1 +0,0 @@ -longrun diff --git a/host/rootfs/usr/bin/lsvm b/host/rootfs/usr/bin/lsvm index a2b2b2b..a9b25ce 100755 --- a/host/rootfs/usr/bin/lsvm +++ b/host/rootfs/usr/bin/lsvm @@ -11,7 +11,7 @@ if -n { redirfd -w 2 /dev/null backtick -E state { pipeline -w { jq -r .state } - ch-remote --api-socket /run/service/ext-vm-${vm}/env/cloud-hypervisor.sock info + ch-remote --api-socket /run/service/vmm/instance/${vm}/env/cloud-hypervisor.sock info } case -s $state { Created { echo "[31mSTOPPED[0m" } diff --git a/host/rootfs/usr/bin/vm-console b/host/rootfs/usr/bin/vm-console index 00d823c..0f850be 100755 --- a/host/rootfs/usr/bin/vm-console +++ b/host/rootfs/usr/bin/vm-console @@ -4,7 +4,7 @@ backtick -E pty { pipeline -w { jq -r .config.console.file } - ch-remote --api-socket /run/service/ext-vm-${1}/env/cloud-hypervisor.sock info + ch-remote --api-socket /run/service/vmm/instance/${1}/env/cloud-hypervisor.sock info } foreground { diff --git a/host/rootfs/usr/bin/vm-start b/host/rootfs/usr/bin/vm-start index effc65d..81437a2 100755 --- a/host/rootfs/usr/bin/vm-start +++ b/host/rootfs/usr/bin/vm-start @@ -12,4 +12,4 @@ foreground { vm-start $provider } -ch-remote --api-socket /run/service/ext-vm-${1}/env/cloud-hypervisor.sock boot +ch-remote --api-socket /run/service/vmm/instance/${1}/env/cloud-hypervisor.sock boot diff --git a/host/rootfs/usr/bin/vm-stop b/host/rootfs/usr/bin/vm-stop index db2e9f3..61b5a11 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: 2023 Alyssa Ross <hi@alyssa.is> -ch-remote --api-socket /run/service/ext-vm-${1}/env/cloud-hypervisor.sock shutdown +ch-remote --api-socket /run/service/vmm/instance/${1}/env/cloud-hypervisor.sock shutdown diff --git a/host/start-vmm/ch.rs b/host/start-vmm/ch.rs index 0ef1354..cc05d84 100644 --- a/host/start-vmm/ch.rs +++ b/host/start-vmm/ch.rs @@ -73,7 +73,7 @@ pub struct VmConfig { } fn command(vm_name: &str, s: impl AsRef<OsStr>) -> Command { - let mut api_socket_path = OsString::from("/run/service/ext-vm-"); + let mut api_socket_path = OsString::from("/run/service/vmm/instance/"); api_socket_path.push(vm_name); api_socket_path.push("/env/cloud-hypervisor.sock"); diff --git a/host/start-vmm/lib.rs b/host/start-vmm/lib.rs index 34d385b..837e3d5 100644 --- a/host/start-vmm/lib.rs +++ b/host/start-vmm/lib.rs @@ -116,7 +116,7 @@ pub fn vm_config(vm_name: &str, config_root: &Path) -> Result<VmConfig, String> Ok(FsConfig { tag: entry.to_string(), - socket: format!("../fs-{vm_name}:{entry}/env/virtiofsd.sock"), + socket: format!("/run/service/vhost-user-fs/instance/{vm_name}:{entry}/env/virtiofsd.sock"), }) }) .collect::<Result<_, String>>()?, @@ -125,7 +125,7 @@ pub fn vm_config(vm_name: &str, config_root: &Path) -> Result<VmConfig, String> }, gpu: match wayland_path.try_exists() { Ok(true) => vec![GpuConfig { - socket: format!("../gpu-{vm_name}/env/crosvm.sock"), + socket: format!("/run/service/vhost-user-gpu/instance/{vm_name}/env/crosvm.sock"), }], Ok(false) => vec![], Err(e) => return Err(format!("checking for existence of {:?}: {e}", wayland_path)), @@ -203,15 +203,10 @@ pub fn create_vm(dir: &Path, config_root: &Path) -> Result<(), String> { .to_str() .ok_or_else(|| format!("VM name {:?} is not valid UTF-8", vm_name))?; - if !vm_name.starts_with("vm-") { - return Err("not running from a VM service directory".to_string()); - } - if vm_name.contains(':') { return Err(format!("VM name may not contain a colon: {:?}", vm_name)); } - let vm_name = &vm_name[3..]; let config = vm_config(vm_name, config_root)?; // SAFETY: safe because we ensure we don't violate any invariants @@ -239,7 +234,7 @@ mod tests { #[test] fn test_vm_name_colon() { - let e = create_vm(Path::new("/vm-:"), Path::new("/")).unwrap_err(); + let e = create_vm(Path::new("/:vm"), Path::new("/")).unwrap_err(); assert!(e.contains("colon"), "unexpected error: {:?}", e); } } diff --git a/host/start-vmm/tests/vm_command-shared-dir.rs b/host/start-vmm/tests/vm_command-shared-dir.rs index 7da7843..d446d5f 100644 --- a/host/start-vmm/tests/vm_command-shared-dir.rs +++ b/host/start-vmm/tests/vm_command-shared-dir.rs @@ -41,7 +41,7 @@ fn main() -> std::io::Result<()> { assert_eq!(actual_tags, expected_tags); let expected_sockets = (1..=2) - .map(|i| format!("../fs-testvm:dir{i}/env/virtiofsd.sock")) + .map(|i| format!("/run/service/vhost-user-fs/instance/testvm:dir{i}/env/virtiofsd.sock")) .collect(); assert_eq!(actual_sockets, expected_sockets); |