Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: vfio-manager graphics mode #757

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions assets/state-vfio-manager/0400_configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ data:

echo "unbinding device $gpu"
unbind_from_driver $gpu
#for graphics mode, we need to unbind the auxiliary device as well
aux_dev=$(get_graphics_aux_dev "$gpu")
if [ "$aux_dev" != "NONE" ]; then
echo "gpu $gpu is in graphics mode aux_dev $aux_dev"
unbind_from_driver "$aux_dev"
fi
}

unbind_all() {
Expand All @@ -106,13 +112,9 @@ data:
done
}

bind_device() {
bind_pci_device() {
local gpu=$1

if ! is_nvidia_gpu_device $gpu; then
return 0
fi

if ! is_bound_to_vfio $gpu; then
unbind_from_other_driver $gpu
echo "binding device $gpu"
Expand All @@ -123,6 +125,35 @@ data:
fi
}

get_graphics_aux_dev() {
local gpu=$1
device_class_file=$(readlink -f "/sys/bus/pci/devices/$gpu/class")
device_class=$(cat "$device_class_file")
if [ "$device_class" == "0x030000" ]; then
aux_dev=$(ls "/sys/bus/pci/devices/$gpu" | grep consumer | awk -Fconsumer:pci: '{print $2}')
echo "$aux_dev"
else
echo "NONE"
fi
}

bind_device() {
local gpu=$1

if ! is_nvidia_gpu_device $gpu; then
echo "device $gpu is not a gpu!"
return 0
fi

bind_pci_device "$gpu"
#for graphics mode, we need to bind the auxiliary device as well
aux_dev=$(get_graphics_aux_dev "$gpu")
if [ "$aux_dev" != "NONE" ]; then
echo "gpu $gpu is in graphics mode aux_dev $aux_dev"
bind_pci_device "$aux_dev"
fi
}

bind_all() {
for dev in /sys/bus/pci/devices/*; do
read vendor < $dev/vendor
Expand Down
Loading