patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Subject: [PATCH v3 3/6] img/app: add support for testing virtio-gpu
Date: Fri, 21 Jul 2023 18:00:15 +0000	[thread overview]
Message-ID: <20230721180015.597099-4-hi@alyssa.is> (raw)
In-Reply-To: <20230721180015.597099-1-hi@alyssa.is>

From: Alyssa Ross <alyssa.ross@unikie.com>

crosvm sadly doesn't support socket activation or readiness
notification, hence the sleep loop here.

Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com>
Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
 img/app/Makefile  | 13 ++++++++++++-
 img/app/shell.nix |  2 +-
 lib/common.mk     |  2 ++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/img/app/Makefile b/img/app/Makefile
index 1ea0d66..0742440 100644
--- a/img/app/Makefile
+++ b/img/app/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: EUPL-1.2+
 # SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2022 Unikie
 
 include ../../lib/common.mk
 
@@ -77,6 +78,15 @@ build/etc/s6-rc: $(VM_S6_RC_FILES)
 	    s6-rc-compile $@ $$dir; \
 	    exit=$$?; rm -r $$dir; exit $$exit
 
+start-vhost-user-gpu:
+	rm -f build/vhost-user-gpu.sock
+	$(CROSVM_DEVICE_GPU) \
+	    --socket build/vhost-user-gpu.sock \
+	    --wayland-sock "$$XDG_RUNTIME_DIR/$$WAYLAND_DISPLAY" \
+	    --params '{"context-types":"cross-domain"}' &
+	while ! [ -S build/vhost-user-gpu.sock ] && sleep .1; do :; done
+.PHONY: start-vhost-user-gpu
+
 start-virtiofsd:
 	mkdir -p build
 	$(S6_IPCSERVER_SOCKETBINDER) -B build/virtiofsd.sock \
@@ -100,7 +110,7 @@ run-qemu: $(imgdir)/appvm/blk/root.img start-virtiofsd
 	    -device virtconsole,chardev=virtiocon0
 .PHONY: run-qemu
 
-run-cloud-hypervisor: $(imgdir)/appvm/blk/root.img start-virtiofsd
+run-cloud-hypervisor: $(imgdir)/appvm/blk/root.img start-vhost-user-gpu start-virtiofsd
 	rm -f build/vmm.sock
 	@../../scripts/run-cloud-hypervisor.sh \
 	    --api-socket path=build/vmm.sock \
@@ -108,6 +118,7 @@ run-cloud-hypervisor: $(imgdir)/appvm/blk/root.img start-virtiofsd
 	    --disk path=$(imgdir)/appvm/blk/root.img,readonly=on \
 	    --disk path=$(RUN_IMG),readonly=on \
 	    --fs tag=virtiofs0,socket=build/virtiofsd.sock \
+	    --gpu socket=build/vhost-user-gpu.sock \
 	    --kernel $(KERNEL) \
 	    --cmdline "root=PARTLABEL=root" \
 	    --console tty \
diff --git a/img/app/shell.nix b/img/app/shell.nix
index ba75fcc..0c94f1d 100644
--- a/img/app/shell.nix
+++ b/img/app/shell.nix
@@ -15,7 +15,7 @@ with config.pkgs;
     # so we have to list virtiofsd first.
     virtiofsd
 
-    cloud-hypervisor execline jq qemu_kvm reuse s6
+    cloud-hypervisor crosvm execline jq qemu_kvm reuse s6
   ];
 
   runDef = import run { inherit config; };
diff --git a/lib/common.mk b/lib/common.mk
index e32fecb..81754b9 100644
--- a/lib/common.mk
+++ b/lib/common.mk
@@ -11,6 +11,8 @@ QEMU_KVM = qemu-kvm
 BACKGROUND = background
 CPIO = cpio
 CPIOFLAGS = --reproducible -R +0:+0 -H newc
+CROSVM = crosvm
+CROSVM_DEVICE_GPU = $(CROSVM) device gpu
 MCOPY = mcopy
 MKFS_FAT = mkfs.fat
 MMD = mmd
-- 
2.40.1



  parent reply	other threads:[~2023-07-21 18:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 18:00 [PATCH v3 0/6] Initial support for VM Wayland Alyssa Ross
2023-07-21 18:00 ` [PATCH v3 1/6] img/app: allow waiting for GPU to appear Alyssa Ross
2023-07-28 12:10   ` Alyssa Ross
2023-07-21 18:00 ` [PATCH v3 2/6] vm-lib: add mesa drivers to VM Alyssa Ross
2023-07-28 12:10   ` Alyssa Ross
2023-07-21 18:00 ` Alyssa Ross [this message]
2023-07-28 12:10   ` [PATCH v3 3/6] img/app: add support for testing virtio-gpu Alyssa Ross
2023-07-21 18:00 ` [PATCH v3 4/6] vm: add support for testing in crosvm Alyssa Ross
2023-07-28 12:10   ` Alyssa Ross
2023-07-21 18:00 ` [PATCH v3 5/6] host: add support for Wayland in VMs Alyssa Ross
2023-07-28 12:10   ` Alyssa Ross
2023-07-21 18:00 ` [PATCH v3 6/6] vm/app: add hello-wayland demo VM Alyssa Ross
2023-07-28 12:10   ` Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230721180015.597099-4-hi@alyssa.is \
    --to=hi@alyssa.is \
    --cc=devel@spectrum-os.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).