[[PageOutline]]
{{{
#!html
實作八:VMGL 實作
}}}
----
= 【Step 1: 在 Dom0 上安裝 VMGL 】 =
* 安裝環境所需套件.
{{{
$ sudo apt-get install build-essential firefox flashplugin-nonfree htop libao2 libasound2 libmikmod2 mesa-common-dev libglu1-mesa-dev mesa-utils libxmu-headers libxmu6 libxmu-dev zlib1g-dev libjpeg62 libjpeg62-dev xutils-dev libxext6 libxext-dev rxvt lwm tightvncserver xauth xvfb xfonts-100dpi xfonts-75dpi culmus xfonts-scalable xfonts-base
}}}
* 下載VMGL.
{{{
$ wget !http://www.cs.toronto.edu/~andreslc/software/vmgl-0.1.tar.bz2
$ tar jxvf vmgl-0.1.tar.bz2
$ cd ./vmgl.hg/tightvnc/
}}}
* Patch for AMD64_Machine.
{{{
$ wget --no-check-certificate !https://trac.nchc.org.tw/grid/raw-attachment/wiki/Xen_GPU_cluster/tightvnc-1.2.9-amd64support.patch
$ patch -p0 < ../../tightvnc-1.2.9-amd64support.patch
}}}
* 設定編譯器路徑.
{{{
$ sudo ln -sf /usr/bin/make /usr/bin/gmake (if necessary)
}}}
* 編譯.
{{{
~/vmgl/vmgl.hg$ make
}}}
* 安裝於 Dom0(host) 端上.
{{{
~/vmgl/vmgl.hg$ sudo make install-host
}}}
* 設定主機信任清單. 在 Dom0 加入 DomU 的 COOKIE.
{{{
$ xauth
}}}
* 為遠端使用者設定存取權.
{{{
#!sh
Using authority file /home/rider/.Xauthority
xauth> add guest/unix:10 MIT-MAGIC-COOKIE-1 ec0ffd387888b9749d55f88031505888 -> guest 端的 VMGL DISPLAY:10
xauth> add guest/unix:1 MIT-MAGIC-COOKIE-1 6824789b4ce0ac5743aeb57fd3ef8f5b -> guest 端的 VNC DISPLAY:1
xauth> exit
}}}
* 檢視存取權清單.
{{{
$ xauth list
}}}
{{{
#!sh
guest:1 MIT-MAGIC-COOKIE-1 5c53c8c640b816d7714e23d5cfcd9a8e
cloud/unix:1 MIT-MAGIC-COOKIE-1 5c53c8c640b816d7714e23d5cfcd9a8e
guest:2 MIT-MAGIC-COOKIE-1 5bfe43007be14ca93e9ee5fc71701463
cloud/unix:2 MIT-MAGIC-COOKIE-1 5bfe43007be14ca93e9ee5fc71701463
guest:3 MIT-MAGIC-COOKIE-1 04499062b48a199921e859ee76d267ab
cloud/unix:3 MIT-MAGIC-COOKIE-1 04499062b48a199921e859ee76d267ab
guest/unix:10 MIT-MAGIC-COOKIE-1 ec0ffd387888b9749d55f88031505888
guest/unix:1 MIT-MAGIC-COOKIE-1 6824789b4ce0ac5743aeb57fd3ef8f5b
guest/unix:2 MIT-MAGIC-COOKIE-1 98e85e7e551246d428023b54b5dff02b
cloud/unix:0 MIT-MAGIC-COOKIE-1 b5f3b4b4f9d0e63e8f9b88a6d57fad15
localhost:0 MIT-MAGIC-COOKIE-1 b5f3b4b4f9d0e63e8f9b88a6d57fad15
}}}
----
= 【Step 2: 建構一台 VMGL Guest VM 】 =
* 設定你想要怎樣規格的虛擬機器.
{{{
$ sudo vim /etc/xen-tools/xen-tools.conf
}}}
{{{
#!sh
dir = /home
install-method = debootstrap
size = 8Gb # Disk image size.
memory = 1024Mb # Memory size
swap = 128Mb # Swap size
fs = ext3 # use the EXT3 filesystem for the disk image.
dist = hardy # Default distribution to install. ---> For CUDA Support (Ubuntu 8.0.4)
image = sparse # Specify sparse vs. full disk images.
gateway = 140.XXX.XXX.XXX
netmask = 255.255.255.0
broadcast = 140.XXX.XXX.XXX
kernel = /boot/vmlinuz-`uname -r`
initrd = /boot/initrd.img-`uname -r`
mirror = http://free.nchc.org.tw/ubuntu/
ext3_options = noatime,nodiratime,errors=remount-ro
ext2_options = noatime,nodiratime,errors=remount-ro
xfs_options = defaults
reiser_options = defaults
}}}
{{{
$ sudo xen-create-image --hostname node1 --ip xxx.XXX.XXX.XXX
}}}
----
= 【Step 3: 設定虛擬機器(Guest)】 =
{{{
$ sudo vim /etc/xen/node1.cfg
}}}
{{{
#!sh
kernel = '/boot/vmlinuz-2.6.22.9'
ramdisk = '/boot/initrd.img-2.6.22.9'
memory = '1024'
vcpus = '4'
# 不需配置 PCIE 顯示卡
# pci = ['01:00.0']
root = '/dev/sda2 ro'
disk = [
'file:/home/domains/nvidia/disk.img,sda2,w',
'file:/home/domains/nvidia/swap.img,sda1,w',
]
name = 'node1'
#
# Networking
#
vif = [ 'ip=xxx.xxx.xxx.xxx,mac=00:16:3E:AA:70:5C' ]
#
# Behaviour
#
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
}}}
----
= 【Step 4: 在 DomU(Guest) 上安裝 VMGL 】 =
* 啟動虛擬機器Guest並登入.
'''# 方法一.''' [[BR]]
{{{
$ sudo xm create -c guest.cfg
}}}
'''# 方法二.''' [[BR]]
* @Dom0 [[BR]]
{{{
$ sudo xm create guest.cfg
}}}
* @!ClientUser
{{{
$ ssh xxx.xxx.xxx.xxx
}}}
* 安裝環境所需套件.
{{{
~$ sudo apt-get install build-essential firefox flashplugin-nonfree htop mozilla-plugin-vlc libao2 libasound2 libmikmod2 mesa-common-dev libglu1-mesa-dev mesa-utils libxmu-headers libxmu6 libxmu-dev zlib1g-dev libjpeg62 libjpeg62-dev xutils-dev libxaw-headers libxaw7 libxaw7-dev libxext6 libxext-dev rxvt lwm vlc vlc-plugin-alsa tightvncserver xauth xvfb xfonts-100dpi xfonts-75dpi culmus xfonts-scalable xfonts-base
}}}
* 基本桌面環境.
{{{
#!sh
# Desgin for lightweight X support
xfonts-base xfonts-100dpi xfonts-75dpi -> fonts support
rxvt -> x-terminal-emulator for VNC
lwm -> x-window-manager for VNC
}}}
* 下載VMGL.
{{{
$ mkdir -p vmgl
$ cd ./vmgl
~/vmgl$ wget !http://www.cs.toronto.edu/~andreslc/software/vmgl-0.1.tar.bz2
~/vmgl$ wget !http://trac.nchc.org.tw/grid/raw-attachment/wiki/Xen_GPU_cluster/tightvnc-1.2.9-amd64support.patch
~/vmgl$ tar jxvf vmgl-0.1.tar.bz2
~/vmgl$ cd ./vmgl.hg/tightvnc/
}}}
* Patch for AMD64_Machine.
{{{
~/vmgl/vmgl.hg/tightvnc$ patch -p0 < ../../tightvnc-1.2.9-amd64support.patch
~/vmgl$ cd ..
}}}
* 設定編譯器路徑.
{{{
~/vmgl$ sudo ln -sf /usr/bin/make /usr/bin/gmake (if necessary)
}}}
* 建立安裝所需基本目錄.
{{{
~/vmgl/vmgl.hg$ sudo mkdir -p /usr/lib/xorg/modules/extensions (if necessary)
}}}
* 編譯.
{{{
~/vmgl/vmgl.hg$ make
}}}
* 安裝於 DomU(guest) 端上.
{{{
~/vmgl/vmgl.hg$ sudo make install-guest
}}}
* 修正 rgb PATH 問題.
{{{
~/vmgl/vmgl.hg$ sudo mkdir -p /usr/X11R6/lib/X11
~/vmgl/vmgl.hg$ sudo ln -sf /etc/X11/rgb.txt /usr/X11R6/lib/X11/rgb
}}}
----
= 【Step 5: 在 DomU(Guest) 上安裝輕量級桌面環境(LXDE)】 =
* 切換身份為 Super user.
{{{
$ sudo su
}}}
* 加入 LXDE 的 source.
{{{
$ echo "deb !http://ppa.launchpad.net/lxde/ubuntu hardy main" >> /etc/apt/sources.list
$ echo "deb-src !http://ppa.launchpad.net/lxde/ubuntu hardy main" >> /etc/apt/sources.list
$ exit
}}}
* 安裝 LXDE.
{{{
$ sudo apt-get install lxde openbox-themes gnome-settings-daemon gnome-settings-daemon-dev gnome-icon-theme
}}}
* 預設 LXDE 為VNC桌面環境.
{{{
$ echo "startlxde &" >> .vnc/xstartup
}}}
* 基本桌面環境.
{{{
#!sh
# Desgin for lightweight X support
lxde -> Lightweight X11 Desktop Environment
openbox -> X-window-manager for VNC
}}}
----
= 【Step 6: VMGL 使用說明: 在Dom0 上的設定】 =
* 將 X-Windows 桌面 export 出來.
{{{
$ export DISPLAY=:0
}}}
* 啟動 VLGL stub-daemon.
{{{
rider@cloud:~$ stub-daemon
}}}
* 檢查 stub-daemon 所對應的 port(7000) 有無開啟.
{{{
$ netstat -tunlp
}}}
{{{
#!sh
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8002 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:7000 0.0.0.0:* LISTEN 29082/stub-daemon ---> VMGL stub-daemon
udp 0 0 0.0.0.0:32769 0.0.0.0:* -
udp 0 0 0.0.0.0:5353 0.0.0.0:* -
}}}
----
= 【Step 7: VMGL 使用說明: 在DomU 上的設定】 =
* 設定 DomU 上的字型路徑對應.
{{{
$ sudo ln -sf /usr/share/fonts/X11/ /usr/X11R6/lib/X11/fonts (if necessary - fix font path)
}}}
{{{
#!sh
# FontPath:
/usr/X11R6/lib/X11/fonts
or
/usr/share/fonts/X11
}}}
* 確認 rgb 存在於對應路徑.
{{{
$ less /usr/X11R6/lib/X11/rgb.txt (if necessary - rgb path confirmation)
}}}
* 設定 DomU 上的 VMGL 環境變數.
{{{
$ sudo vim /etc/profile
}}}
{{{
#!sh
GLSTUB=IP:7000
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/vmgl
LD_PRELOAD=/usr/local/lib/vmgl/libGL.so
export GLSTUB LD_LIBRARY_PATH LD_PRELOAD
}}}
{{{
$ source /etc/profile
}}}
* 設定 DomU 上的 X forwarding.
* Using X forwarding.
{{{
$ sudo vim /etc/ssh/sshd_config
}}}
{{{
#!sh
X11Forwarding yes
}}}
{{{
$ sudo vim /etc/ssh/ssh_config
}}}
{{{
#!sh
ForwardX11 yes
ForwardX11Trusted yes
}}}
* 重新啟動 DomU 上的 SSH Service.
{{{
$ sudo /etc/init.d/ssh restart
}}}
* 設定 VNC server 使用者密碼.
{{{
$ vncpasswd
}}}
* 啟動 VNC server.
{{{
$ vncserver
}}}
{{{
#!sh
xauth: creating new authority file /home/gtd/.Xauthority
New 'X' desktop is guest:1
Creating default startup script /home/gtd/.vnc/xstartup
Starting applications specified in /home/gtd/.vnc/xstartup
Log file is /home/gtd/.vnc/guest:1.log
}}}
* 關閉 VNC server.
{{{
$ vncserver -kill :1
}}}
* 設定 VNC server 啟動參數.
{{{
$ vim .vnc/xstartup
}}}
{{{
#!sh
# xrdb $HOME/.Xresources
}}}
* 開啟 DomU 上的第一台VNC Server,並指定解析度為 1024 x 768.
{{{
$ vncserver -geometry 1024x768 -depth 24 :1
}}}
* 檢查 VNCserver 有無開啟對應之 port(5901開始).
{{{
$ netstat -tunlp
}}}
{{{
#!sh
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 10652/Xtightvnc ---> guest:1
tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 10630/Xtightvnc
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 10652/Xtightvnc ---> guest:2
tcp 0 0 0.0.0.0:6002 0.0.0.0:* LISTEN 10630/Xtightvnc
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:6010 :::* LISTEN -
}}}
* 將 VNC Server:1 export 出來.
{{{
$ export DISPLAY=:1
}}}
----
= 【Step 8: 在 Dom0 上 透過 X forwarding 登入 DomU 】 =
* 使用 X forwarding 的方式登入 DomU.
* Using X forwarding.
{{{
$ ssh -X guest
}}}
* 檢查 direct rendering 有無起來.
{{{
$ glxinfo
}}}
{{{
#!sh
name of display: localhost:10.0
display: localhost:10 screen: 0
direct rendering: Yes
server glx vendor string: VMGL
server glx version string: 1.2 VMGL
server glx extensions:
client glx vendor string: VMGL
client glx version string: 1.2 VMGL
client glx extensions:
GLX version: 1.3
GLX extensions:
OpenGL extensions:
GL_ARB_depth_texture, GL_ARB_fragment_program, GL_ARB_multisample,
GL_ARB_multitexture, GL_ARB_occlusion_query, GL_ARB_point_parameters,
GL_ARB_point_sprite, GL_ARB_shadow, GL_ARB_texture_border_clamp,
GL_ARB_texture_compression, GL_ARB_texture_cube_map,
GL_ARB_texture_env_add, GL_ARB_texture_env_combine,
GL_EXT_texture_env_combine, GL_ARB_texture_env_dot3,
GL_EXT_texture_env_dot3, GL_ARB_texture_mirrored_repeat,
GL_ARB_texture_non_power_of_two, GL_ARB_transpose_matrix,
GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_window_pos,
GL_EXT_blend_color, GL_EXT_blend_minmax, GL_EXT_blend_func_separate,
GL_EXT_blend_subtract, GL_EXT_texture_env_add, GL_EXT_fog_coord,
GL_EXT_multi_draw_arrays, GL_EXT_secondary_color, GL_EXT_shadow_funcs,
GL_EXT_stencil_wrap, GL_EXT_texture_cube_map, GL_EXT_texture_edge_clamp,
GL_EXT_texture_filter_anisotropic, GL_EXT_texture_lod_bias,
GL_EXT_texture_object, GL_EXT_texture3D, GL_EXT_bgra,
GL_IBM_rasterpos_clip, GL_NV_fog_distance, GL_NV_fragment_program,
GL_NV_register_combiners, GL_NV_register_combiners2,
GL_NV_texgen_reflection, GL_NV_texture_rectangle, GL_NV_vertex_program,
GL_NV_vertex_program1_1, GL_NV_vertex_program2, GL_SGIS_generate_mipmap,
GL_CR_state_parameter, GL_CR_cursor_position, GL_CR_bounding_box,
GL_CR_print_string, GL_CR_tilesort_info, GL_CR_synchronization,
GL_CR_head_spu_name, GL_CR_performance_info, GL_CR_window_size,
GL_CR_tile_info, GL_CR_saveframe, GL_CR_readback_barrier_size,
GL_CR_server_id_sharing, GL_CR_server_matrix
GLX_ARB_multisample
OpenGL vendor string: H. Andres Lagar-Cavilla
OpenGL renderer string: VMGL
OpenGL version string: 1.5 VMGL 1.9
0x52 24 dc 0 32 0 r y . 8 8 8 0 4 24 8 16 16 16 16 2 1 None
0x53 24 dc 0 32 0 r y . 8 8 8 8 4 24 8 16 16 16 16 2 1 None
0x54 24 dc 0 32 0 r y . 8 8 8 0 4 24 8 16 16 16 16 4 1 None
0x55 24 dc 0 32 0 r y . 8 8 8 8 4 24 8 16 16 16 16 4 1 None
0x56 24 dc 0 32 0 r . . 8 8 8 0 4 24 8 16 16 16 16 2 1 None
0x57 24 dc 0 32 0 r . . 8 8 8 8 4 24 8 16 16 16 16 2 1 None
0x58 24 dc 0 32 0 r . . 8 8 8 0 4 24 8 16 16 16 16 4 1 None
0x59 24 dc 0 32 0 r . . 8 8 8 8 4 24 8 16 16 16 16 4 1 None
0x23 32 tc 0 32 0 r y . 8 8 8 0 4 24 8 16 16 16 16 0 0 None
0x5a 32 tc 0 32 0 r y . 8 8 8 8 4 24 8 16 16 16 16 0 0 None
0x5b 32 tc 0 32 0 r . . 8 8 8 0 4 24 8 16 16 16 16 0 0 None
0x5c 32 tc 0 32 0 r . . 8 8 8 8 4 24 8 16 16 16 16 0 0 None
0x5d 32 tc 0 32 0 r y . 8 8 8 0 4 24 0 16 16 16 16 0 0 None
0x5e 32 tc 0 32 0 r y . 8 8 8 8 4 24 0 16 16 16 16 0 0 None
0x5f 32 tc 0 32 0 r . . 8 8 8 0 4 24 0 16 16 16 16 0 0 None
0x60 32 tc 0 32 0 r . . 8 8 8 8 4 24 0 16 16 16 16 0 0 None
0x61 32 tc 0 32 0 r y . 8 8 8 0 4 0 0 16 16 16 16 0 0 None
0x62 32 tc 0 32 0 r y . 8 8 8 8 4 0 0 16 16 16 16 0 0 None
0x63 32 tc 0 32 0 r . . 8 8 8 0 4 0 0 16 16 16 16 0 0 None
0x64 32 tc 0 32 0 r . . 8 8 8 8 4 0 0 16 16 16 16 0 0 None
0x65 32 tc 0 32 0 r y . 8 8 8 0 4 24 0 16 16 16 16 2 1 None
0x66 32 tc 0 32 0 r y . 8 8 8 8 4 24 0 16 16 16 16 2 1 None
0x67 32 tc 0 32 0 r y . 8 8 8 0 4 24 0 16 16 16 16 4 1 None
0x68 32 tc 0 32 0 r y . 8 8 8 8 4 24 0 16 16 16 16 4 1 None
0x69 32 tc 0 32 0 r . . 8 8 8 0 4 24 0 16 16 16 16 2 1 None
0x6a 32 tc 0 32 0 r . . 8 8 8 8 4 24 0 16 16 16 16 2 1 None
0x6b 32 tc 0 32 0 r . . 8 8 8 0 4 24 0 16 16 16 16 4 1 None
0x6c 32 tc 0 32 0 r . . 8 8 8 8 4 24 0 16 16 16 16 4 1 None
0x6d 32 tc 0 32 0 r y . 8 8 8 0 4 24 8 16 16 16 16 2 1 None
0x6e 32 tc 0 32 0 r y . 8 8 8 8 4 24 8 16 16 16 16 2 1 None
0x6f 32 tc 0 32 0 r y . 8 8 8 0 4 24 8 16 16 16 16 4 1 None
0x70 32 tc 0 32 0 r y . 8 8 8 8 4 24 8 16 16 16 16 4 1 None
0x71 32 tc 0 32 0 r . . 8 8 8 0 4 24 8 16 16 16 16 2 1 None
0x72 32 tc 0 32 0 r . . 8 8 8 8 4 24 8 16 16 16 16 2 1 None
0x73 32 tc 0 32 0 r . . 8 8 8 0 4 24 8 16 16 16 16 4 1 None
0x74 32 tc 0 32 0 r . . 8 8 8 8 4 24 8 16 16 16 16 4 1 None
}}}
{{{
#!sh
# Note: please do not run stub-daemon with "root"
}}}
* DomU 上的 glxgears 效能測試.
{{{
$ glxgears
}}}
{{{
#!sh
47819 frames in 5.0 seconds = 9563.678 FPS
46064 frames in 5.0 seconds = 9212.566 FPS
44584 frames in 5.0 seconds = 8916.581 FPS
44256 frames in 5.0 seconds = 8850.974 FPS
44688 frames in 5.0 seconds = 8937.528 FPS
}}}
----
【討論 & 休息】
[[BR]]
[[BR]]