From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id AEDEE56C44; Fri, 21 Jul 2023 18:01:07 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 5E24556C31; Fri, 21 Jul 2023 18:01:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by atuin.qyliss.net (Postfix) with ESMTPS id 9025756B7A for ; Fri, 21 Jul 2023 18:01:01 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 3469A320092A for ; Fri, 21 Jul 2023 14:01:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 21 Jul 2023 14:01:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1689962459; x= 1690048859; bh=aKkLgrC4jgMXE4eNy41uyFSsxx4Ems5YmKYfwIj/YZg=; b=g LruQdRcKOhoNOzdchuuBreISKs8GsAgAG/soV6GV2DdfZY7ixD29UIwYU6nIfRNY Aa0hVvFCLg4PL+vpTSjEILYIsPzh9Y0cniBUH8UNssUGGIMUBZX0ppKnzXaC6Od9 l+eQ4k3/1FIgQjKYKj8nBikQe1G6sj2r5rv2f7j4HawCpUopzux5gSf5n3nEmbtU JALeJTZK4numw79k1+y70zI/OROs0vWMC/I2I8IrnqhNewpZU2qICysDpViO3gUQ oXm8Cix+hS+u0UGCIpqbKZDYpMvc5JGRWQkkjavvyNx+7/ccAA/P/UCVNRN0yKEY Ypj8DGajkgk0phaarGdIQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1689962459; x=1690048859; bh=a KkLgrC4jgMXE4eNy41uyFSsxx4Ems5YmKYfwIj/YZg=; b=3cge79E1sZX+IWCaj NQntyh+OEVmmh3Rh9FVtWgOgedEyVntI5OWjhjfb/goYeQHYgmdxDtcR09pwK9xb Pu5CpMWDmYgOTvZANregnMV4ZHhGM8uRFyAGaRCZN8S6hIuNZ+wt2Y0Ry8/KcNke sokyE4WQ65VYdldaeNJjsFJ2HdZs1XkcYkJGWMj7UPfXF4BFpAw5zbUCHfHNp4T1 50sko44zyMtDvr7/dvPPKR2EeL2YAA2kUPMRBT+hPPtdvXzMf0pvrM1jSxisEi2R o+acSvA3GMFrKEAWRz+oxG9KC/GZrNca3wKTyT12c/tFQO1lR5GSRXRCcZCnRlDn 4HoJA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrhedvgdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehlhihsshgrucftohhsshcuoehhihesrghlhihsshgrrdhi sheqnecuggftrfgrthhtvghrnhepgfefudekvdelieelledufeevheeglefggedvudejvd dtffeuueevffehleejkedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhephhhisegrlhihshhsrgdrihhs X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 21 Jul 2023 14:00:59 -0400 (EDT) Received: by x220.qyliss.net (Postfix, from userid 1000) id 55C1A732F; Fri, 21 Jul 2023 18:00:58 +0000 (UTC) From: Alyssa Ross To: devel@spectrum-os.org Subject: [PATCH v3 5/6] host: add support for Wayland in VMs Date: Fri, 21 Jul 2023 18:00:19 +0000 Message-Id: <20230721180015.597099-6-hi@alyssa.is> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230721180015.597099-1-hi@alyssa.is> References: <20230721180015.597099-1-hi@alyssa.is> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: TI45QK2QSLAEC2F6AZLSKJJS2LG2AWNR X-Message-ID-Hash: TI45QK2QSLAEC2F6AZLSKJJS2LG2AWNR X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.5 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Alyssa Ross When a VM is configured with Wayland support, the ext-rc-init service will create an additional service to supervise the crosvm GPU backend, and start-vm will pass the required arguments to cloud-hypervisor to tell it how to connect to crosvm. Signed-off-by: Alyssa Ross Signed-off-by: Alyssa Ross --- Documentation/using-spectrum/creating-vms.adoc | 5 +++++ host/rootfs/Makefile | 4 ++++ host/rootfs/default.nix | 6 +++--- host/rootfs/etc/s6-rc/ext-rc-init/up | 7 +++++++ host/rootfs/etc/template/gpu/data/check | 5 +++++ host/rootfs/etc/template/gpu/notification-fd | 1 + host/rootfs/etc/template/gpu/notification-fd.license | 2 ++ host/rootfs/etc/template/gpu/run | 9 +++++++++ host/rootfs/etc/template/gpu/type | 1 + host/rootfs/etc/template/gpu/type.license | 2 ++ host/start-vm/lib.rs | 10 ++++++++++ vm-lib/make-vm.nix | 9 ++++++++- 12 files changed, 57 insertions(+), 4 deletions(-) create mode 100755 host/rootfs/etc/template/gpu/data/check create mode 100644 host/rootfs/etc/template/gpu/notification-fd create mode 100644 host/rootfs/etc/template/gpu/notification-fd.license create mode 100755 host/rootfs/etc/template/gpu/run create mode 100644 host/rootfs/etc/template/gpu/type create mode 100644 host/rootfs/etc/template/gpu/type.license diff --git a/Documentation/using-spectrum/creating-vms.adoc b/Documentation/using-spectrum/creating-vms.adoc index f7560f0..9e37856 100644 --- a/Documentation/using-spectrum/creating-vms.adoc +++ b/Documentation/using-spectrum/creating-vms.adoc @@ -3,6 +3,7 @@ :page-nav_order: 2 // SPDX-FileCopyrightText: 2022 Alyssa Ross +// SPDX-FileCopyrightText: 2022 Unikie // SPDX-License-Identifier: GFDL-1.3-no-invariants-or-later OR CC-BY-SA-4.0 == Configuration @@ -33,6 +34,10 @@ providers/net:: A directory containing a file named for each VM that should provide networking to this VM. The contents of these files are ignored. +wayland:: An empty file, whose presence indicates that the host should +set up a virtio-gpu device supporting the cross-domain context type, +for the VM to send Wayland messages over. + === Example A configuration directory for a VM called "appvm-lynx" dedicated to diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile index be31fc3..64decbc 100644 --- a/host/rootfs/Makefile +++ b/host/rootfs/Makefile @@ -27,6 +27,10 @@ FILES = \ 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/xdg/weston/autolaunch \ etc/xdg/weston/weston.ini \ usr/bin/lsvm \ diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix index 85a1331..16477f4 100644 --- a/host/rootfs/default.nix +++ b/host/rootfs/default.nix @@ -46,8 +46,8 @@ let foot = pkgsGui.foot.override { allowPgo = false; }; packages = [ - cloud-hypervisor e2fsprogs execline jq kmod mdevd s6 s6-linux-init s6-rc - socat start-vm virtiofsd + cloud-hypervisor e2fsprogs execline jq kmod mdevd + s6 s6-linux-init s6-rc socat start-vm virtiofsd (cryptsetup.override { programs = { @@ -73,7 +73,7 @@ let CONFIG_RMMOD n ''; }) - ] ++ (with pkgsGui; [ foot westonLite ]); + ] ++ (with pkgsGui; [ crosvm foot westonLite ]); nixosAllHardware = nixos ({ modulesPath, ... }: { imports = [ (modulesPath + "/profiles/all-hardware.nix") ]; diff --git a/host/rootfs/etc/s6-rc/ext-rc-init/up b/host/rootfs/etc/s6-rc/ext-rc-init/up index 8b5c29e..cd5d2d0 100644 --- a/host/rootfs/etc/s6-rc/ext-rc-init/up +++ b/host/rootfs/etc/s6-rc/ext-rc-init/up @@ -26,6 +26,13 @@ if { touch -- ${name}/dependencies.d/${name}-fs-${fsname} } + if { + if -t { test -e ${dir}/wayland } + if { cp -R -- /etc/template/gpu ${name}-gpu } + if { mkdir -- ${name}-gpu/env } + touch -- ${name}/dependencies.d/${name}-gpu + } + elglob -0 paths /ext/svc/data/${name}/providers/net/* forx -po0 -E path { $paths } backtick -E dep { basename -- $path } diff --git a/host/rootfs/etc/template/gpu/data/check b/host/rootfs/etc/template/gpu/data/check new file mode 100755 index 0000000..113dcf0 --- /dev/null +++ b/host/rootfs/etc/template/gpu/data/check @@ -0,0 +1,5 @@ +#!/bin/execlineb -P +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2022 Unikie + +test -S env/crosvm.sock diff --git a/host/rootfs/etc/template/gpu/notification-fd b/host/rootfs/etc/template/gpu/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/host/rootfs/etc/template/gpu/notification-fd @@ -0,0 +1 @@ +3 diff --git a/host/rootfs/etc/template/gpu/notification-fd.license b/host/rootfs/etc/template/gpu/notification-fd.license new file mode 100644 index 0000000..2241beb --- /dev/null +++ b/host/rootfs/etc/template/gpu/notification-fd.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: CC0-1.0 +SPDX-FileCopyrightText: 2022 Unikie diff --git a/host/rootfs/etc/template/gpu/run b/host/rootfs/etc/template/gpu/run new file mode 100755 index 0000000..eaac8d6 --- /dev/null +++ b/host/rootfs/etc/template/gpu/run @@ -0,0 +1,9 @@ +#!/bin/execlineb -P +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2022 Unikie + +s6-notifyoncheck -d +crosvm --no-syslog device gpu + --socket env/crosvm.sock + --wayland-sock /run/user/0/wayland-1 + --params "{\"context-types\":\"cross-domain\"}" diff --git a/host/rootfs/etc/template/gpu/type b/host/rootfs/etc/template/gpu/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/host/rootfs/etc/template/gpu/type @@ -0,0 +1 @@ +longrun diff --git a/host/rootfs/etc/template/gpu/type.license b/host/rootfs/etc/template/gpu/type.license new file mode 100644 index 0000000..2241beb --- /dev/null +++ b/host/rootfs/etc/template/gpu/type.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: CC0-1.0 +SPDX-FileCopyrightText: 2022 Unikie diff --git a/host/start-vm/lib.rs b/host/start-vm/lib.rs index adf9915..8834202 100644 --- a/host/start-vm/lib.rs +++ b/host/start-vm/lib.rs @@ -1,5 +1,6 @@ // SPDX-License-Identifier: EUPL-1.2+ // SPDX-FileCopyrightText: 2022-2023 Alyssa Ross +// SPDX-FileCopyrightText: 2022 Unikie mod ch; mod net; @@ -127,6 +128,15 @@ pub fn vm_command( Err(e) => return Err(format!("reading directory {:?}: {}", blk_dir, e)), } + if config_dir.join("wayland").exists() { + command.arg("--gpu").arg({ + let mut gpu = OsString::from("socket=../"); + gpu.push(vm_name); + gpu.push("-gpu/env/crosvm.sock"); + gpu + }); + } + let shared_dirs_dir = config_dir.join("shared-dirs"); match shared_dirs_dir.read_dir() { Ok(entries) => { diff --git a/vm-lib/make-vm.nix b/vm-lib/make-vm.nix index 80e6ef5..c3533ec 100644 --- a/vm-lib/make-vm.nix +++ b/vm-lib/make-vm.nix @@ -1,5 +1,6 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2022 Alyssa Ross +# SPDX-FileCopyrightText: 2022 Unikie { pkgs ? import {} @@ -13,7 +14,7 @@ pkgs.pkgsStatic.callPackage ( { lib, runCommand, writeReferencesToFile, erofs-utils }: -{ run, providers ? {}, sharedDirs ? {} }: +{ run, providers ? {}, sharedDirs ? {}, wayland ? false }: let inherit (lib) @@ -26,6 +27,8 @@ assert !(any (hasInfix "\n") (concatLists (attrValues providers))); runCommand "spectrum-vm" { nativeBuildInputs = [ erofs-utils ]; + inherit wayland; + providerDirs = concatStrings (concatLists (mapAttrsToList (kind: map (vm: "${kind}/${vm}\n")) providers)); passAsFile = [ "providerDirs" ]; @@ -53,6 +56,10 @@ runCommand "spectrum-vm" { popd + if [ -n "$wayland" ]; then + touch "$out/wayland" + fi + ln -s /usr/img/appvm/blk/root.img "$out/blk" ln -s /usr/img/appvm/vmlinux "$out" '' -- 2.40.1