This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.
18.5.18. vfio-pci 커널 드라이버를 NIC에 바인딩
VFIO(가상 기능 I/O) 네트워크에 연결하는 컴퓨팅 머신에는 구성된 네트워크에 연결된 포트에 vfio-pci 커널 드라이버를 바인딩해야 합니다. 이 VFIO 네트워크에 연결하는 작업자의 머신 세트를 생성합니다.
절차
명령줄에서 VFIO 네트워크 UUID를 검색합니다.
openstack network show <VFIO_network_name> -f value -c id
$openstack network show <VFIO_network_name>-f value -cid
Copy to ClipboardCopied!Toggle word wrapToggle overflow
다음 템플릿에서 클러스터에 머신 세트를 생성합니다.
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 99-vhostuser-bind
spec:
config:
ignition:
version: 2.2.0
systemd:
units:
- name: vhostuser-bind.service
enabled: true
contents: |
[Unit]
Description=Vhostuser Interface vfio-pci Bind
Wants=network-online.target
After=network-online.target ignition-firstboot-complete.service
[Service]
Type=oneshot
EnvironmentFile=/etc/vhostuser-bind.conf
ExecStart=/usr/local/bin/vhostuser $ARG
[Install]
WantedBy=multi-user.target
storage:
files:
- contents:
inline: vfio-pci
filesystem: root
mode: 0644
path: /etc/modules-load.d/vfio-pci.conf
- contents:
inline: |
#!/bin/bash
set -e
if [[ "$#" -lt 1 ]]; then
echo "Nework ID not provided, nothing to do"
exit
fi
source /etc/vhostuser-bind.conf
NW_DATA="/var/config/openstack/latest/network_data.json"
if [ ! -f ${NW_DATA} ]; then
echo "Network data file not found, trying to download it from nova metadata"
if ! curl http://169.254.169.254/openstack/latest/network_data.json > /tmp/network_data.json; then
echo "Failed to download network data file"
exit 1
fi
NW_DATA="/tmp/network_data.json"
fi
function parseNetwork() {
local nwid=$1
local pcis=()
echo "Network ID is $nwid"
links=$(jq '.networks[] | select(.network_id == "'$nwid'") | .link' $NW_DATA)
if [ ${#links} -gt 0 ]; then
for link in $links; do
echo "Link Name: $link"
mac=$(jq -r '.links[] | select(.id == '$link') | .ethernet_mac_address' $NW_DATA)
if [ -n $mac ]; then
pci=$(bindDriver $mac)
pci_ret=$?
if [[ "$pci_ret" -eq 0 ]]; then
echo "$pci bind succesful"
fi
fi
done
fi
}
function bindDriver() {
local mac=$1
for file in /sys/class/net/*; do
dev_mac=$(cat $file/address)
if [[ "$mac" == "$dev_mac" ]]; then
name=${file##*\/}
bus_str=$(ethtool -i $name | grep bus)
dev_t=${bus_str#*:}
dev=${dev_t#[[:space:]]}
echo $dev
devlink="/sys/bus/pci/devices/$dev"
syspath=$(realpath "$devlink")
if [ ! -f "$syspath/driver/unbind" ]; then
echo "File $syspath/driver/unbind not found"
return 1
fi
if ! echo "$dev">"$syspath/driver/unbind"; then
return 1
fi
if [ ! -f "$syspath/driver_override" ]; then
echo "File $syspath/driver_override not found"
return 1
fi
if ! echo "vfio-pci">"$syspath/driver_override"; then
return 1
fi
if [ ! -f "/sys/bus/pci/drivers/vfio-pci/bind" ]; then
echo "File /sys/bus/pci/drivers/vfio-pci/bind not found"
return 1
fi
if ! echo "$dev">"/sys/bus/pci/drivers/vfio-pci/bind"; then
return 1
fi
return 0
fi
done
return 1
}
for nwid in "$@"; do
parseNetwork $nwid
done
filesystem: root
mode: 0744
path: /usr/local/bin/vhostuser
- contents:
inline: |
ARG="be22563c-041e-44a0-9cbd-aa391b439a39,ec200105-fb85-4181-a6af-35816da6baf7"
filesystem: root
mode: 0644
path: /etc/vhostuser-bind.conf
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:labels:machineconfiguration.openshift.io/role: worker
name: 99-vhostuser-bind
spec:config:ignition:version: 2.2.0
systemd:units:-name: vhostuser-bind.service
enabled:truecontents:|
[Unit]
Description=Vhostuser Interface vfio-pci Bind
Wants=network-online.target
After=network-online.target ignition-firstboot-complete.service
[Service]
Type=oneshot
EnvironmentFile=/etc/vhostuser-bind.conf
ExecStart=/usr/local/bin/vhostuser $ARG
[Install]
WantedBy=multi-user.targetstorage:files:-contents:inline: vfio-pci
filesystem: root
mode:0644path: /etc/modules-load.d/vfio-pci.conf
-contents:inline:|
#!/bin/bash
set -e
if [[ "$#" -lt 1 ]]; then
echo "Nework ID not provided, nothing to do"
exit
fi
source /etc/vhostuser-bind.conf
NW_DATA="/var/config/openstack/latest/network_data.json"
if [!-f ${NW_DATA}]; then
echo "Network data file not found, trying to download it from nova metadata"
if ! curl http://169.254.169.254/openstack/latest/network_data.json > /tmp/network_data.json; then
echo "Failed to download network data file"
exit 1
fi
NW_DATA="/tmp/network_data.json"
fi
function parseNetwork() {
local nwid=$1
local pcis=()
echo "Network ID is $nwid"
links=$(jq '.networks[]| select(.network_id == "'$nwid'") | .link' $NW_DATA)
if [ ${#links} -gt 0 ]; then
for link in $links; do
echo "Link Name: $link"
mac=$(jq -r '.links[]| select(.id == '$link') | .ethernet_mac_address' $NW_DATA)
if [-n $mac ]; then
pci=$(bindDriver $mac)
pci_ret=$?
if [[ "$pci_ret" -eq 0 ]]; then
echo "$pci bind succesful"
fi
fi
done
fi
}
function bindDriver() {
local mac=$1
for file in /sys/class/net/*; do
dev_mac=$(cat $file/address)
if [[ "$mac" == "$dev_mac" ]]; then
name=${file##*\/}
bus_str=$(ethtool -i $name | grep bus)
dev_t=${bus_str#*:}
dev=${dev_t#[[:space:]]}
echo $dev
devlink="/sys/bus/pci/devices/$dev"
syspath=$(realpath "$devlink")
if [!-f "$syspath/driver/unbind" ]; then
echo "File $syspath/driver/unbind not found"
return 1
fi
if ! echo "$dev">"$syspath/driver/unbind"; then
return 1
fi
if [!-f "$syspath/driver_override" ]; then
echo "File $syspath/driver_override not found"
return 1
fi
if ! echo "vfio-pci">"$syspath/driver_override"; then
return 1
fi
if [!-f "/sys/bus/pci/drivers/vfio-pci/bind" ]; then
echo "File /sys/bus/pci/drivers/vfio-pci/bind not found"
return 1
fi
if ! echo "$dev">"/sys/bus/pci/drivers/vfio-pci/bind"; then
return 1
fi
return 0
fi
done
return 1
}
for nwid in "$@"; do
parseNetwork $nwid
done
filesystem: root
mode:0744path: /usr/local/bin/vhostuser
-contents:inline:|
ARG="be22563c-041e-44a0-9cbd-aa391b439a39,ec200105-fb85-4181-a6af-35816da6baf7"