目的
ubuntu 17.10でwaylandがデフォルトになりました。
これまでリモートでの作業やヘッドレステストにVNCを使ってきましたが、XVncはOpenGLが扱えないのでAtom等が動かずこれまで苦々しい思いをしていました。
OpenGLのためにVinoを使うというのもありますが、複数ユーザーで使えないですし、リモートのデスクトップがディスプレイに表示されたり、WSLで使えない制約があります。
chromeは今年ヘッドレスモードが追加されたのでテストではVNCやWaylandはどうでもよくなったかもしれないですが。
WaylandではRDPでOpenGLのパッチがあたりその状況が改善してきたようなので、この度試してみました。
Windowsのmstscではうまくいかなかったですが、FreeRDPのwfreerdpで表示できました。
WaylandのおさらいとRDPまで
WaylandではXWindowのWindowManagerとXServerはコンポジタに統合されます。WestonはWaylandのコンポジタのリファレンス実装です。GnomeはMutterというコンポジタを提供しています。
クライアント(ブラウザ、terminalなど)->コンポジタ->バックエンド(drm,kmsなど)
とWaylandはシンプルな構成になっています。
今あるコンポジタは下記です。
- Weston(リファレンス実装)
- Mutter(Gnome)
- KWin(KDE)
Westonではバックエンドの部分は切り替えられるようで下記がサポートされています。Mutterとかは切り得られるかどうかわかりませんでした。こちらの記事をみるとMutterはWestonのrdpは使わないようです。
- x11
- drm
- wayland
- headless
- fbdev
- rdp(リモートデスクトップ)
テストした環境
Ubuntuではrdpのバックエンドを政治的な理由か配布していないので、Westonをビルドする必要があります。
Ubuntu 16.04でWeston 3.0.90(efade28db954ad02ac283a626238df04bae146da)をビルドしました。
ビルドにはさまざまなライブラリが必要でwayland-build-toolsを使用しました。
ビルド
wayland-build-toolsはrdpがサポートされていないので、下記のような修正を行いました。
diff --git a/wl_build b/wl_build
index 9f167a5..04bb4eb 100755
--- a/wl_build
+++ b/wl_build
@@ -19,6 +19,17 @@ gen() {
./autogen.sh --prefix=$WLD $*
}
+genForCmake() {
+ pkg=$1
+ shift
+ echo
+ echo $pkg
+ cd $WLROOT/$pkg
+ echo "git@github.com:FreeRDP/FreeRDP.git./autogen.sh --prefix=$WLD $*"
+ cmake -DCMAKE_INSTALL_PREFIX:PATH=$WLD .
+}
+
+
compile() {
make -j32 && make install
if [ $? != 0 ]; then
@@ -38,6 +49,9 @@ distcheck() {
mkdir -p $WLD/share/aclocal
+genForCmake FreeRDP
+compile
+
gen wayland
compile
@@ -209,6 +223,7 @@ git clean -xfd
--enable-setuid-install=no \
--enable-clients \
--enable-headless-compositor \
+ --enable-rdp-compositor \
--enable-demo-clients-install
compile
#distcheck
diff --git a/wl_clone b/wl_clone
index 4673517..d52a798 100755
--- a/wl_clone
+++ b/wl_clone
@@ -57,6 +57,7 @@ clone_or_update git://anongit.freedesktop.org/wayland/wayland-protocols
clone_or_update git://git.code.sf.net/p/linuxwacom/libwacom
clone_or_update git://anongit.freedesktop.org/wayland/libinput
clone_or_update git://anongit.freedesktop.org/wayland/weston
+clone_or_update git://github.com/FreeRDP/FreeRDP
if [ ${INCLUDE_XWAYLAND} ]; then
if [ ${WL_BITS} = "32" ]; then
ビルドは下記です。mesonをいれましょう。
apt-get install -y git
apt-get install python3 ninja-build
pip3 install --user meson
mkdir ~/Wayland # sources and builds will be here
mkdir -p ~/.config/wayland-build-tools
cp wl_defines.sh ~/.config/wayland-build-tools/
./wl_install_deps
./wl_clone
./wl_build
ビルドが終わったら下記を実行してパスを通しましょう。
source ~/.config/wayland-build-tools/wl_defines.sh
実行
rdpバックエンドはRSAキーの設定かTLSの設定が必要です。
RSAキーの場合は下記を実行。
ssh-keygen -f rdp.key
weston --backend=rdp-backend.so --rdp4-key=rdp.key
TLSの場合は下記を実行。
winpr-makecert -rdp > rdp.crt
weston --backend=rdp-backend.so --rdp-tls-cert=rdp.crt --rdp-tls-key=rdp.key
起動後、windowsのmstscでサーバーを指定してつなぎます。
mstsc /v:"接続先"
しかし、mstscの画面は真っ黒なままです。下記のログでましたが、原因不明です。
$ weston --backend=rdp-backend.so --rdp4-key=rdp.key --xwayland --width=1024 --height=768
Date: 2017-10-26 JST
[12:27:23.352] weston 3.0.90
http://wayland.freedesktop.org
Bug reports to: https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland&component=weston&version=3.0.90
Build: 3.0.0-53-gefade28 libweston-desktop/xdg-shell-v6: Actually send same-as-current configure if needed (2017-10-18 11:04:30 +0200)
[12:27:23.352] Command line: weston --backend=rdp-backend.so --rdp4-key=rdp.key --xwayland --width=1024 --height=768
[12:27:23.352] OS: Linux, 4.4.0-92-lowlatency, #115-Ubuntu SMP PREEMPT Thu Aug 10 09:53:57 UTC 2017, x86_64
[12:27:23.352] Using config file '/home/junji-hashimoto/.config/weston.ini'
[12:27:23.353] Output repaint window is 7 ms maximum.
[12:27:23.353] Loading module '/home/junji-hashimoto/Wayland/install/lib/libweston-3/rdp-backend.so'
[12:27:23.362] using FreeRDP version 2.0.0
[12:27:23:404] [7600:7600] [INFO][com.freerdp.core.listener] - Listening on 0.0.0.0:3389
[12:27:23.362] Registered plugin API 'weston_rdp_output_api_v1' of size 8
[12:27:23.362] Compositor capabilities:
arbitrary surface rotation: yes
screen capture uses y-flip: yes
presentation clock: CLOCK_MONOTONIC_RAW, id 4
presentation clock resolution: 0.000000001 s
[12:27:23.362] Loading module '/home/junji-hashimoto/Wayland/install/lib/weston/desktop-shell.so'
[12:27:23.363] launching '/home/junji-hashimoto/Wayland/install/libexec/weston-keyboard'
[12:27:23.363] Loading module '/home/junji-hashimoto/Wayland/install/lib/libweston-3/xwayland.so'
[12:27:23.368] Registered plugin API 'weston_xwayland_v1' of size 32
[12:27:23.369] Registered plugin API 'weston_xwayland_surface_v1' of size 16
[12:27:23.369] xserver listening on display :0
[12:27:23.369] launching '/home/junji-hashimoto/Wayland/install/libexec/weston-desktop-shell'
[12:28:30:192] [7600:7600] [INFO][com.freerdp.core.connection] - Client Security: NLA:0 TLS:0 RDP:1
[12:28:30:192] [7600:7600] [INFO][com.freerdp.core.connection] - Server Security: NLA:0 TLS:0 RDP:1
[12:28:30:192] [7600:7600] [INFO][com.freerdp.core.connection] - Negotiated Security: NLA:0 TLS:0 RDP:1
[12:28:30:197] [7600:7600] [INFO][com.freerdp.core.connection] - Accepted client: xxx
[12:28:30:197] [7600:7600] [INFO][com.freerdp.core.connection] - Accepted channels:
[12:28:30:197] [7600:7600] [INFO][com.freerdp.core.connection] - rdpdr
[12:28:30:197] [7600:7600] [INFO][com.freerdp.core.connection] - rdpsnd
[12:28:30:197] [7600:7600] [INFO][com.freerdp.core.connection] - cliprdr
[12:28:30:197] [7600:7600] [INFO][com.freerdp.core.connection] - drdynvc
[12:28:30:197] [7600:7600] [INFO][com.freerdp.core.gcc] - Active rdp encryption level: CLIENT-COMPATIBLE
[12:28:30:197] [7600:7600] [INFO][com.freerdp.core.gcc] - Selected rdp encryption method: 128BIT
[12:28:30.472] kbd_layout:0xe0010411 kbd_type:0x7 kbd_subType:0x2 kbd_functionKeys:0xc
[12:28:30.472] xf_peer_activate: matching layout=jp variant=kana
その後、FreeRDPのクライアントwfreerdpを試したところ、つながりました。ターミナル,chrome,atomが起動できました。
wfreerdp /v:"接続先"
ログは下記のようなものです。
$ weston --backend=rdp-backend.so --rdp4-key=rdp.key --xwayland --width=1024 --height=768
Date: 2017-10-26 JST
[12:35:11.205] weston 3.0.90
http://wayland.freedesktop.org
Bug reports to: https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland&component=weston&version=3.0.90
Build: 3.0.0-53-gefade28 libweston-desktop/xdg-shell-v6: Actually send same-as-current configure if needed (2017-10-18 11:04:30 +0200)
[12:35:11.205] Command line: weston --backend=rdp-backend.so --rdp4-key=rdp.key --xwayland --width=1024 --height=768
[12:35:11.205] OS: Linux, 4.4.0-92-lowlatency, #115-Ubuntu SMP PREEMPT Thu Aug 10 09:53:57 UTC 2017, x86_64
[12:35:11.205] Using config file '/home/junji-hashimoto/.config/weston.ini'
[12:35:11.205] Output repaint window is 7 ms maximum.
[12:35:11.205] Loading module '/home/junji-hashimoto/Wayland/install/lib/libweston-3/rdp-backend.so'
[12:35:11.214] using FreeRDP version 2.0.0
[12:35:11:256] [7659:7659] [INFO][com.freerdp.core.listener] - Listening on 0.0.0.0:3389
[12:35:11.214] Registered plugin API 'weston_rdp_output_api_v1' of size 8
[12:35:11.214] Compositor capabilities:
arbitrary surface rotation: yes
screen capture uses y-flip: yes
presentation clock: CLOCK_MONOTONIC_RAW, id 4
presentation clock resolution: 0.000000001 s
[12:35:11.214] Loading module '/home/junji-hashimoto/Wayland/install/lib/weston/desktop-shell.so'
[12:35:11.215] launching '/home/junji-hashimoto/Wayland/install/libexec/weston-keyboard'
[12:35:11.215] Loading module '/home/junji-hashimoto/Wayland/install/lib/libweston-3/xwayland.so'
[12:35:11.220] Registered plugin API 'weston_xwayland_v1' of size 32
[12:35:11.220] Registered plugin API 'weston_xwayland_surface_v1' of size 16
[12:35:11.220] xserver listening on display :0
[12:35:11.220] launching '/home/junji-hashimoto/Wayland/install/libexec/weston-desktop-shell'
[12:35:15:276] [7659:7659] [INFO][com.freerdp.core.connection] - Client Security: NLA:1 TLS:1 RDP:0
[12:35:15:276] [7659:7659] [INFO][com.freerdp.core.connection] - Server Security: NLA:0 TLS:0 RDP:1
[12:35:15:276] [7659:7659] [ERROR][com.freerdp.core.connection] - server supports only Standard RDP Security
[12:35:15:276] [7659:7659] [ERROR][com.freerdp.core.connection] - Protocol security negotiation failure
[12:35:15:276] [7659:7659] [ERROR][com.freerdp.core.peer] - peer_recv_callback: CONNECTION_STATE_INITIAL - rdp_server_accept_nego() fail
[12:35:15:276] [7659:7659] [ERROR][com.freerdp.core.transport] - transport_check_fds: transport->ReceiveCallback() - -1
[12:35:15.235] unable to checkDescriptor for 0x15b7750
[12:35:15:291] [7659:7659] [INFO][com.freerdp.core.connection] - Client Security: NLA:0 TLS:1 RDP:0
[12:35:15:291] [7659:7659] [INFO][com.freerdp.core.connection] - Server Security: NLA:0 TLS:0 RDP:1
[12:35:15:291] [7659:7659] [ERROR][com.freerdp.core.connection] - server supports only Standard RDP Security
[12:35:15:291] [7659:7659] [ERROR][com.freerdp.core.connection] - Protocol security negotiation failure
[12:35:15:291] [7659:7659] [ERROR][com.freerdp.core.peer] - peer_recv_callback: CONNECTION_STATE_INITIAL - rdp_server_accept_nego() fail
[12:35:15:291] [7659:7659] [ERROR][com.freerdp.core.transport] - transport_check_fds: transport->ReceiveCallback() - -1
[12:35:15.249] unable to checkDescriptor for 0x161c6f0
[12:35:15:305] [7659:7659] [INFO][com.freerdp.core.connection] - Client Security: NLA:0 TLS:0 RDP:1
[12:35:15:305] [7659:7659] [INFO][com.freerdp.core.connection] - Server Security: NLA:0 TLS:0 RDP:1
[12:35:15:306] [7659:7659] [INFO][com.freerdp.core.connection] - Negotiated Security: NLA:0 TLS:0 RDP:1
[12:35:15:307] [7659:7659] [INFO][com.freerdp.core.connection] - Accepted client: xxx
[12:35:15:307] [7659:7659] [INFO][com.freerdp.core.connection] - Accepted channels:
[12:35:15:307] [7659:7659] [INFO][com.freerdp.core.connection] - cliprdr
[12:35:15:307] [7659:7659] [INFO][com.freerdp.core.gcc] - Active rdp encryption level: CLIENT-COMPATIBLE
[12:35:15:307] [7659:7659] [INFO][com.freerdp.core.gcc] - Selected rdp encryption method: 128BIT
[12:35:15.284] kbd_layout:0x411 kbd_type:0x4 kbd_subType:0x0 kbd_functionKeys:0xc
[12:35:15.284] xf_peer_activate: matching layout=jp variant=(null)
結果
FreeRDPのクライアントを用いてRSAキーの場合でRDPできました。
Windowsのmstscを使った場合ではRSAキーの場合は接続できましたが、真っ黒い画面がでたままでした。WAYLAND_DEBUG=1
をつけてデバッグしたところキーやマウスのイベントはとれているようです。表示だけがうまくいってないようです。
WAYLAND_DEBUG=1 weston --backend=rdp-backend.so --rdp4-key=rdp.key
また、mstscによるTLSの場合は接続さえできませんでした。原因の追究はできていません。