[[PageOutline]]
{{{
#!html
Demo(二):VMGL 操作手冊
}}}
----
= 【前言】 =
* '''''小叮嚀__'''''
* 請使用 gcc-4.1 來編譯 VMGL,勿使用 gcc-4.3.
* 必要時請切換 gcc 版本,可以使用 update-alternatives 或是重新建立 gcc 連結.
{{{
$ sudo update-alternatives --config gcc
}}}
----
= 【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
}}}
* 編譯.
{{{
~/vmgl/vmgl.hg$ make
}}}
* 安裝於 Dom0(host) 端上.
{{{
~/vmgl/vmgl.hg$ sudo make install-host
}}}
----
= 【Step 2: 建構一台 VMGL VM (vg01) 】 =
* 設定你的虛擬機器.
{{{
$ sudo gedit /etc/xen-tools/xen-tools.conf
}}}
{{{
#!sh
45 dir = /home
128 size = 4Gb # Disk image size.
129 memory = 256Mb # Memory size
130 swap = 128Mb # Swap size
132 fs = ext3 # use the EXT3 filesystem for the disk image.
133 dist = lenny # Default distribution to install.
134 image = sparse # Specify sparse vs. full disk images.
163 gateway = 192.168.100.254
164 netmask = 255.255.255.0
165 broadcast = 192.168.100.255
215 mirror = http://free.nchc.org.tw/debian
}}}
* 產生你的虛擬機器.
{{{
$ sudo xen-create-image --hostname=vg01 --ip=192.168.100.X --mac=00:16:XX:XX:XX:XX --force
}}}
----
= 【Step 3: 確認虛擬機器(vg01)正確無誤】 =
{{{
$ sudo gedit /etc/xen/vg01.cfg
}}}
{{{
#!sh
9 kernel = '/boot/vmlinuz-2.6.22.9'
10 ramdisk = '/boot/initrd.img-2.6.22.9'
11 memory = '256'
12 vcpus = '4'
# 不需配置顯示卡
# pci = ['01:00.0']
17 root = '/dev/sda2 ro'
18 disk = [
'file:/home/domains/nvidia/disk.img,sda2,w',
'file:/home/domains/nvidia/swap.img,sda1,w',
]
27 name = 'vg01'
#
# Networking
#
32 vif = [ 'ip=192.168.100.X ,mac=00:16:XX:XX:XX:XX' ]
#
# Behaviour
#
37 on_poweroff = 'destroy'
38 on_reboot = 'restart'
39 on_crash = 'restart'
}}}
----
= 【Step 4: 在 DomU(vg01) 上安裝 VMGL 】 =
* 在 Dom0 上啟動虛擬機器 vg01 並登入.
{{{
$ sudo xm create -c vg01.cfg
}}}
* 先用 root 免密碼登入 vg01, 然後新增使用者 clouder.
{{{
$ adduser clouder
}}}
* 先登出 "root" 並且改用使用者 "clouder" 登入,接著安裝環境所需套件.
{{{
$ logout
$ sudo apt-get install build-essential gcc-4.1 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 libxaw7 libxaw7-dev libxext6 libxext-dev rxvt lwm vlc vlc-plugin-alsa tightvncserver udev ntpdate xauth xvfb xfonts-100dpi xfonts-75dpi culmus xfonts-scalable xfonts-base lxde openbox-themes gnome-settings-daemon gnome-settings-daemon-dev gnome-icon-theme
}}}
* 說明:輕量級桌面環境相關套件.
{{{
#!sh
# Designed for lightweight X desktop support.
xfonts-base xfonts-100dpi xfonts-75dpi -> fonts support
rxvt -> x-terminal-emulator for VNC
lwm -> x-window-manager for VNC
openbox -> X-window-manager for VNC
lxde -> Lightweight X11 Desktop Environment
}}}
* 下載VMGL.
{{{
$ mkdir 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
}}}
* 更換預設 gcc 版本,從 gcc-4.3 換成 gcc-4.1(更換連結).
{{{
$ sudo rm /usr/bin/gcc
$ sudo ln -sf /usr/bin/gcc-4.1 /usr/bin/gcc
}}}
* 建立安裝所需基本目錄.
{{{
~/vmgl/vmgl.hg$ sudo mkdir -p /usr/lib/xorg/modules/extensions
}}}
* 編譯.
{{{
~/vmgl/vmgl.hg$ make
}}}
* 安裝於 DomU(vg01) 端上.
{{{
~/vmgl/vmgl.hg$ sudo make install-guest
}}}
----
= 【Step 5: VMGL 使用說明: 在Dom0 上的設定】 =
* 將 X-Windows 桌面 export 出來.
{{{
$ export DISPLAY=:0
}}}
* 啟動 VLGL stub-daemon.
{{{
$ 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 6: VMGL 使用說明: 在DomU 上的設定】 =
* 設定 DomU 上的字型路徑對應.
{{{
$ sudo mkdir -p /usr/X11R6/lib/X11/
$ sudo ln -sf /usr/share/fonts/X11/ /usr/X11R6/lib/X11/fonts
}}}
{{{
#!sh
# FontPath:
/usr/X11R6/lib/X11/fonts (新路徑)
or
/usr/share/fonts/X11 (系統預設路徑)
}}}
* 確認 rgb.txt 存在於相對應路徑.
{{{
$ sudo ln -sf /usr/share/X11/rgb.txt /usr/X11R6/lib/X11/rgb.txt
$ cat /usr/X11R6/lib/X11/rgb.txt
}}}
* 切換為超級使用者.
{{{
$ sudo su -
}}}
* 設定 DomU 上的 VMGL 環境變數.
{{{
$ cat >> /etc/profile << EOF
}}}
* 逐一貼上以下設定.
{{{
#!sh
GLSTUB=140.XXX.XXX.XXX: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
EOF
}}}
* 設定 DomU 上的 X forwarding.
* Using X forwarding.
{{{
$ echo "X11Forwarding yes" >> /etc/ssh/sshd_config
}}}
{{{
$ cat >> /etc/ssh/ssh_config << EOF
}}}
* 逐一貼上以下設定.
{{{
#!sh
ForwardX11 yes
ForwardX11Trusted yes
EOF
}}}
* 返回使用者 "clouder".
{{{
$ exit
}}}
* 使環境變數生效.
{{{
$ source /etc/profile
}}}
* 重新啟動 DomU 上的 SSH Service.
{{{
$ sudo /etc/init.d/ssh restart
}}}
----
= 【Step 7: 在 Dom0 上 透過 X forwarding 登入 DomU 】 =
* 使用 X forwarding 的方式登入 DomU.
* Using X forwarding.
{{{
$ ssh -X vg01
}}}
* 檢查 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]]