patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <alyssa.ross@unikie.com>
To: devel@spectrum-os.org
Cc: Puck Meerburg <puck@puckipedia.com>,
	Ville Ilvonen <ville.ilvonen@unikie.com>,
	sternenseemann <sternenseemann@systemli.org>
Subject: [RFC PATCH nixpkgs v2 0/9] virtio-gpu with crosvm and cloud-hypervisor
Date: Fri, 30 Sep 2022 21:08:57 +0000	[thread overview]
Message-ID: <20220930210906.1696349-1-alyssa.ross@unikie.com> (raw)

Changes since v1
----------------

 - Fixed the cloud-hypervisor seccomp sandbox for the GPU device.

 - Worked around crosvm not handling wlroots's read-only keymaps in
   cloud-hypervisor.  (Thanks Puck.)

 - Switched to cherry-picks of sternenseemann's ocamlPackages.wayland
   and wayland-proxy-virtwl updates from upstream.

v1: https://spectrum-os.org/lists/archives/spectrum-devel/20220928170128.1583791-1-alyssa.ross@unikie.com/

Introduction
------------

This series contains all the changes needed to make it possible to run
Wayland over cross-domain virtio-gpu using cloud-hypervisor.  It only
contains changes needed to packages in Nixpkgs, so there's no Spectrum
integration here.  That's a separate patchset, of which I'll also be
sending v2 soon.

There's also still some work to do here, hence being marked RFC — in
the cloud-hypervisor patch you'll spot a few TODOs and FIXMEs — but
it's ready for other people to have a look at and test.

With these changes, it's possible to run a cloud-hypervisor VM with a
GPU attached as follows:

	crosvm device gpu --socket vhost-user-gpu.sock ...
	cloud-hypervisor --gpu socket=vhost-user-gpu.sock ...

Then in the guest, just run a Wayland application under
wayland-proxy-virtwl:

	wayland-proxy-virtwl --virtio-gpu hello-wayland

For Wayland over cross-domain virtio-gpu, which we're particularly
interested in, the full crosvm command line would be something like:

	crosvm device gpu --socket vhost-user-gpu.sock \
		--wayland-sock "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" \
		--params '{"context-types": "virgl:virgl2:cross-domain"}'

Overview
--------

We start by upgrading crosvm to a beta version (since very recent
changes changed their vhost-user implementation in a way that makes it
significantly easier to interoperate with from cloud-hypervisor), then
applying a few small fixes for cases where crosvm had made assumptions
that were violated by cloud-hypervisor.

Next, we apply patches to cloud-hypervisor and some of its
dependencies, to implement the frontend of the GPU device.

Finally, we upgrade wayland-proxy-virtwl (the program that speaks
virtio-gpu and acts as the Wayland compositor inside the guest) to a
version that supports virtio-gpu.  I'm using wayland-proxy-virtwl over
Sommelier here primary because Sommelier appears to have broken with
Linux 5.19, but another nice benefit is that wayland-proxy-virtwl is
maintained by somebody that we know and talk to sometimes on
discuss@spectrum-os.org.

Upstreamability
---------------

A question anybody looking at the volume of changes here should be
asking is: "To what extent is this upstreamable?".  It's a bit of a
mixed bag — most notably, cloud-hypervisor is not interested in
virtio-gpu[1], so we'll have to maintain the cloud-hypervisor patches
ourselves until we can come up with a more upstream-friendly solution
(e.g. a vfio-user implementation of virtio-gpu).  We also can't
upstream the changes to the vhost crate, as the protocol we are using
is crosvm specific, and so some standardisation work would need to
happen there.

But we can upstream the changes to crosvm, and the virtio-bindings
crate.  I've already started on the latter.  As for the patches to
Nixpkgs itself here, the updates to wayland-proxy-virtwl and the
wayland library it depends on are already upstream (thanks sterni), I
have an open PR[2] for the crosvm update (although to 105.0 rather
than 106.3 than here, since the 106 series is still in beta), and the
rustPlatform change is also upstreamable, but would require auditing
Nixpkgs for cargoSha256 values that would change as a result.

[1]: https://github.com/cloud-hypervisor/cloud-hypervisor/discussions/3960#discussioncomment-2542915
[2]: https://github.com/NixOS/nixpkgs/pull/193746

Alyssa Ross (7):
  crosvm: switch back to old git repo URL
  crosvm.updateScript: update release branch format
  crosvm: 104.0 -> 106.2
  crosvm.updateScript: don't vendor Cargo.lock
  crosvm: add fixes for cloud-hypervisor virtio-gpu
  rustPlatform: forward unpack hooks to cargo fetch
  cloud-hypervisor: add virtio-gpu support

sternenseemann (2):
  ocamlPackages.wayland: 1.0 -> 1.1
  wayland-proxy-virtwl: unstable-2021-12-05 -> unstable-2022-09-22

 .../0001-build-use-local-vhost.patch          |   39 +
 ...dings-regenerate-with-bindgen-0.60.1.patch | 2589 ++++++++++++
 ...0002-build-use-local-virtio-bindings.patch |   39 +
 ...gs-remove-workaround-for-old-bindgen.patch |   28 +
 ...-bindings-regenerate-with-Glibc-2.36.patch |  247 ++
 ...0003-virtio-devices-add-a-GPU-device.patch | 1279 ++++++
 ...-bindings-regenerate-with-Linux-5.19.patch | 1067 +++++
 ...tio-bindings-add-virtio-gpu-bindings.patch | 3587 +++++++++++++++++
 .../cloud-hypervisor/default.nix              |   64 +-
 ...ser-add-shared-memory-region-support.patch |  724 ++++
 .../virtualization/crosvm/Cargo.lock          | 2214 ----------
 .../crosvm/default-seccomp-policy-dir.diff    |   38 +-
 .../virtualization/crosvm/default.nix         |   15 +-
 ...-consider-shm-buuffers-when-setting-.patch |   34 +
 ...t_user-loosen-expected-message-order.patch |   71 +
 ...ces-vhost_user-remove-spurious-check.patch |   42 +
 .../virtualization/crosvm/update.py           |   15 +-
 .../rust/build-rust-package/default.nix       |    4 +-
 .../ocaml-modules/wayland/default.nix         |    8 +-
 .../wayland/wayland-proxy-virtwl/default.nix  |   17 +-
 20 files changed, 9857 insertions(+), 2264 deletions(-)
 create mode 100644 pkgs/applications/virtualization/cloud-hypervisor/0001-build-use-local-vhost.patch
 create mode 100644 pkgs/applications/virtualization/cloud-hypervisor/0001-virtio-bindings-regenerate-with-bindgen-0.60.1.patch
 create mode 100644 pkgs/applications/virtualization/cloud-hypervisor/0002-build-use-local-virtio-bindings.patch
 create mode 100644 pkgs/applications/virtualization/cloud-hypervisor/0002-virtio-bindings-remove-workaround-for-old-bindgen.patch
 create mode 100644 pkgs/applications/virtualization/cloud-hypervisor/0003-virtio-bindings-regenerate-with-Glibc-2.36.patch
 create mode 100644 pkgs/applications/virtualization/cloud-hypervisor/0003-virtio-devices-add-a-GPU-device.patch
 create mode 100644 pkgs/applications/virtualization/cloud-hypervisor/0004-virtio-bindings-regenerate-with-Linux-5.19.patch
 create mode 100644 pkgs/applications/virtualization/cloud-hypervisor/0005-virtio-bindings-add-virtio-gpu-bindings.patch
 create mode 100644 pkgs/applications/virtualization/cloud-hypervisor/vhost-vhost_user-add-shared-memory-region-support.patch
 delete mode 100644 pkgs/applications/virtualization/crosvm/Cargo.lock
 create mode 100644 pkgs/applications/virtualization/crosvm/devices-properly-consider-shm-buuffers-when-setting-.patch
 create mode 100644 pkgs/applications/virtualization/crosvm/devices-vhost_user-loosen-expected-message-order.patch
 create mode 100644 pkgs/applications/virtualization/crosvm/devices-vhost_user-remove-spurious-check.patch


base-commit: 768879638cfd6a54664b762ec98a7f8f45620c44
-- 
2.37.1



             reply	other threads:[~2022-09-30 21:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 21:08 Alyssa Ross [this message]
2022-09-30 21:08 ` [RFC PATCH nixpkgs v2 1/9] crosvm: switch back to old git repo URL Alyssa Ross
2022-09-30 21:08 ` [RFC PATCH nixpkgs v2 2/9] crosvm.updateScript: update release branch format Alyssa Ross
2022-09-30 21:09 ` [RFC PATCH nixpkgs v2 3/9] crosvm: 104.0 -> 106.2 Alyssa Ross
2022-09-30 21:09 ` [RFC PATCH nixpkgs v2 4/9] crosvm.updateScript: don't vendor Cargo.lock Alyssa Ross
2022-09-30 21:09 ` [RFC PATCH nixpkgs v2 5/9] crosvm: add fixes for cloud-hypervisor virtio-gpu Alyssa Ross
2022-09-30 21:09 ` [RFC PATCH nixpkgs v2 6/9] rustPlatform: forward unpack hooks to cargo fetch Alyssa Ross
2022-09-30 21:09 ` [RFC PATCH nixpkgs v2 7/9] cloud-hypervisor: add virtio-gpu support Alyssa Ross
2022-09-30 21:09 ` [RFC PATCH nixpkgs v2 8/9] ocamlPackages.wayland: 1.0 -> 1.1 Alyssa Ross
2022-09-30 21:12 ` [RFC PATCH nixpkgs v2 9/9] wayland-proxy-virtwl: unstable-2021-12-05 -> unstable-2022-09-22 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=20220930210906.1696349-1-alyssa.ross@unikie.com \
    --to=alyssa.ross@unikie.com \
    --cc=devel@spectrum-os.org \
    --cc=puck@puckipedia.com \
    --cc=sternenseemann@systemli.org \
    --cc=ville.ilvonen@unikie.com \
    /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).