Another week that ended up being a detour from the Wayland work I wanted to do, unfortunately. I think this will be the end of it, though.
Fixed an error in my crosvm deadlock fix from last week. Due to an oversight (obvious as soon as I tried to test the affected devices, and from looking at the code in retrospect), this actually broke the devices that were *not* affected by the deadlock, which I had neglected to properly test. Fortunately, it was a very small and easy fix.
I also had an interesting (and ongoing) conversation with Cole about the deadlock fix in the mailing list thread. It's one of those situations where getting to talk about the code with another person and having to explain things is going to result in much better code. So we'll end up with a much tidier fix than what I came up with on my own. Thanks to Cole for his feedback and this opportunity. It's great to know that somebody else is passing an eye over my code.
: https://spectrum-os.org/git/crosvm/commit/?id=ca5bdd2ac3e473e9b082c44c2870f4... : https://spectrum-os.org/lists/archives/spectrum-devel/20200614114344.22642-1... : https://spectrum-os.org/lists/archives/spectrum-devel/CH2PR14MB357902F389083...
My current area of attention is modifying Wayland to use a virtio_wl socket as the display socket. Preparing to start implementing that this week, it occurred to me that working on it using my current setup was going to be extremely time consuming. Up until now, I've been doing Nix VM rebuilds when I want to test a change to, for example, wlroots. This means rebuilding, in that case, wlroots and all dependencies (i.e. Wayfire). In the case of wlroots, it's not so bad because rebuilding two packages doesn't take all that long, but it wasn't going to work for Wayland.
So I decided that the best way forward would be to create a VM running a traditional Linux distribution, in which I could hack on Wayland without having to restart the VM or rebuild all of its dependents. To that end, I spent much of this week setting up an Alpine VM that can be run under both crosvm and QEMU. (Configuring networking with crosvm is hard for a one-off like this, but QEMU has a built-in userspace networking stack that makes it easy, so when I want to, e.g. install a package, I can boot with QEMU to do that, and then go back to crosvm for testing virtio_wl things.) This resulted in a Nixpkgs pull request to package Alpine's apk package manager, which was used in building the VM image.
As of this afternoon, I have this VM all set up and ready to go. I have a script that runs it under crosvm with a virtio_wl socket available to try to connect Wayland to, and another virtio_wl socket connected to the host Wayland compositor for testing. It also sets up some limited networking that allows me to SSH into the VM, but does not allow the VM to access the internet. A separate script runs the VM under QEMU with full networking. The VM has Wayland, wlroots, and Sway (the choice of wlroots-based compositor is irrelevant to this work, and Sway is easier to build) installed from source, and because I can SSH to it I can edit files in the VM easily from my host Emacs using TRAMP.
All of this will allow me to iterate on the Wayland work without having to wait upwards of an hour to test each change. This was actually the first time I'd ever booted a VM image in crosvm that I hadn't generated specifically for that purpose myself with Nix. I improved my understanding of crosvm in a few ways in the process (although not anything concrete enough I can think of to write down here).
Next week, I'll continue with the Wayland work. It shouldn't be all that much work in the end, but getting set up to actually be able to do it has been annoyingly complicated.