patches and low-level development discussion
 help / color / mirror / code / Atom feed
* [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.
@ 2022-11-29 22:58 vadim likholetov
  0 siblings, 0 replies; only message in thread
From: vadim likholetov @ 2022-11-29 22:58 UTC (permalink / raw)
  To: devel; +Cc: vadim likholetov

---
 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 <hi@alyssa.is>
+
+{ 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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-29 22:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 22:58 [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 vadim likholetov

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).