Changes between Initial Version and Version 1 of Xen_Lab7


Ignore:
Timestamp:
Oct 1, 2009, 4:54:02 PM (15 years ago)
Author:
rider
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Xen_Lab7

    v1 v1  
     1[[PageOutline]]
     2{{{
     3#!html
     4<h1 style="text-align: center; color: blue">實作七:Xen PCI Passthrough 操作</h1>
     5}}}
     6----
     7= 【Step 1: 連線到遠端主機】 =
     8'''# 以下兩種連線方式擇一使用.''' [[BR]]
     9rider@cloud:~$ ssh 140.xxx.xxx.xxx [[BR]]
     10rider@cloud:~$ vncviewer 140.xxx.xxx.xxx [[BR]]
     11----
     12= 【Step 2: 產生一台虛擬機器】 =
     13'''# 設定你想要怎樣規格的虛擬機器.''' [[BR]]
     14rider@cloud:~$ sudo vim /etc/xen-tools/xen-tools.conf [[BR]]
     15{{{
     16#!sh
     17dir = /home
     18install-method = debootstrap
     19size   = 8Gb      # Disk image size.
     20memory = 1024Mb    # Memory size
     21swap   = 128Mb    # Swap size
     22fs     = ext3     # use the EXT3 filesystem for the disk image.
     23dist   = hardy    # Default distribution to install. ---> For CUDA Support (Ubuntu 8.0.4)
     24image  = sparse   # Specify sparse vs. full disk images.
     25gateway   = 140.XXX.XXX.XXX
     26netmask   = 255.255.255.0
     27broadcast = 140.XXX.XXX.XXX
     28kernel      = /boot/vmlinuz-`uname -r`
     29initrd      = /boot/initrd.img-`uname -r`
     30mirror = http://gb.archive.ubuntu.com/ubuntu/
     31ext3_options   = noatime,nodiratime,errors=remount-ro
     32ext2_options   = noatime,nodiratime,errors=remount-ro
     33xfs_options    = defaults
     34reiser_options = defaults
     35}}}
     36rider@cloud:~$ sudo xen-create-image --hostname nvidia --ip 140.XXX.XXX.XXX [[BR]]
     37----
     38= 【Step 3: 查看你的顯卡資訊】 =
     39rider@cloud:~$ lspci -vv
     40{{{
     4101:00.0 VGA compatible controller: nVidia Corporation GeForce 9800 GT (rev a2)
     42        Subsystem: ASUSTeK Computer Inc. Device 82a0
     43        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
     44        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
     45        Latency: 0
     46        Interrupt: pin A routed to IRQ 16
     47        Region 0: Memory at fd000000 (32-bit, non-prefetchable) [size=16M]
     48        Region 1: Memory at d0000000 (64-bit, prefetchable) [size=256M]
     49        Region 3: Memory at fa000000 (64-bit, non-prefetchable) [size=32M]
     50        Region 5: I/O ports at dc80 [size=128]
     51        [virtual] Expansion ROM at fea00000 [disabled] [size=128K]
     52        Capabilities: <access denied>
     53        Kernel driver in use: pciback
     54        Kernel modules: nvidia, nvidiafb
     55}}}
     56----
     57= 【Step 4: PCI Frontend Configuration 設定你的 DomU 】 =
     58rider@cloud:~$ sudo vim /etc/xen/nvidia.cfg [[BR]]
     59{{{
     60#!sh
     61kernel      = '/boot/vmlinuz-2.6.22.9'
     62ramdisk     = '/boot/initrd.img-2.6.22.9'
     63 
     64memory      = '1024'
     65vcpus       = '4'
     66
     67# 配置你的 PCIE 顯示卡
     68pci         = ['01:00.0']
     69
     70root        = '/dev/sda2 ro'
     71disk        = [
     72                  'file:/home/domains/nvidia/disk.img,sda2,w',
     73                  'file:/home/domains/nvidia/swap.img,sda1,w',
     74              ]
     75name        = 'nvidia'
     76 
     77#
     78#  Networking
     79#
     80vif         = [ 'ip=140.xxx.xxx.xxx,mac=00:16:3E:AA:70:5C' ]
     81 
     82#
     83#  Behaviour
     84#
     85on_poweroff = 'destroy'
     86on_reboot   = 'restart'
     87on_crash    = 'restart'
     88}}}
     89----
     90= 【Step 5: PCI Backend Configuration 設定你的 Dom0 】 =
     91rider@cloud:~$ sudo su - [[BR]]
     92'''# Hide the device from dom0 so pciback can take control.''' [[BR]]
     93root@cloud:~$ echo -n "0000:01:00.0" > /sys/bus/pci/drivers/nvidia/unbind [[BR]]
     94
     95'''# Give the dev_ids to pciback, and give it a new slot then bind.''' [[BR]]
     96root@cloud:~$ echo -n "0000:01:00.0" > /sys/bus/pci/drivers/pciback/new_slot [[BR]]
     97root@cloud:~$ echo -n "0000:01:00.0" > /sys/bus/pci/drivers/pciback/bind [[BR]]
     98
     99root@cloud:~$ cat /sys/bus/pci/drivers/pciback/slots [[BR]]
     100{{{
     1010000:01:00.0
     102}}}
     103
     104'''# Caution: Make sure that the device is not controlled by any driver: there should be no driver symlink for nvidia.''' [[BR]]
     105{{{
     106PATH: /sys/bus/pci/devices/0000:01:00.0/
     107driver -> ../../../../bus/pci/drivers/nvidia ---> This symlink shouldn't exist.
     108}}}
     109----
     110= 【Step 6: 硬體直接存取設定】 =
     111
     112==== Permissive Flag ====
     113
     114rider@cloud:~$ sudo vim /etc/xen/xend-pci-permissive.sxp [[BR]]
     115{{{
     116#!sh
     117(unconstrained_dev_ids
     118     #('0123:4567:89AB:CDEF')
     119     ('0000:01:00.0')
     120)
     121}}}
     122
     123==== User-space Quirks ====
     124
     125rider@cloud:~$ sudo vim /etc/xen/xend-pci-quirks.sxp [[BR]]
     126{{{
     127#!sh
     128(pci_ids
     129   # Entries are formated as follows: 
     130   #     <vendor>:<device>[:<subvendor>:<subdevice>]
     131
     132   ('10de:0605'   # NVIDIA 9800GT
     133   )
     134)
     135}}}
     136----
     137= 【Step 7: 啟動並登入你的虛擬機器 DomU 】 =
     138'''說明: 用 root 免密碼先登入,然後建立自己的帳號. 改用自己的帳號登入(亦可用 root 登入 , 不新建帳號 ):''' [[BR]]
     139@ Dom0 [[BR]]
     140rider@cloud:~$ sudo xm create -c nvidia.cfg [[BR]]
     141
     142@ DomU [[BR]]
     143root@nvidia:~# adduser username [[BR]]
     144root@nvidia:~# vim /etc/sudoers [[BR]]
     145{{{
     146#!sh
     147username    ALL=(ALL) ALL
     148}}}
     149----
     150= 【Step 8: 設定你的 DomU 基本環境】 =
     151'''# 設定 locales (系統語系)''' [[BR]]
     152rider@nvidia:~$ sudo vim /etc/profile [[BR]]
     153{{{
     154# Locale
     155export LANGUAGE="en_US.UTF-8"
     156export LC_ALL="en_US.UTF-8"
     157export LANG="en_US.UTF-8"
     158}}}
     159rider@nvidia:~$ source /etc/profile [[BR]]
     160rider@nvidia:~$ sudo dpkg-reconfigure locales [[BR]]
     161'''# 更新 PCI ID Database''' [[BR]]
     162rider@nvidia:~$ sudo apt-get update [[BR]]
     163rider@nvidia:~$ sudo apt-get install wget [[BR]]
     164rider@nvidia:~$ sudo update-pciids [[BR]]
     165'''# 查看顯卡資訊有無正常顯示''' [[BR]]
     166rider@nvidia:~$ lspci [[BR]]
     167{{{
     16800:00.0 VGA compatible controller: nVidia Corporation GeForce 9800 GT (rev a2)
     169}}}
     170'''# 查看顯卡資源有無順利分配到 DomU''' [[BR]]
     171rider@nvidia:~$ dmesg | grep pci
     172{{{
     173pcifront pci-0: Installing PCI frontend
     174pcifront pci-0: Creating PCI Frontend Bus 0000:00
     175pciback 0000:00:00.0: probing...
     176pciback: pcistub_init_devices_late
     177}}}
     178----