talex5 / wayland-proxy-virtwl

Allow guest VMs to open windows on the host
Apache License 2.0
114 stars 12 forks source link

socket not removed - intentially? #59

Closed jonleivent closed 1 year ago

jonleivent commented 1 year ago

I noticed that the socket file created by wayland-proxy-virtwl is not removed on exit. Is this intentional?

talex5 commented 1 year ago

This is fixed in the Eio branch, at least for a clean shutdown (if you exit with Ctrl-C it won't clean it up).

Both versions check for stale sockets and remove them on the next run, though.

jonleivent commented 1 year ago

Is the eio branch mature enough to be used in place of the master branch? If so, I will switch. Otherwise, I will stay on master and handle socket cleanup with a wrapper script. But from reading about eio, it sounds like that will eventually become the master, replacing lwt as much as possible, correct?

talex5 commented 1 year ago

Yes. I'm running the Eio branch myself. The branch is only not merged because it needs FD-passing support in Eio (https://github.com/ocaml-multicore/eio/pull/522), which isn't merged yet because it's queued up behind another PR.

jonleivent commented 1 year ago

I get an error when building on the Eio branch:

[ERROR] The compilation of wayland-proxy-virtwl.~dev failed at "dune build -p
        wayland-proxy-virtwl -j 3 @install".

#=== ERROR while compiling wayland-proxy-virtwl.~dev ==========================#
# context     2.1.2 | linux/x86_64 | ocaml.5.0.0 | pinned(git+file:///home/jil/gits/wayland-proxy-virtwl#HEAD#b325e822)
# path        ~/.opam/default/.opam-switch/build/wayland-proxy-virtwl.~dev
# command     ~/.opam/default/bin/dune build -p wayland-proxy-virtwl -j 3 @install
# exit-code   1
# env-file    ~/.opam/log/wayland-proxy-virtwl-41125-d26086.env
# output-file ~/.opam/log/wayland-proxy-virtwl-41125-d26086.out
### output ###
# Error: This expression has type
# [...]
#        but an expression was expected of type #Wayland.S.transport
#        Types for method recv are incompatible
# (cd _build/default && /home/jil/.opam/default/bin/ocamlc.opt -w -40 -g -bin-annot -I .main.eobjs/byte -I /home/jil/.opam/default/lib/bigstringaf -I /home/jil/.opam/default/lib/bytes -I /home/jil/.opam/default/lib/cmdliner -I /home/jil/.opam/default/lib/cstruct -I /home/jil/.opam/default/lib/domain-local-await -I /home/jil/.opam/default/lib/eio -I /home/jil/.opam/default/lib/eio/core -I /home/[...]
# File "host.ml", line 10, characters 24-46:
# 10 |   let display, closed = Wayland.Client.connect ~sw ~trace:(module Trace.Host) transport in
#                              ^^^^^^^^^^^^^^^^^^^^^^
# Error: This function has type
#          ?trace:(module Wayland.Client.TRACE) ->
#          #Wayland__.S.transport ->
#          Wayland.Client.t * (unit, exn) Lwt_result.t
#        It is applied to too many arguments; maybe you forgot a `;'.
talex5 commented 1 year ago

It also needs an Eio version of ocaml-wayland. I've added some Git submodules to track the dependencies now. git submodule update --init --recursive should bring them in.

jonleivent commented 1 year ago

After doing git submodule update --init --recursive, I get different errors:

File "virtio_gpu/dev.ml", line 5, characters 29-30:
5 | type pipe = Eio_unix.sink_ty r
                                 ^
Error: Unbound type constructor r
File "virtio_gpu/wayland_dmabuf.ml", line 27, characters 4-31:
27 |     Wayland.Client.sync wayland;
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type unit Lwt.t
       but an expression was expected of type unit
       because it is in the left-hand side of a sequence
File "virtio_gpu/virtio_gpu.ml", line 9, characters 16-29:
9 |   device_path : Eio.Fs.dir_ty Eio.Path.t;
                    ^^^^^^^^^^^^^
Error: Unbound type constructor Eio.Fs.dir_ty
File "tests/test.ml", line 145, characters 53-55:
145 |   let display, conn_closed = Wayland.Client.connect ~sw transport in
                                                           ^^
Error: The function applied to this argument has type
         ?trace:(module Wayland.Client.TRACE) ->
         Wayland.Client.t * (unit, exn) Lwt_result.t
This argument cannot be applied with label ~sw
File "x11/x11.mli", line 23, characters 31-54:   
23 |   val connect : sw:Switch.t -> _ Eio.Net.stream_socket -> t
                                    ^^^^^^^^^^^^^^^^^^^^^^^
Error: The type constructor Eio.Net.stream_socket expects 0 argument(s),
       but is here applied to 1 argument(s)
File "x11/types.ml", line 19, characters 47-48: 
19 |   socket : [`Generic] Eio.Net.stream_socket_ty r;
                                                    ^
Error: Unbound type constructor r
talex5 commented 1 year ago

It's passing in CI: https://github.com/talex5/wayland-proxy-virtwl/runs/15815539817

You should see:

$ git log -- eio
commit ccf667c3c086b172e04f4c2e3cff07b4e8f46ce2 (HEAD -> eio, tal/eio)
Author: Thomas Leonard <talex5@gmail.com>
Date:   Fri Aug 11 11:32:50 2023 +0100

    Temporary: add eio and ocaml-wayland submodules

$ grep "type 'a r"  eio/lib_eio/std.ml
type 'a r = 'a Resource.t
jonleivent commented 1 year ago

OK - the problem is that my eio dir is empty. The git log -- eio is correct. Why isn't my eio dir populating?

jonleivent commented 1 year ago

eio wasn't populating because I did the git submodule update --init --recursive on the master branch. After doing it on eio, it builds. I didn't know that git submodule update --init --recursive was specific to the current branch.

jonleivent commented 1 year ago

I'm switching my work to the Eio branch, and closing this.