Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

如何在VT-d 虚拟化中安装Intel® Media Server Studio

$
0
0

Intel® Graphics Virtualization Technology (Intel® GVT)是Intel® Virtualization Technology (Intel® VT) for Directed I/O (Intel® VT-d) 的一个扩展, 它可以为Intel® HD graphics 提供硬件加速I/O虚拟化支持,- 它是一种GPU虚拟化解决方案. Intel GVT允许虚拟机 (VM) 通过I/O调用GPU功能.

仅支持“-d” (直接或者“传送”)虚拟化。这意味着每次只有一个VM能够使用GPU。但是,其他虚拟机可以执行不需要GPU的工作。

了解更多有关通用图形(非Media SDK或OpenCL)访问GPU, 请参考Intel GVT and KVMGT.

术语

主机:实际虚拟化发生的机器,在此系统上安装Intel Media Server Studio通用包.
VM:虚拟机对计算机系统的特定模拟,在此系统上安装Intel Media Server Studio Gold配置.
远程操作系统:用于从远程系统访问主机和虚拟机的操作系统。

下列步骤提供在Intel VT-d环境下启用Intel Media Server Studio的方法. 这包括主机和VM的安装,以及对安装的验证。

 

1. 设置主机

1.0 硬件要求

  • 主机:你需要一个支持Intel® Media Server Studio的CPU. 你可以在Release Notes for Linux* here中找到这部分的说明. 此外,确保这个CPU 支持Intel VT-d: 登录http://ark.intel.com以你CPU模式作为关键字进行搜索。在本文中,我们使用 GIGABYTE* GB-BXi7-4770R作为主机.
  • 远程操作系统: 要远程访问主机,你可以安装Microsoft* Windows* 或Linux*。在本文中,我们使用PuTTY 运行在Windows 8.1 从远程访问主机。

1.1 设置主机上的BIOS

以下设置应该在BIOS中启用: - VT-d 选项 - legacy 启动选项(设置UEFI 启动选项可能会导致VM 启动失败)

1.2 主机操作系统的设置

1. 设置主机系统使用"Server with GUI"选项

在安装CentOS* 7.1期间, 更改"Software Selection"中的默认选项到"Base Environment"到"Server with GUI".

2. 设置代理,如果你的主机需要设置代理服务器

以下行添加到 /etc/yum.conf
proxy=<proxy-server-ip>:<proxy-port>

3. 设置wget需要使用的环境变量,如果需要代理

以下行添加到 ~/.bashrc to get wget access:
export http_proxy=proxy-server-ip:proxy-port
export https_proxy=proxy-server-ip:proxy-port
export ftp_proxy=proxy-server-ip:proxy-port

4. 安装前提和依赖的软件包:

# yum groupinstall "Development Tools"
# yum install -y uuid-c++-devel lzo-devel gcc gcc-c++ git patch texinfo python-devel acpica-tools libuuid-devel ncurses-devel glib2 glib2-devel libaio-devel openssl-devel yajl-devel glibc-devel glibc-devel.i686 pixman-devel libpciaccess-devel pciutils-devel pciutils-devel-static pciutils-libs
# yum install -y tigervnc tigervnc-server SDL.i686 bridge-utils
# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/dev86-0.16.17-15.1.el6.x86_64.rpm
# rpm -Uvh dev86-0.16.17-15.1.el6.x86_64.rpm

2. 设置Dom0

2.1 安装Intel® Media Server Studio 通用软件包

1. 用户模式驱动和组件的安装

(如欲了解更多信息请参阅Intel Media Server Studio getting started guide.)

$ mkdir driver-setup
$ tar xf SDK*/Generic/intel-linux-media-ocl_generic*.tar.gz -C driver-setup
$ cd driver-setup
(as root)
# ./install_media.sh
# reboot

2. 内核模式驱动(KMD)的安装

作为普通用户安装是,请执行以下步骤:

$ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.14.5.tar.xz
$ tar -xJf linux-3.14.5.tar.xz
$ cp  /opt/intel/mediasdk/opensource/patches/kmd/3.14.5/intel-kernel-patches.tar.bz2 .
$ tar -xvjf intel-kernel-patches.tar.bz2
$ cd linux-3.14.5
$ for i in ../intel-kernel-patches/*.patch; do patch -p1 < $i; done
$ cp config-3.14.5-VTd.txt .config  ## refer note for config-3.14.5-VTd.txt
$ make -j 8
(as root)
# make modules_install
# make install
# grub2-mkconfig –o /boot/grub2/grub.cfg
# reboot      ## ==> new kernel 3.14.5

2.2 在Xen上安装Dom0

1. 通过源码构建Xen

$ git clone git://xenbits.xen.org/xen.git
$ cd xen
$ git checkout -b FOR-4.5.0 RELEASE-4.5.0
$ ./configure
$ make dist
(as root)
# make install

2. 设置守护程序和动态库

(as root)
# chkconfig --level 35 xencommons on
# chkconfig --level 35 xendomains on

# cd /etc/ld.so.conf.d/
# cat > libxen-x86_64.conf << EOF
/usr/local/lib
EOF
# ldconfig -v
# reboot

3. 配置Grub

a) 编辑/etc/grub.d/40_custom, 并复制新内核启动项目,从/boot/grub2/grub.cfg中拷贝新内核启动配置.

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'CentOS Linux 7 (Core), with Linux 3.14.5-MSSr6+' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.14.5-MSSr6+-advanced-62f16e28-adcb-4a47-925a-f4813854416f' {
    load_video
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 --hint='hd0,msdos3'  62f16e28-adcb-4a47-925a-f4813854416f
    else
      search --no-floppy --fs-uuid --set=root 62f16e28-adcb-4a47-925a-f4813854416f
    fi
    linux16 /boot/vmlinuz-3.14.5-MSSr6+ root=UUID=62f16e28-adcb-4a47-925a-f4813854416f ro rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet
    initrd16 /boot/initramfs-3.14.5-MSSr6+.img
}

b) 插入如下行,这只dom0内存和虚拟CPU核心分配

multiboot /boot/xen.gz dom0_mem=2048M iommu=1 dom0_max_vcpus=2 dom0_vcpus_pin=1

c) 用"module"更换"linux16"和"initrd16", 如下所示

menuentry 'CentOS Linux 7 (Core), with Linux 3.14.5-MSSr6+ Xen Hypervisor' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.14.5-MSSr6+-advanced-62f16e28-adcb-4a47-925a-f4813854416f' {
    load_video
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 --hint='hd0,msdos3'  62f16e28-adcb-4a47-925a-f4813854416f
    else
      search --no-floppy --fs-uuid --set=root 62f16e28-adcb-4a47-925a-f4813854416f
    fi

    multiboot /boot/xen.gz dom0_mem=2048M iommu=1 dom0_max_vcpus=8 dom0_vcpus_pin=1
    module /boot/vmlinuz-3.14.5-MSSr6+ root=UUID=62f16e28-adcb-4a47-925a-f4813854416f ro rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet
    module /boot/initramfs-3.14.5-MSSr6+.img
}

d) 更新grub菜单

(as root)
# grub2-mkconfig -o /boot/grub2/grub.cfg

e) 重新启动,并在grub菜单中选择'CentOS Linux 7 (Core), with Linux 3.14.5-MSSr6+ Xen Hypervisor' .

(as root)
# reboot

4. 检查Xen环境

$ lsmod | grep xen
xen_pciback            55503  0
xen_netback            36536  0
xen_blkback            37265  0
xen_gntalloc           13626  0
xen_gntdev             18675  2
xen_evtchn             13033  1
xenfs                  12978  1
xen_privcmd            13243  4 xenfs

(as root)
# xl list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  7852     8     r-----      54.4

# xl info
host                   : centos71.hsw.zhou
release                : 3.14.5-MSSr6+
version                : #1 SMP Tue Sep 1 13:36:53 CST 2015
machine                : x86_64
……

2.3 在Dom0上检查MediaSDK

$ DISPLAY=:0.0 vainfo
libva info: VA-API version 0.35.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_0_32
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.35 (libva 1.3.1)
vainfo: Driver version: 16.4.2.1.39163-ubit
vainfo: Supported profile and entrypoints
……

$ ./sample_multi_transcode_drm -hw -i::h264 input.h264 -o::h264 output.h264 -angle 180 -opencl
$ ./sample_encode_drm h264  -hw -i test.yuv -o test.h264 -w 720 -h 480 -la -lad 20

CAUTION: If you run media functions on dom0 and Dom0 is down for some reason, this will cause all VMs to fail.

3. 设置DomU

1. 启动主机并选择"Linux 3.14.5-MSSr6+ Xen Hypervisor"菜单条目

2. 创建并设置虚拟网桥 xenbr0

a) 搜索以下文件名: /etc/sysconfig/network-scripts/ifcfg-

b) 启用Xenbr0

(as root)
# br0.sh <NIC> xenbr0        ## br0.sh refer to 7.1

c) 验证xenbr0

$ ifconfig xenbr0
xenbr0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST>  mtu 1500
        inet 10.239.10.16  netmask 255.255.255.0  broadcast 10.239.10.255
        ether fc:aa:14:db:cf:0d  txqueuelen 0  (Ethernet)
        RX packets 136  bytes 14838 (14.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 47  bytes 9236 (9.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

3. 创建虚拟机

a) 创建一个虚拟硬盘映像

# dd if=/dev/zero of=./image30g.img seek=10000 bs=3M count=1

b) 创建一个虚拟机的配置文件 -  /etc/xen/xlexample.hvm是一个可以参考的示例

$ cat centos71-no-vtd.hvm
kernel = "hvmloader"
builder = 'hvm'
memory = 3072
vcpus = 6
cpus = "4,5,6,7"
name = "centos-vm1"
vif = [ 'mac=fc:aa:14:db:cf:4e, bridge=xenbr0, model=e1000' ]
disk = [ 'file:/home/lmsdk/setup-vtd/vm/image30g.img,hda,w', 'file:/home/lmsdk/setup-vtd/vm/CentOS-7-x86_64-DVD-1503-01.iso,hdc:cdrom,r' ]
xen_platform_pci=1
device_model_version='qemu-xen'
sdl=0
vnc=1
vnclisten='0.0.0.0'
vncpasswd='intel123'
serial='pty'
tsc_mode="default"
usb=1
keymap='en-us'

c) 启动虚拟机操作系统和设置CentOS 7.1

(as root)
# xl create centos71-no-vtd.hvm
# vncviewer :0   # input password (intel123) setting in VM configure file

安装操作系统过程中, 在 "Software"– "Software Selection"– "Base Environment"中,选择 "Server with GUI".

d) 安装Intel Media Server Studio 使用Gold 配置. 安装方法可以参考media_server_studio_getting_started_guide.pdf

e) 关闭虚拟机,不要测试媒体功能

(as root)
# xl list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  2048     8     r-----     977.1
centos-vm1                                   3  3072     6     -b----      39.8

# xl dest 3

4. 设置VGA PCI 传送模式

1. 使用putty登录主机,确保主机已经登录到桌面

2. 设置VGA PCI 传送

(as root)
# xl pci-assignable-add 0000:00:02.0@1c,msitranslate=1
# xl pci-assignable-list
0000:00:02.0

3. 修改虚拟机配置,使用Intel® GVT

$ cat centos71.hvm
kernel = "hvmloader"
builder = 'hvm'
memory = 2048
vcpus = 2
cpus = ["4", "5"]
name = "centos-vm1"
gfx_passthru=1
pci=['00:02.0@1c,msitranslate=1']
vif = [ 'mac=fc:aa:14:db:cf:4e, bridge=xenbr0, model=e1000' ]
disk = [ 'file:image30g.img,hda,w', 'file:CentOS-7-x86_64-DVD-1503-01.iso,hdc:cdrom,r' ]
xen_platform_pci=1
device_model_version='qemu-xen-traditional'
device_model_override='/usr/local/lib/xen/bin/qemu-dm'
sdl=0
#vnc=1
#vnclisten='0.0.0.0'
#vncpasswd='intel123'
serial='pty'
tsc_mode=0
usb=1
keymap='en-us'

4. 启动带有Intel® GVT虚拟机

(as root)
# xl create centos71.hvm

5. 在虚拟机上确认Intel® GVT

1. 确认显卡PCI设备

$ lspci –nn | grep VGA
00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:0d22] (rev 08)

2. 请参与 section in Intel Media Server Studio R6 Getting Started Guide中的"Verify correct installation"部分,用root用户验证 Intel Media Server Studio.

3. 在虚拟机上验证OpenCL和look-ahead码率控制方法

(as root)
# DISPLAY=:0.0 ./sample_multi_transcode_drm -hw -i::h264 test.h264 -o::h264 output.h264 -angle 180 -opencl
# DISPLAY=:0.0 ./sample_encode_drm h264  -hw -i test.yuv -o test-la-out.h264 -w 720 -h 480 -la -lad 20

6. 设置Intel® GVT的脚本

1. 运行br0.sh安装虚拟网桥

#!/bin/bash
if [ $# != 2 ] ; then
    echo "Usage: `basename $0`  "
    echo "       NIC: find it via ifconfig"
    echo "       BRIDGE: xenbr0 or br0"
    exit 1;
fi

eth0=$1
br0=$2

ifconfig $eth0 down                         # close eth0 first
brctl addbr $br0                            # add virtual bridge br0
brctl addif $br0 $eth0                      # add interface eth0 on br0
brctl stp $br0 off                          # only on bridge, so close generate tree protocol
brctl setfd $br0 1                          # set br0 delay time of forward
brctl sethello $br0 1                       # set br0 hello time
ifconfig $br0 0.0.0.0 promisc up            # open br0
ifconfig $eth0 0.0.0.0 promisc up           # open eth0
dhclient $br0                               # br0 get IP address from DHCP server
brctl show $br0                             # show virtual bridge list
brctl showstp $br0                          # show interface information on br0

7. 故障配出

下面的文章和资料可以帮您解决安装问题


Viewing all articles
Browse latest Browse all 3384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>