From 2560307721acc35d68592905969f546da0648056 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Wed, 23 Jun 2021 02:53:52 +0800 Subject: [PATCH 01/11] 7554 --- config.yaml | 32 +++++++++++++++++++++++--------- run-wine.sh | 5 +++++ winvm/supervisord.conf | 3 ++- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/config.yaml b/config.yaml index b718a11..d36f975 100644 --- a/config.yaml +++ b/config.yaml @@ -1,14 +1,28 @@ -path: /apps/ # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II -appFile: Notepad.exe # File Name of the app in the directory -windowTitle: Notepad # Window Title: not to show, it's the substring of title to help specify the running program in OS -pageTitle: "Notepad - A Cloud Morph Demo" # Page Title: To display on webpage -appName: Notepad # App name: to show in discovery +#path: /apps/7554 # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II +#appFile: 7554.exe # File Name of the app in the directory +#windowTitle: 7554 # Window Title: not to show, it's the substring of title to help specify the running program in OS +#pageTitle: "7554 - Learn History of Vietnam" # Page Title: To display on webpage +#appName: 7554 # App name: to show in discovery +#appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) +#hasChat: true # Turn on chat +#hardwareKey: true # Some game using DirectX needs hardward key. Turn this flag on to receive the input +## screenWidth: 480 # Optional: Default to be: 800 +## screenHeight: 320 # Optional: Default to be: 600 +#isWindowMode: true # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app +## discoveryHost: http://discovery.cloudmorph.io # Optional: to be discoverable if you plug-in to the discovery server +## instanceAddr: clouddiablo.com # Address of a cloud service instance, discovery can find + +path: /apps/RetroBlockGame3D_Data # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II +appFile: RetroBlockGame3D.exe # File Name of the app in the directory +windowTitle: RetroBlockGame3D # Window Title: not to show, it's the substring of title to help specify the running program in OS +pageTitle: "RetroBlock" # Page Title: To display on webpage +appName: RetroBlock # App name: to show in discovery appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) hasChat: true # Turn on chat -# hardwareKey: false # Some game using DirectX needs hardward key. Turn this flag on to receive the input -# screenWidth: 480 # Optional: Default to be: 800 -# screenHeight: 320 # Optional: Default to be: 600 -# isWindowMode: false # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app +hardwareKey: true # Some game using DirectX needs hardward key. Turn this flag on to receive the input +screenWidth: 800 # Optional: Default to be: 800 +screenHeight: 600 # Optional: Default to be: 600 +isWindowMode: false # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app # discoveryHost: http://discovery.cloudmorph.io # Optional: to be discoverable if you plug-in to the discovery server # instanceAddr: clouddiablo.com # Address of a cloud service instance, discovery can find # diff --git a/run-wine.sh b/run-wine.sh index 551aadf..a4dd267 100755 --- a/run-wine.sh +++ b/run-wine.sh @@ -2,6 +2,11 @@ cd winvm docker build -t syncwine . docker rm -f appvm + +# Sync local wine +#docker run -v ~/.wine:/rpath/wine --volume winecfg:/root/.wine syncwine bash -c 'cp -rf /rpath/wine/* /root/.wine' +#docker run -v ~/.wine:/rpath --volume winecfg:/root/.wine syncwine bash -c 'bash -c' + if [ $(uname -s) == "Darwin" ] then echo "Spawn container on Mac" diff --git a/winvm/supervisord.conf b/winvm/supervisord.conf index f3ca642..7408f42 100644 --- a/winvm/supervisord.conf +++ b/winvm/supervisord.conf @@ -16,7 +16,8 @@ stdout_logfile=/winevm/wineapp_out stderr_logfile=/winevm/wineapp_err [program:Xvfb] -command=/usr/bin/Xvfb :99 -screen 0 800x600x16 +/*command=/usr/bin/Xvfb :99 -screen 0 800x600x16*/ +command=/usr/bin/Xvfb :99 -screen 0 800x600x24+32 autostart=true autorestart=true startsecs=5 From e9bfa7fc95a07d1a24b3aa24025ff78d3042b193 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Sun, 27 Jun 2021 11:56:46 +0800 Subject: [PATCH 02/11] update syncinput --- config.yaml | 44 +++++++++++++++++++++--------------------- winvm/supervisord.conf | 2 +- winvm/syncinput.cpp | 14 ++++++++++---- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/config.yaml b/config.yaml index d36f975..0885cd8 100644 --- a/config.yaml +++ b/config.yaml @@ -1,28 +1,28 @@ -#path: /apps/7554 # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II -#appFile: 7554.exe # File Name of the app in the directory -#windowTitle: 7554 # Window Title: not to show, it's the substring of title to help specify the running program in OS -#pageTitle: "7554 - Learn History of Vietnam" # Page Title: To display on webpage -#appName: 7554 # App name: to show in discovery -#appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) -#hasChat: true # Turn on chat -#hardwareKey: true # Some game using DirectX needs hardward key. Turn this flag on to receive the input -## screenWidth: 480 # Optional: Default to be: 800 -## screenHeight: 320 # Optional: Default to be: 600 -#isWindowMode: true # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app -## discoveryHost: http://discovery.cloudmorph.io # Optional: to be discoverable if you plug-in to the discovery server -## instanceAddr: clouddiablo.com # Address of a cloud service instance, discovery can find - -path: /apps/RetroBlockGame3D_Data # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II -appFile: RetroBlockGame3D.exe # File Name of the app in the directory -windowTitle: RetroBlockGame3D # Window Title: not to show, it's the substring of title to help specify the running program in OS -pageTitle: "RetroBlock" # Page Title: To display on webpage -appName: RetroBlock # App name: to show in discovery +path: / # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II +appFile: C:/7554/7554.exe # File Name of the app in the directory +windowTitle: 7554 # Window Title: not to show, it's the substring of title to help specify the running program in OS +pageTitle: "7554 - Learn History of Vietnam" # Page Title: To display on webpage +appName: 7554 # App name: to show in discovery appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) hasChat: true # Turn on chat hardwareKey: true # Some game using DirectX needs hardward key. Turn this flag on to receive the input -screenWidth: 800 # Optional: Default to be: 800 -screenHeight: 600 # Optional: Default to be: 600 -isWindowMode: false # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app +#screenWidth: 800 # Optional: Default to be: 800 +#screenHeight: 600 # Optional: Default to be: 600 +#isWindowMode: false # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app +# discoveryHost: http://discovery.cloudmorph.io # Optional: to be discoverable if you plug-in to the discovery server +# instanceAddr: clouddiablo.com # Address of a cloud service instance, discovery can find + +#path: /apps/RetroBlockGame3D_Data # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II +#appFile: RetroBlockGame3D.exe # File Name of the app in the directory +#windowTitle: RetroBlockGame3D # Window Title: not to show, it's the substring of title to help specify the running program in OS +#pageTitle: "RetroBlock" # Page Title: To display on webpage +#appName: RetroBlock # App name: to show in discovery +#appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) +#hasChat: true # Turn on chat +#hardwareKey: true # Some game using DirectX needs hardward key. Turn this flag on to receive the input +#screenWidth: 800 # Optional: Default to be: 800 +#screenHeight: 600 # Optional: Default to be: 600 +#isWindowMode: false # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app # discoveryHost: http://discovery.cloudmorph.io # Optional: to be discoverable if you plug-in to the discovery server # instanceAddr: clouddiablo.com # Address of a cloud service instance, discovery can find # diff --git a/winvm/supervisord.conf b/winvm/supervisord.conf index 7408f42..7fa9cf4 100644 --- a/winvm/supervisord.conf +++ b/winvm/supervisord.conf @@ -36,7 +36,7 @@ stdout_logfile=/winevm/pulse_audio_out stderr_logfile=/winevm/pulse_audio_err [program:syncinput] -command=wine syncinput.exe %(ENV_appname)s \"%(ENV_hwkey)s\" %(ENV_dockerhost)s +command=wine syncinput.exe %(ENV_appname)s %(ENV_hwkey)s %(ENV_dockerhost)s directory=/winevm/ autostart=true autorestart=true diff --git a/winvm/syncinput.cpp b/winvm/syncinput.cpp index a33491c..45c72a0 100644 --- a/winvm/syncinput.cpp +++ b/winvm/syncinput.cpp @@ -85,7 +85,8 @@ void getDesktopResolution(int &width, int &height) HWND getWindowByTitle(char *pattern) { - HWND hwnd = NULL; + HWND hwnd = 0; + return 0; do { @@ -263,8 +264,12 @@ Mouse parseMousePayload(string stPos) return Mouse{isLeft, state, x, y, w, h}; } -void formatWindow(HWND hwnd) +void formatWindow(HWND hwnd, bool isWindowedMode) { + // deprecated, should run with window mode only + if (!isWindowedMode) { + return; + } SetWindowPos(hwnd, NULL, 0, 0, 800, 600, 0); SetWindowLong(hwnd, GWL_STYLE, 0); cout << "Window formated" << endl; @@ -298,7 +303,7 @@ void *thwndupdate(void *args) hwnd = getWindowByTitle(winTitle); if (hwnd != oldhwnd) { - formatWindow(hwnd); + formatWindow(hwnd, false); cout << "Updated HWND: " << hwnd << endl; oldhwnd = hwnd; } @@ -339,6 +344,7 @@ int main(int argc, char *argv[]) { if (strcmp(argv[2], "game") == 0) { + cout << "Running DX Game" << endl; isDxGame = true; } } @@ -356,7 +362,7 @@ int main(int argc, char *argv[]) << "height " << screenHeight << endl; cout << "Docker host" << dockerHost << endl; - formatWindow(hwnd); + formatWindow(hwnd, false); // setup socket watcher. TODO: How to check if a socket pipe is broken? done = false; From 0069f518c7b6ef5a55616841eddfb6d1966891ff Mon Sep 17 00:00:00 2001 From: giongto35 Date: Mon, 28 Jun 2021 01:46:52 +0800 Subject: [PATCH 03/11] Add GPU accelerate --- run-wine.sh | 5 +++++ winvm/Dockerfile | 14 ++++++++++++++ winvm/supervisord.conf | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/run-wine.sh b/run-wine.sh index 551aadf..79add06 100755 --- a/run-wine.sh +++ b/run-wine.sh @@ -17,6 +17,9 @@ then --env "wineoptions=$7" \ --env "dockerhost=host.docker.internal" \ --env "DISPLAY=:99" \ + #--env="DISPLAY" \ + --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine supervisord else echo "Spawn container on Linux" @@ -33,5 +36,7 @@ else --env "wineoptions=$7" \ --env "dockerhost=127.0.0.1" \ --env "DISPLAY=:99" \ + --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine supervisord fi diff --git a/winvm/Dockerfile b/winvm/Dockerfile index d1cb883..1322b83 100644 --- a/winvm/Dockerfile +++ b/winvm/Dockerfile @@ -26,11 +26,25 @@ RUN winetricks d3dx9_43 # uncomment it for lutris game #RUN winetricks --force -q dotnet48 +ENV VIRTUALGL_VERSION 2.5.2 # Download gecko and mono installers COPY download_gecko_and_mono.sh /root/download_gecko_and_mono.sh RUN chmod +x /root/download_gecko_and_mono.sh \ && /root/download_gecko_and_mono.sh "$(dpkg -s wine-stable | grep "^Version:\s" | awk '{print $2}' | sed -E 's/~.*$//')" +RUN apt-get update && apt-get install -y --no-install-recommends \ + libglu1-mesa-dev mesa-utils curl ca-certificates xterm && \ + curl -sSL https://downloads.sourceforge.net/project/virtualgl/"${VIRTUALGL_VERSION}"/virtualgl_"${VIRTUALGL_VERSION}"_amd64.deb -o virtualgl_"${VIRTUALGL_VERSION}"_amd64.deb && \ + dpkg -i virtualgl_*_amd64.deb && \ + /opt/VirtualGL/bin/vglserver_config -config +s +f -t && \ + rm virtualgl_*_amd64.deb && \ + apt-get clean && \ + apt-get remove -y curl ca-certificates && \ + rm -rf /var/lib/apt/lists/* +LABEL com.nvidia.volumes.needed="nvidia_driver" +ENV PATH /usr/local/nvidia/bin:/opt/VirtualGL/bin:${PATH} +ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}/lists/* + RUN mkdir -p /winevm WORKDIR /winevm COPY ./ ./ diff --git a/winvm/supervisord.conf b/winvm/supervisord.conf index f3ca642..72e4f19 100644 --- a/winvm/supervisord.conf +++ b/winvm/supervisord.conf @@ -5,7 +5,7 @@ loglevel=debug logfile_maxbytes=0 [program:wineapp] -command=wine %(ENV_appfile)s %(ENV_wineoptions)s +command=vglrun wine %(ENV_appfile)s %(ENV_wineoptions)s directory=%(ENV_apppath)s environment=DISPLAY=:99 autostart=true From 6c26f48b7f67f6afcda77977bc5a8fb4e26a0bd3 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Tue, 29 Jun 2021 01:34:37 +0800 Subject: [PATCH 04/11] Add VGL RUN --- config.yaml | 1 + pkg/common/config/config.go | 1 + pkg/core/go/cloudapp/cloudapp.go | 6 ++++ run-wine.sh | 50 +++++++++++++++++++++++--------- winvm/supervisord.conf | 2 +- 5 files changed, 46 insertions(+), 14 deletions(-) diff --git a/config.yaml b/config.yaml index 0885cd8..95efeed 100644 --- a/config.yaml +++ b/config.yaml @@ -6,6 +6,7 @@ appName: 7554 # App name: to show in discovery appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) hasChat: true # Turn on chat hardwareKey: true # Some game using DirectX needs hardward key. Turn this flag on to receive the input +gpuAccelerated: true # GPU acceleration with VirtualGL to replace Software Rendering with XVFB. Better performance #screenWidth: 800 # Optional: Default to be: 800 #screenHeight: 600 # Optional: Default to be: 600 #isWindowMode: false # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index e4c85f1..e040160 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -16,6 +16,7 @@ type Config struct { // To help WinAPI search the app WindowTitle string `yaml:"windowTitle"` HWKey bool `yaml:"hardwareKey"` + GPUAcc bool `yaml:"gpuAccelerated"` AppMode string `yaml:"appMode"` AppName string `yaml:"appName"` ScreenWidth int `yaml:"screenWidth"` diff --git a/pkg/core/go/cloudapp/cloudapp.go b/pkg/core/go/cloudapp/cloudapp.go index fafca59..ea6eacb 100644 --- a/pkg/core/go/cloudapp/cloudapp.go +++ b/pkg/core/go/cloudapp/cloudapp.go @@ -181,6 +181,12 @@ func (c *ccImpl) launchAppVM(curVideoRTPPort int, curAudioRTPPort int, cfg confi } else { params = append(params, "") } + if cfg.GPUAcc { + fmt.Println("using vgl run") + params = append(params, "vglrun ") + } else { + params = append(params, "") + } runApp(params) // update flag diff --git a/run-wine.sh b/run-wine.sh index 5679052..56dc62b 100755 --- a/run-wine.sh +++ b/run-wine.sh @@ -10,25 +10,46 @@ docker rm -f appvm if [ $(uname -s) == "Darwin" ] then echo "Spawn container on Mac" - docker run -d --privileged --rm --name "appvm" \ + xhost +local:root + #docker run -d --privileged --rm --name "appvm" \ + #--mount type=bind,source="$(pwd)"/apps,target=/apps \ + #--mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ + #--env "apppath=$1" \ + #--env "appfile=$2" \ + #--env "appname=$3" \ + #--env "hwkey=$4" \ + #--env "screenwidth=$5" \ + #--env "screenheight=$6" \ + #--env "wineoptions=$7" \ + #--env "vglrun=$8" \ + #--env "dockerhost=host.docker.internal" \ + #--env "DISPLAY=:99" \ + #--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + #--volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ + #--volume "winecfg:/root/.wine" syncwine supervisord +#else + #echo "Spawn container on Linux" + + nvidia-docker run -t -d --privileged --rm --name "appvm" \ --mount type=bind,source="$(pwd)"/apps,target=/apps \ --mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ - --env "apppath=$1" \ - --env "appfile=$2" \ - --env "appname=$3" \ - --env "hwkey=$4" \ - --env "screenwidth=$5" \ - --env "screenheight=$6" \ - --env "wineoptions=$7" \ - --env "dockerhost=host.docker.internal" \ + --network=host \ + --env "apppath=/" \ + --env "appfile=C:/7554/7554.exe" \ + --env "appname=7554" \ + --env "hwkey=game" \ + --env "screenwidth=800" \ + --env "screenheight=600" \ + --env "wineoptions=-w" \ + --env "vglrun=vglrun" \ + --env "dockerhost=127.0.0.1" \ --env "DISPLAY=:99" \ - #--env="DISPLAY" \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine supervisord -else - echo "Spawn container on Linux" - docker run -t -d --privileged --rm --name "appvm" \ + xhost -local:root # resetting permissions + + nvdia-docker run -t -d --privileged --rm --name "appvm" \ --mount type=bind,source="$(pwd)"/apps,target=/apps \ --mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ --network=host \ @@ -39,9 +60,12 @@ else --env "screenwidth=$5" \ --env "screenheight=$6" \ --env "wineoptions=$7" \ + --env "vglrun=$8" \ --env "dockerhost=127.0.0.1" \ --env "DISPLAY=:99" \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine supervisord fi + +xhost -local:root # resetting permissions diff --git a/winvm/supervisord.conf b/winvm/supervisord.conf index c0b733f..f8df3ca 100644 --- a/winvm/supervisord.conf +++ b/winvm/supervisord.conf @@ -5,7 +5,7 @@ loglevel=debug logfile_maxbytes=0 [program:wineapp] -command=vglrun wine %(ENV_appfile)s %(ENV_wineoptions)s +command=%(ENV_vglrun)swine %(ENV_appfile)s %(ENV_wineoptions)s directory=%(ENV_apppath)s environment=DISPLAY=:99 autostart=true From 01848ac91a451d14e4098bc419b563ec532bab73 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Wed, 30 Jun 2021 00:18:22 +0800 Subject: [PATCH 05/11] Update Dockerfile --- run-wine.sh | 54 +++++++++++++++++------------------------------- winvm/Dockerfile | 6 ++++-- 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/run-wine.sh b/run-wine.sh index 56dc62b..6b272e7 100755 --- a/run-wine.sh +++ b/run-wine.sh @@ -10,46 +10,29 @@ docker rm -f appvm if [ $(uname -s) == "Darwin" ] then echo "Spawn container on Mac" - xhost +local:root - #docker run -d --privileged --rm --name "appvm" \ - #--mount type=bind,source="$(pwd)"/apps,target=/apps \ - #--mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ - #--env "apppath=$1" \ - #--env "appfile=$2" \ - #--env "appname=$3" \ - #--env "hwkey=$4" \ - #--env "screenwidth=$5" \ - #--env "screenheight=$6" \ - #--env "wineoptions=$7" \ - #--env "vglrun=$8" \ - #--env "dockerhost=host.docker.internal" \ - #--env "DISPLAY=:99" \ - #--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ - #--volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ - #--volume "winecfg:/root/.wine" syncwine supervisord -#else - #echo "Spawn container on Linux" - - nvidia-docker run -t -d --privileged --rm --name "appvm" \ + docker run -d --privileged --rm --name "appvm" \ --mount type=bind,source="$(pwd)"/apps,target=/apps \ --mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ - --network=host \ - --env "apppath=/" \ - --env "appfile=C:/7554/7554.exe" \ - --env "appname=7554" \ - --env "hwkey=game" \ - --env "screenwidth=800" \ - --env "screenheight=600" \ - --env "wineoptions=-w" \ - --env "vglrun=vglrun" \ - --env "dockerhost=127.0.0.1" \ + --env "apppath=$1" \ + --env "appfile=$2" \ + --env "appname=$3" \ + --env "hwkey=$4" \ + --env "screenwidth=$5" \ + --env "screenheight=$6" \ + --env "wineoptions=$7" \ + --env "vglrun=$8" \ + --env "dockerhost=host.docker.internal" \ --env "DISPLAY=:99" \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine supervisord - xhost -local:root # resetting permissions +else + echo "Spawn container on Linux" - nvdia-docker run -t -d --privileged --rm --name "appvm" \ + #xhost +local:root + nvidia-docker run -t -d --privileged --rm --name "appvm" \ + --runtime=nvidia \ + -e XAUTHORITY -e NVIDIA_DRIVER_CAPABILITIES=all \ --mount type=bind,source="$(pwd)"/apps,target=/apps \ --mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ --network=host \ @@ -62,10 +45,11 @@ then --env "wineoptions=$7" \ --env "vglrun=$8" \ --env "dockerhost=127.0.0.1" \ - --env "DISPLAY=:99" \ + --env "DISPLAY=$DISPLAY" \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine supervisord + #xhost -local:root # resetting permissions fi -xhost -local:root # resetting permissions + diff --git a/winvm/Dockerfile b/winvm/Dockerfile index 1322b83..c80de0c 100644 --- a/winvm/Dockerfile +++ b/winvm/Dockerfile @@ -1,7 +1,9 @@ #FROM golang:1.14 #FROM ubuntu:18.04 -FROM ubuntu:20.04 -#FROM debian:10-slim +FROM nvidia/cudagl:11.3.1-base-ubuntu20.04 +ENV DEBIAN_FRONTEND=noninteractive +ENV NVIDIA_VISIBLE_DEVICES all +ENV NVIDIA_DRIVER_CAPABILITIES compute,graphics,utility,video RUN apt update RUN apt-get update -y From ae4a3d957d7f248b7752c6f3c2b6b232b151d50b Mon Sep 17 00:00:00 2001 From: giongto35 Date: Thu, 1 Jul 2021 02:10:37 +0800 Subject: [PATCH 06/11] Retro --- config.yaml | 14 +++++++------- run-wine.sh | 24 ++++++++++++++++++++---- winvm/Dockerfile | 3 +++ winvm/supervisord.conf | 5 +++-- winvm/syncinput.cpp | 1 - 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/config.yaml b/config.yaml index 95efeed..a70b152 100644 --- a/config.yaml +++ b/config.yaml @@ -1,6 +1,6 @@ -path: / # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II -appFile: C:/7554/7554.exe # File Name of the app in the directory -windowTitle: 7554 # Window Title: not to show, it's the substring of title to help specify the running program in OS +#path: / # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II +#appFile: C:/7554/7554.exe # File Name of the app in the directory +#windowTitle: 7554 # Window Title: not to show, it's the substring of title to help specify the running program in OS pageTitle: "7554 - Learn History of Vietnam" # Page Title: To display on webpage appName: 7554 # App name: to show in discovery appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) @@ -13,14 +13,14 @@ gpuAccelerated: true # GPU acceleration with VirtualGL to replace Software Rende # discoveryHost: http://discovery.cloudmorph.io # Optional: to be discoverable if you plug-in to the discovery server # instanceAddr: clouddiablo.com # Address of a cloud service instance, discovery can find -#path: /apps/RetroBlockGame3D_Data # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II -#appFile: RetroBlockGame3D.exe # File Name of the app in the directory -#windowTitle: RetroBlockGame3D # Window Title: not to show, it's the substring of title to help specify the running program in OS +path: /apps/RetroBlockGame3D_Data # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II +appFile: RetroBlockGame3D.exe # File Name of the app in the directory +windowTitle: RetroBlockGame3D # Window Title: not to show, it's the substring of title to help specify the running program in OS #pageTitle: "RetroBlock" # Page Title: To display on webpage #appName: RetroBlock # App name: to show in discovery #appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) #hasChat: true # Turn on chat -#hardwareKey: true # Some game using DirectX needs hardward key. Turn this flag on to receive the input +hardwareKey: false # Some game using DirectX needs hardward key. Turn this flag on to receive the input #screenWidth: 800 # Optional: Default to be: 800 #screenHeight: 600 # Optional: Default to be: 600 #isWindowMode: false # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app diff --git a/run-wine.sh b/run-wine.sh index 6b272e7..d39891f 100755 --- a/run-wine.sh +++ b/run-wine.sh @@ -10,7 +10,7 @@ docker rm -f appvm if [ $(uname -s) == "Darwin" ] then echo "Spawn container on Mac" - docker run -d --privileged --rm --name "appvm" \ + docker run -d --privileged --name "appvm" \ --mount type=bind,source="$(pwd)"/apps,target=/apps \ --mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ --env "apppath=$1" \ @@ -29,10 +29,26 @@ then else echo "Spawn container on Linux" - #xhost +local:root + XAUTH=/tmp/.docker.xauth + if [ ! -f $XAUTH ] + then + xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/') + if [ ! -z "$xauth_list" ] + then + echo $xauth_list | xauth -f $XAUTH nmerge - + else + touch $XAUTH + fi + chmod a+r $XAUTH + fi + + xhost +local:root nvidia-docker run -t -d --privileged --rm --name "appvm" \ --runtime=nvidia \ - -e XAUTHORITY -e NVIDIA_DRIVER_CAPABILITIES=all \ + --env NVIDIA_DRIVER_CAPABILITIES=all \ + --env="XAUTHORITY=$XAUTH" \ + --volume="$XAUTH:$XAUTH" \ + --env="QT_X11_NO_MITSHM=1" \ --mount type=bind,source="$(pwd)"/apps,target=/apps \ --mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ --network=host \ @@ -45,7 +61,7 @@ else --env "wineoptions=$7" \ --env "vglrun=$8" \ --env "dockerhost=127.0.0.1" \ - --env "DISPLAY=$DISPLAY" \ + --env "DISPLAY=:99" \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine supervisord diff --git a/winvm/Dockerfile b/winvm/Dockerfile index c80de0c..0663756 100644 --- a/winvm/Dockerfile +++ b/winvm/Dockerfile @@ -29,6 +29,8 @@ RUN winetricks d3dx9_43 #RUN winetricks --force -q dotnet48 ENV VIRTUALGL_VERSION 2.5.2 +#RUN nohup Xvfb :99 & +ENV DISPLAY=:99 # Download gecko and mono installers COPY download_gecko_and_mono.sh /root/download_gecko_and_mono.sh RUN chmod +x /root/download_gecko_and_mono.sh \ @@ -54,4 +56,5 @@ COPY ./default.pa /etc/pulse/ # Compile syncinput.exe RUN x86_64-w64-mingw32-g++ ./syncinput.cpp -o /winevm/syncinput.exe -lws2_32 -lpthread -static +RUN DISPLAY=:99 /opt/VirtualGL/bin/vglserver_config -config +s +f -t COPY ./supervisord.conf /etc/supervisor/conf.d/ diff --git a/winvm/supervisord.conf b/winvm/supervisord.conf index f8df3ca..07331d1 100644 --- a/winvm/supervisord.conf +++ b/winvm/supervisord.conf @@ -7,7 +7,7 @@ logfile_maxbytes=0 [program:wineapp] command=%(ENV_vglrun)swine %(ENV_appfile)s %(ENV_wineoptions)s directory=%(ENV_apppath)s -environment=DISPLAY=:99 +environment=DISPLAY=:99,VGL_DISPLAY=:1 autostart=true autorestart=true startsecs=5 @@ -17,7 +17,8 @@ stderr_logfile=/winevm/wineapp_err [program:Xvfb] /*command=/usr/bin/Xvfb :99 -screen 0 800x600x16*/ -command=/usr/bin/Xvfb :99 -screen 0 800x600x24+32 +/*command=/usr/bin/Xvfb :99 -screen 0 800x600x24+32*/ +command=/usr/bin/Xvfb :99 -screen 0 800x600x24+32 +extension GLX +render -noreset autostart=true autorestart=true startsecs=5 diff --git a/winvm/syncinput.cpp b/winvm/syncinput.cpp index 45c72a0..18b1cee 100644 --- a/winvm/syncinput.cpp +++ b/winvm/syncinput.cpp @@ -86,7 +86,6 @@ void getDesktopResolution(int &width, int &height) HWND getWindowByTitle(char *pattern) { HWND hwnd = 0; - return 0; do { From cc44971739066122817a8bfc5b9430f110508317 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Thu, 1 Jul 2021 22:09:45 +0800 Subject: [PATCH 07/11] Update test script --- test.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 test.sh diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..90d1cb2 --- /dev/null +++ b/test.sh @@ -0,0 +1,32 @@ +docker rm -f apptest + +#nvidia-docker run -it --privileged --rm --name "appvm" \ +#--runtime=nvidia \ +#-e XAUTHORITY -e NVIDIA_DRIVER_CAPABILITIES=all \ +#--env "DISPLAY=$DISPLAY" \ +#--network=host \ +#--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ +#--volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ +#--volume "winecfg:/root/.wine" syncwine bash + +#[/ C:/7554/7554.exe 7554 game 800 600 -w vglrun ] +nvidia-docker run -it --privileged --rm --name "apptest" \ +--runtime=nvidia \ +-e XAUTHORITY -e NVIDIA_DRIVER_CAPABILITIES=all \ +--network=host \ +--env "apppath=/" \ +--env "appfile=C:/7554/7554.exe" \ +--env "appname=7554" \ +--env "hwkey=game" \ +--env "screenwidth=800" \ +--env "screenheight=600" \ +--env "wineoptions=-w" \ +--env "vglrun=vglrun" \ +--env "dockerhost=127.0.0.1" \ +--env "DISPLAY=:99" \ +--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ +--volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ +--volume "winecfg:/root/.wine" vglrun syncwine glxinfo | grep vendor +#xhost -local:root # resetting permissions +#--mount type=bind,source="$(pwd)"/apps,target=/apps \ +#--mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ From 6f287db60e526b180751cfc1177ec6f6a568dfc9 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Fri, 2 Jul 2021 16:26:18 +0800 Subject: [PATCH 08/11] Fix --- run-wine.sh | 25 ++++++++++++++++++++++++- test.sh | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/run-wine.sh b/run-wine.sh index d39891f..c7861f7 100755 --- a/run-wine.sh +++ b/run-wine.sh @@ -62,10 +62,33 @@ else --env "vglrun=$8" \ --env "dockerhost=127.0.0.1" \ --env "DISPLAY=:99" \ + --env NVIDIA_DISABLE_REQUIRE=1 \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine supervisord #xhost -local:root # resetting permissions fi - + #nvidia-docker run -it --privileged --rm --name "appvm" \ + #--runtime=nvidia \ + #--env NVIDIA_DRIVER_CAPABILITIES=all \ + #--env="XAUTHORITY=$XAUTH" \ + #--volume="$XAUTH:$XAUTH" \ + #--env="QT_X11_NO_MITSHM=1" \ + #--mount type=bind,source="$(pwd)"/apps,target=/apps \ + #--mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ + #--network=host \ + #--env "apppath=/apps/RetroBlockGame3D_Data" \ + #--env "appfile=RetroBlockGame3D.exe" \ + #--env "appname=Retro" \ + #--env "hwkey=game" \ + #--env NVIDIA_DISABLE_REQUIRE=1 \ + #--env "screenwidth=800" \ + #--env "screenheight=600" \ + #--env "wineoptions=-w" \ + #--env "vglrun=vglrun" \ + #--env "dockerhost=127.0.0.1" \ + #--env "DISPLAY=:99" \ + #--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + #--volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ + #--volume "winecfg:/root/.wine" syncwine supervisord diff --git a/test.sh b/test.sh index 90d1cb2..c1e09b1 100755 --- a/test.sh +++ b/test.sh @@ -26,7 +26,7 @@ nvidia-docker run -it --privileged --rm --name "apptest" \ --env "DISPLAY=:99" \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ ---volume "winecfg:/root/.wine" vglrun syncwine glxinfo | grep vendor +--volume "winecfg:/root/.wine" syncwine vglrun glxinfo | grep vendor #xhost -local:root # resetting permissions #--mount type=bind,source="$(pwd)"/apps,target=/apps \ #--mount type=bind,source="$(pwd)"/supervisord.conf,target=/etc/supervisor/conf.d/supervisord.conf \ From 5a314add433a9d4cd5718452b174da2154ef5c14 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Sat, 3 Jul 2021 03:23:30 +0800 Subject: [PATCH 09/11] Fix --- test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test.sh b/test.sh index c1e09b1..bb69880 100755 --- a/test.sh +++ b/test.sh @@ -24,6 +24,7 @@ nvidia-docker run -it --privileged --rm --name "apptest" \ --env "vglrun=vglrun" \ --env "dockerhost=127.0.0.1" \ --env "DISPLAY=:99" \ +--env NVIDIA_DISABLE_REQUIRE=1 \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine vglrun glxinfo | grep vendor From 3ab499ccf305fbff0833e7b6bd651480cca3674e Mon Sep 17 00:00:00 2001 From: giongto35 Date: Tue, 6 Jul 2021 02:05:34 +0800 Subject: [PATCH 10/11] Clean up --- config.yaml | 30 +++++------------------------- winvm/Dockerfile | 3 --- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/config.yaml b/config.yaml index a70b152..9d20bb5 100644 --- a/config.yaml +++ b/config.yaml @@ -1,29 +1,9 @@ -#path: / # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II -#appFile: C:/7554/7554.exe # File Name of the app in the directory -#windowTitle: 7554 # Window Title: not to show, it's the substring of title to help specify the running program in OS -pageTitle: "7554 - Learn History of Vietnam" # Page Title: To display on webpage -appName: 7554 # App name: to show in discovery +path: /apps/RetroBlockGame3D_Data # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II +appFile: RetroBlockGame3D.exe # File Name of the app in the directory +windowTitle: RetroBlockGame3D # Window Title: not to show, it's the substring of title to help specify the running program in OS +pageTitle: "RetroBlockGame3D" # Page Title: To display on webpage +appName: RetroBlockGame3D # App name: to show in discovery appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) hasChat: true # Turn on chat hardwareKey: true # Some game using DirectX needs hardward key. Turn this flag on to receive the input gpuAccelerated: true # GPU acceleration with VirtualGL to replace Software Rendering with XVFB. Better performance -#screenWidth: 800 # Optional: Default to be: 800 -#screenHeight: 600 # Optional: Default to be: 600 -#isWindowMode: false # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app -# discoveryHost: http://discovery.cloudmorph.io # Optional: to be discoverable if you plug-in to the discovery server -# instanceAddr: clouddiablo.com # Address of a cloud service instance, discovery can find - -path: /apps/RetroBlockGame3D_Data # Directory to the app. NOTE: It's the path in docker. EX: /apps/Diablo II -appFile: RetroBlockGame3D.exe # File Name of the app in the directory -windowTitle: RetroBlockGame3D # Window Title: not to show, it's the substring of title to help specify the running program in OS -#pageTitle: "RetroBlock" # Page Title: To display on webpage -#appName: RetroBlock # App name: to show in discovery -#appMode: collaborative # app mode: collaborative/single (ex. collaborative: multiple user using same game session) -#hasChat: true # Turn on chat -hardwareKey: false # Some game using DirectX needs hardward key. Turn this flag on to receive the input -#screenWidth: 800 # Optional: Default to be: 800 -#screenHeight: 600 # Optional: Default to be: 600 -#isWindowMode: false # Optional: Default to be true. Full screen Windowed or Fullscreen. Up to app -# discoveryHost: http://discovery.cloudmorph.io # Optional: to be discoverable if you plug-in to the discovery server -# instanceAddr: clouddiablo.com # Address of a cloud service instance, discovery can find -# diff --git a/winvm/Dockerfile b/winvm/Dockerfile index 0663756..c80de0c 100644 --- a/winvm/Dockerfile +++ b/winvm/Dockerfile @@ -29,8 +29,6 @@ RUN winetricks d3dx9_43 #RUN winetricks --force -q dotnet48 ENV VIRTUALGL_VERSION 2.5.2 -#RUN nohup Xvfb :99 & -ENV DISPLAY=:99 # Download gecko and mono installers COPY download_gecko_and_mono.sh /root/download_gecko_and_mono.sh RUN chmod +x /root/download_gecko_and_mono.sh \ @@ -56,5 +54,4 @@ COPY ./default.pa /etc/pulse/ # Compile syncinput.exe RUN x86_64-w64-mingw32-g++ ./syncinput.cpp -o /winevm/syncinput.exe -lws2_32 -lpthread -static -RUN DISPLAY=:99 /opt/VirtualGL/bin/vglserver_config -config +s +f -t COPY ./supervisord.conf /etc/supervisor/conf.d/ From f3b231bf3524d46d8d91ccc915ec6a93fd4c8a35 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Fri, 9 Jul 2021 16:43:16 +0800 Subject: [PATCH 11/11] Fix --- run-wine.sh | 2 ++ winvm/supervisord.conf | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/run-wine.sh b/run-wine.sh index c7861f7..786589d 100755 --- a/run-wine.sh +++ b/run-wine.sh @@ -23,6 +23,7 @@ then --env "vglrun=$8" \ --env "dockerhost=host.docker.internal" \ --env "DISPLAY=:99" \ + --env "VGL_DISPLAY=:1" \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ --volume "winecfg:/root/.wine" syncwine supervisord @@ -62,6 +63,7 @@ else --env "vglrun=$8" \ --env "dockerhost=127.0.0.1" \ --env "DISPLAY=:99" \ + --env "VGL_DISPLAY=:1" \ --env NVIDIA_DISABLE_REQUIRE=1 \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --volume="/usr/lib/x86_64-linux-gnu/libXv.so.1:/usr/lib/x86_64-linux-gnu/libXv.so.1" \ diff --git a/winvm/supervisord.conf b/winvm/supervisord.conf index 07331d1..3b8d455 100644 --- a/winvm/supervisord.conf +++ b/winvm/supervisord.conf @@ -7,7 +7,6 @@ logfile_maxbytes=0 [program:wineapp] command=%(ENV_vglrun)swine %(ENV_appfile)s %(ENV_wineoptions)s directory=%(ENV_apppath)s -environment=DISPLAY=:99,VGL_DISPLAY=:1 autostart=true autorestart=true startsecs=5 @@ -16,8 +15,6 @@ stdout_logfile=/winevm/wineapp_out stderr_logfile=/winevm/wineapp_err [program:Xvfb] -/*command=/usr/bin/Xvfb :99 -screen 0 800x600x16*/ -/*command=/usr/bin/Xvfb :99 -screen 0 800x600x24+32*/ command=/usr/bin/Xvfb :99 -screen 0 800x600x24+32 +extension GLX +render -noreset autostart=true autorestart=true @@ -28,7 +25,6 @@ stderr_logfile=/winevm/xvfb_err [program:pulseaudio] command=pulseaudio --exit-idle-time=-1 -/*command=pulseaudio --disallow-exit --disallow-module-loading --exit-idle-time=-1*/ autostart=true autorestart=true startsecs=5