*azeqjz OpenStack: *
除OVS與硬直通SR-IOV外郁副,還有PCI直通讨盒,即物理網(wǎng)卡給一個(gè)虛擬機(jī)網(wǎng)口獨(dú)占。
PCI直通特性允許虛擬機(jī)完全訪問與直接控制物理PCI設(shè)備愈案。此機(jī)制對任何類型的PCI設(shè)備都是通用的挺尾,并且可以與網(wǎng)絡(luò)接口卡(NIC),圖形處理單元(GPU)或可以連接到PCI總線的任何其他設(shè)備一起運(yùn)行站绪。
有的PCI設(shè)備提供SR-IOV能力遭铺,當(dāng)使用SR-IOV時(shí),物理設(shè)備被虛擬呈現(xiàn)為多個(gè)PCI設(shè)備恢准。虛擬PCI設(shè)備被分配到同一個(gè)或多個(gè)虛擬機(jī)魂挂。在PCI直通的情況下,整個(gè)物理設(shè)備只能分配給一個(gè)虛擬機(jī)馁筐,并且不能共享涂召。
執(zhí)行以下步驟使能PCI直通(以地址為0000:41:00.0的PCI設(shè)備為例。
):
- 配置nova-scheduler (Controller)
- 配置nova-api (Controller)**
- 配置flavor (Controller)
- 使能PCI直通 (Compute)
- 在nova.conf配置PCI設(shè)備 (Compute)
1. Configure nova-scheduler (Controller)
- 參考 Configure nova-scheduler配置
nova-scheduler
敏沉。
在運(yùn)行nova-scheduler的每個(gè)控制節(jié)點(diǎn)果正,把PciPassthroughFilter添加到scheduler_default_filters,以默認(rèn)使能PciPassthroughFilter過濾器盟迟。同時(shí)秋泳,確保nova.conf [DEFAULT]下的scheduler_available_filters參數(shù)設(shè)置為all_filters,以使能compute服務(wù)提供的所有過濾器攒菠。
[DEFAULT]
scheduler_default_filters = RetryFilter, AvailabilityZoneFilter, RamFilter, ComputeFilter, ComputeCapabilitiesFilter, ImagePropertiesFilter, ServerGroupAntiAffinityFilter, ServerGroupAffinityFilter, PciPassthroughFilter
scheduler_available_filters = nova.scheduler.filters.all_filters
- 重啟
nova-scheduler
服務(wù)迫皱。
2. 配置nova-api (Controller)**
- 指定設(shè)備的PCI別名。
配置PCI別名a1來請求一個(gè)vendor_id為0x8086和product_id為0x154d的PCI設(shè)備辖众。vendor_id和product_id對應(yīng)于地址為0000:41:00.0的PCI設(shè)備卓起。
編輯/etc/nova/nova.conf:
[pci]
alias = { "vendor_id":"8086", "product_id":"154d", "device_type":"type-PF", "name":"a1" }
獲取alias的更多信息,參考nova.conf中的alias配置項(xiàng)赵辕。
PCI直通配置項(xiàng):
配置項(xiàng) = 默認(rèn)值 |
---|
alias = [] |
描述
要求填寫PCI直通設(shè)備的別名既绩。
這允許用戶在flavor的extra_spec屬性中指定PCI設(shè)備的別名,而不需給出指定PCI設(shè)備屬性要求还惠。
可能的值:
描述別名的JSON值列表饲握,例如:
alias = { “name”: “QuickAssist”, “product_id”: “0443”, “vendor_id”: “8086”, “device_type”: “type-PCI” }
定義了Intel QuickAssist卡的別名。有效的值為:
- “name”: PCI設(shè)備的別名
- “product_id”: 設(shè)備的十六進(jìn)制Product ID
- “vendor_id”: 設(shè)備的十六進(jìn)制Vendor ID
- “device_type”: PCI設(shè)備的類型,有效的值為: “type-PCI”, “type-PF” and “type-VF”救欧。
- 重啟nova-api服務(wù)
3. 配置flavor (Controller)
通過flavor為guest虛擬機(jī)配置兩個(gè)PCI設(shè)備衰粹,每個(gè)PCI設(shè)備的vendor_id
是0x8086
,product_id
是0x154d
笆怠。
# openstack flavor set m1.large --property "pci_passthrough:alias"="a1:2"
具體參考flavor铝耻。
$ openstack flavor set FLAVOR-NAME \
--property pci_passthrough:alias=ALIAS:COUNT
- ALIAS: (字符串) 對應(yīng)特定的PCI設(shè)備類型,與nova配置文件中的一致,參考nova.conf中的alias配置項(xiàng)蹬刷。
- COUNT: (整數(shù)) 分配給虛擬機(jī)的ALIAS中指定類型的PCI設(shè)備數(shù)量T瓢捉。
4.使能PCI passthrough (Compute)
使能VT-d和IOMMU,參考Create Virtual Functions中的步驟一與二:
Step 1 BIOS開啟SR-IOV與VT-d办成。
Step 2 在Linux中使能IOMMU泡态,例如使用GRUB把intel_iommu=on添加到內(nèi)核參數(shù)。
5.在nova.conf配置PCI設(shè)備 (Compute)
- 配置
nova-compute
迂卢,允許PCI設(shè)備直通到虛擬機(jī)某弦,編輯/etc/nova/nova.conf
文件:
[pci]
passthrough_whitelist = { "address": "0000:41:00.0" }
或者指定多個(gè)PCI設(shè)備:
[pci]
passthrough_whitelist = { "vendor_id": "8086", "product_id": "10fb" }
所有vendor_id與product_id 匹配的PCI設(shè)備會被添加到可以直通分配給虛擬機(jī)的PCI設(shè)備池。
更多關(guān)于passthrough_whitelist
的用法而克,參考nova.conf中的passthrough_whitelist配置項(xiàng)靶壮。
- 指定PCI設(shè)備的alias。
從Newton版本開始员萍,為了resize帶有PCI設(shè)備的虛擬機(jī)腾降,需要在計(jì)算節(jié)點(diǎn)上同時(shí)配置PCI設(shè)備alias。
配置請求alias為a1
的PCI設(shè)備充活,其中vendor_id
為0x8086
蜂莉,product_id
為0x154d
,對應(yīng)地址為 0000:41:00.0
的PCI設(shè)備混卵。
編輯/etc/nova/nova.conf
文件:
[pci]
alias = { "vendor_id":"8086", "product_id":"154d", "device_type":"type-PF", "name":"a1" }
- 重啟
nova-compute
服務(wù)。
6. 創(chuàng)建帶PCI直通設(shè)備的虛擬機(jī)實(shí)例
nova-scheduler選擇目標(biāo)主機(jī)窖张,這臺主機(jī)的PCI設(shè)備的vendor_id和product_id可以和flavor中定義的alias設(shè)備匹配幕随。
# openstack server create --flavor m1.large --image cirros-0.3.5-x86_64-uec --wait test-pci
可以通過lspci | grep -i eth
(型號與產(chǎn)品id等)查詢環(huán)境已有硬件是否符合要求。