From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 439D63F895; Tue, 29 Nov 2022 22:58:40 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id 095843F890; Tue, 29 Nov 2022 22:58:38 +0000 (UTC) Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by atuin.qyliss.net (Postfix) with ESMTPS id 7CBB73F88E for ; Tue, 29 Nov 2022 22:58:34 +0000 (UTC) Received: by mail-lf1-x12d.google.com with SMTP id c1so24298226lfi.7 for ; Tue, 29 Nov 2022 14:58:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unikie.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dLF2q6jt+bxBhXeZUc/azK9pR0v6ktTFmFIb6O6nBd0=; b=Fqo+wUyFm/7Q6ZDVt6+en5f/sKWUeTPV1VCOyylXcN5Z/j3xvtmrLsoWGXx3wEv8zk wMJaJUN86gvYK8/ScTWiyYDhTgE4eN9Mc5loLvrRkPb5mQM7wh8QRt480ZmRG5vYnkNq XgKgegRujskVWMDRZFPFlruKZ2hc75Njjw9ugdkF5mZG8H5duo7g8l4jPoBBqIQWkDWL k+LDxzJcKyxd2B7NSjWvWyFGUwc6PsiccnjP9eLliJ+wRBx5g3nD9VDitfc8cwfppE4D Wa513rz7cqBPZ3OqjgvyARMg1APLUMP8iVZpmyl8/Yc4kU8tho/Ej37jsrufLlvVZKb8 RXQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dLF2q6jt+bxBhXeZUc/azK9pR0v6ktTFmFIb6O6nBd0=; b=OZCYq3Hd/8p3r2BoIybkPZIekjN+PNmATBHnwDJIupJXhNNmI0/XuaOyer7AWSbWNy gIaOKzOObLOXPQ4NMAM46qtDfi31e+35ZCsh4dECQP3I3jO8OHtx2aEghYX1FNalEcm/ fhC/+bUULmkvbio3wnD8tg8lib4Hf+d6d2nM6vIXRiVb9Hn/Uhh+N6LhC6fxENV+AVCd F9eRDGqiO+lfIJX5/Up92l4tSRi9jQbd+G+sbsahwU+Oa8EGQ3sTeU1r5qu+jBwPZtrj xATCCE0/zBUY0MvF4xafuqJaqfUZnT31ET/5dw1OK1/Hh5zFFBN8Gc5KUqW5227+URwm dXGA== X-Gm-Message-State: ANoB5pm88FBNpbjQoa4iXdi1DNpGt6j31F0h8IcN/4dTtxo0iF4aNeKA Vvmx/TlKj+c9Gle2G8JnVedHHce25A0QtA== X-Google-Smtp-Source: AA0mqf6KZvKfYn1gcIC5Y5w/hXbGdHpUvF70bFGQBU3VSoKAoKgGmKrtY0nPE9FuUQCc/OLfc+JGNw== X-Received: by 2002:ac2:43ad:0:b0:4b0:8a8f:8e28 with SMTP id t13-20020ac243ad000000b004b08a8f8e28mr18407962lfl.682.1669762712811; Tue, 29 Nov 2022 14:58:32 -0800 (PST) Received: from localhost.localdomain (88-114-171-198.elisa-laajakaista.fi. [88.114.171.198]) by smtp.gmail.com with ESMTPSA id b10-20020a056512070a00b004a45ed1ae21sm2379274lfs.224.2022.11.29.14.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 14:58:32 -0800 (PST) From: vadim likholetov To: devel@spectrum-os.org Subject: [PATCH] This patchset enables forwarding Wayland connections from appVM to the host with the help of waypipe tool. It doesn't reqire major changes in Spectrum and tries to utilise existing packages and solutions. Main idea is to create VSOCK virtual device on the start of appVM and use this virtual socket to connect host and guest. On the host side I implement vm-start-way tool that is based on vm-start, but does nesessary preparations for wayland forwarfing. The guest VM is appvm-hello-waypipe and described in hello-waypipe.nix file. To test it boot the Spectrum and do 'vm-start-way appvm-hello-waypipe'. Be patient and in couple of seconds will appear a terminal window from appVM. This patches are for test the concept, so possibly redisign is needed for production use. Date: Wed, 30 Nov 2022 00:58:25 +0200 Message-Id: <20221129225825.1361947-1-vadim.likholetov@unikie.com> X-Mailer: git-send-email 2.36.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 6PI4NLTQCMFTDWZRKHLX67OFIULYIY4D X-Message-ID-Hash: 6PI4NLTQCMFTDWZRKHLX67OFIULYIY4D X-MailFrom: vadim.likholetov@unikie.com X-Mailman-Rule-Hits: header-match-devel.spectrum-os.org-0 X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1 CC: vadim likholetov 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: --- host/initramfs/extfs.nix | 4 +++- host/rootfs/Makefile | 1 + host/rootfs/default.nix | 4 ++-- host/rootfs/usr/bin/vm-start-way | 10 ++++++++++ img/app/default.nix | 3 +++ vm/app/hello-waypipe.nix | 23 +++++++++++++++++++++++ 6 files changed, 42 insertions(+), 3 deletions(-) create mode 100755 host/rootfs/usr/bin/vm-start-way create mode 100644 vm/app/hello-waypipe.nix diff --git a/host/initramfs/extfs.nix b/host/initramfs/extfs.nix index 5c5850f..f49e519 100644 --- a/host/initramfs/extfs.nix +++ b/host/initramfs/extfs.nix @@ -11,12 +11,13 @@ let appvm-catgirl = import ../../vm/app/catgirl.nix { inherit config; }; appvm-lynx = import ../../vm/app/lynx.nix { inherit config; }; + appvm-hello-waypipe = import ../../vm/app/hello-waypipe.nix { inherit config; }; in runCommand "ext.ext4" { nativeBuildInputs = [ e2fsprogs ]; } '' - mkdir -p root/svc/data/appvm-{catgirl,lynx} + mkdir -p root/svc/data/appvm-{catgirl,lynx,hello-waypipe} cd root tar -C ${netvm} -c data | tar -C svc -x @@ -24,6 +25,7 @@ runCommand "ext.ext4" { tar -C ${appvm-catgirl} -c . | tar -C svc/data/appvm-catgirl -x tar -C ${appvm-lynx} -c . | tar -C svc/data/appvm-lynx -x + tar -C ${appvm-hello-waypipe} -c . | tar -C svc/data/appvm-hello-waypipe -x mkfs.ext4 -d . $out 16T resize2fs -M $out diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile index 9559c06..06e3e8e 100644 --- a/host/rootfs/Makefile +++ b/host/rootfs/Makefile @@ -39,6 +39,7 @@ FILES = \ usr/bin/lsvm \ usr/bin/vm-console \ usr/bin/vm-start \ + usr/bin/vm-start-way \ usr/bin/vm-stop DIRS = dev etc/s6-linux-init/env ext run proc sys diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix index 0a84f55..de4a6b6 100644 --- a/host/rootfs/default.nix +++ b/host/rootfs/default.nix @@ -7,7 +7,7 @@ pkgs.pkgsStatic.callPackage ( { lib, stdenvNoCC, nixos, runCommand, writeReferencesToFile, s6-rc, tar2ext4 , busybox, cloud-hypervisor, cryptsetup, execline, e2fsprogs, jq, kmod -, mdevd, s6, s6-linux-init, socat, util-linuxMinimal, xorg +, mdevd, s6, s6-linux-init, socat, util-linuxMinimal, xorg, waypipe }: let @@ -49,7 +49,7 @@ let packages = [ cloud-hypervisor e2fsprogs execline jq kmod mdevd s6 s6-linux-init s6-rc - socat start-vm + socat start-vm waypipe (cryptsetup.override { programs = { diff --git a/host/rootfs/usr/bin/vm-start-way b/host/rootfs/usr/bin/vm-start-way new file mode 100755 index 0000000..bda9934 --- /dev/null +++ b/host/rootfs/usr/bin/vm-start-way @@ -0,0 +1,10 @@ +#!/bin/sh +# SPDX-License-Identifier: EUPL-1.2+ + +s6-rc -bu change ext-rc +s6-rc -l /run/s6-rc.ext -u change $1 +ch-remote --api-socket /run/service/ext-${1}/env/cloud-hypervisor.sock add-vsock cid=4,socket=/run/u.${1}.socket +cd /run +nohup waypipe --socket /run/waypipe.sock client & +nohup socat unix-listen:/run/u.${1}.socket_5000,reuseaddr,fork unix-connect:/run/waypipe.sock & + diff --git a/img/app/default.nix b/img/app/default.nix index e7d5366..80f23c2 100644 --- a/img/app/default.nix +++ b/img/app/default.nix @@ -59,6 +59,9 @@ let DRM_BOCHS = yes; DRM = yes; AGP = yes; + VSOCKETS = yes; + VIRTIO_VSOCKETS = yes; + VIRTIO_VSOCKETS_COMMON = yes; }; }; in diff --git a/vm/app/hello-waypipe.nix b/vm/app/hello-waypipe.nix new file mode 100644 index 0000000..601b638 --- /dev/null +++ b/vm/app/hello-waypipe.nix @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross + +{ config ? import ../../../nix/eval-config.nix {} }: + +import ../make-vm.nix { inherit config; } { + providers.net = [ "netvm" ]; + run = config.pkgs.callPackage ( + { writeScript, waypipe, havoc, foot, hello-wayland, socat}: + writeScript "run-waypipe-app" '' + #!/bin/sh + mkdir /run/0 + export XDG_RUNTIME_DIR=/run/0 + ${socat}/bin/socat unix-listen:/run/waypipe.sock,reuseaddr,fork vsock-connect:2:5000 & + sleep 1 + ${waypipe}/bin/waypipe --display wayland-local --socket /run/waypipe.sock server -- sleep inf & + export WAYLAND_DISPLAY=wayland-local + ${havoc}/bin/havoc + ${hello-wayland}/bin/hello-wayland + ${foot}/bin/foot + '' + ) { }; +} -- 2.36.2