summaryrefslogtreecommitdiffstats
path: root/scripts/create_mdev.sh
diff options
context:
space:
mode:
authorOpen-IOV <dev@open-iov.org>2026-09-23 05:44:08 -0400
committerOpen-IOV <dev@open-iov.org>2026-09-23 05:46:43 -0400
commit2302fc09080bad51c73f293294e19fd4db464eb0 (patch)
treec722d186347fdef5a34131e9e143b1549b1daf8e /scripts/create_mdev.sh
downloadopen-iov-2302fc09080bad51c73f293294e19fd4db464eb0.tar.gz
open-iov-2302fc09080bad51c73f293294e19fd4db464eb0.zip
Open-IOV: initial public release
Open-IOV virtualizes NVIDIA GPUs so that unmodified guest drivers run with real GPU functionality - CUDA first, 3D and video to follow - on unmodified hosts, without a proprietary vGPU license and without patching any driver, firmware or hypervisor. Core principle: emulate the interface, pass through the work. kernel/ open-iov-vfio.ko - host VFIO mdev driver: virtual GPU device (PCI config space, BAR shadows, MSI-X), GSP boot emulation, GSP-RM message-queue/RPC emulation, memory model (GPU-VA to guest-PA discovery) and the semaphore-completion service that advances guest UVM progress. userspace/ libiov.so management API and examples. tools/ guest diagnostics, firmware analysis wrappers, RM probes. scripts/ stack manager, VM harness, build/load/test automation. config/ hardware/version profiles (the portability surface). docs/ documentation tree - start at docs/README.md. wiki/ long-form firmware and protocol deep dives. Status: initialization works end to end for a stock 570.144 Linux guest on Turing (TU104): driver probe, nvidia-smi, the full GSP-RM control battery, object creation and the early CUDA/UVM start-up path. GPU work forwarding - the step that makes CUDA kernels execute on real hardware - is the active work item; see docs/04-implementation/01-known-knowns-and-unknowns.md. License: BSD-3-Clause for the project; GPL-2.0 for kernel modules that link GPL-only kernel interfaces. See LICENSE and docs/09-reference/legal-and-licensing.md.
Diffstat (limited to 'scripts/create_mdev.sh')
-rwxr-xr-xscripts/create_mdev.sh86
1 files changed, 86 insertions, 0 deletions
diff --git a/scripts/create_mdev.sh b/scripts/create_mdev.sh
new file mode 100755
index 0000000..a6ea91e
--- /dev/null
+++ b/scripts/create_mdev.sh
@@ -0,0 +1,86 @@
+#!/bin/bash
+# create_mdev.sh - Create NVIDIA vGPU mediated device for QEMU
+# Usage: ./create_mdev.sh [PCI_ADDRESS] [VGPU_TYPE]
+
+set -euo pipefail
+
+PCI_ADDR="${1:-}"
+VGPU_TYPE="${2:-pci-nvidia-vgpu-turing}"
+
+# Supported vGPU types (matching the mdev type names)
+VALID_TYPES=("pci-nvidia-vgpu-ampere" "pci-nvidia-vgpu-hopper" "pci-nvidia-vgpu-turing" "pci-nvidia-vgpu-pascal")
+
+# Find NVIDIA GPU if not specified
+if [[ -z "$PCI_ADDR" ]]; then
+ echo "Scanning for NVIDIA GPUs..."
+ mapfile -t GPUS < <(lspci -D -d 10de: | grep -E "VGA|3D controller" | awk '{print $1}')
+ if [[ ${#GPUS[@]} -eq 0 ]]; then
+ echo "ERROR: No NVIDIA GPU found"
+ exit 1
+ elif [[ ${#GPUS[@]} -eq 1 ]]; then
+ PCI_ADDR="${GPUS[0]}"
+ echo "Auto-selected GPU: $PCI_ADDR"
+ else
+ echo "Multiple GPUs found:"
+ for i in "${!GPUS[@]}"; do
+ echo " [$i] ${GPUS[$i]}"
+ done
+ read -p "Select GPU [0-$((${#GPUS[@]}-1))]: " idx
+ PCI_ADDR="${GPUS[$idx]}"
+ fi
+fi
+
+# Validate PCI address format
+if [[ ! "$PCI_ADDR" =~ ^[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-9a-fA-F]$ ]]; then
+ echo "ERROR: Invalid PCI address format. Expected: dddd:bb:dd.f"
+ exit 1
+fi
+
+# Check if GPU exists
+if [[ ! -e "/sys/bus/pci/devices/$PCI_ADDR" ]]; then
+ echo "ERROR: PCI device $PCI_ADDR not found"
+ exit 1
+fi
+
+# Validate vGPU type
+if [[ ! " ${VALID_TYPES[*]} " =~ " ${VGPU_TYPE} " ]]; then
+ echo "ERROR: Invalid vGPU type. Valid types: ${VALID_TYPES[*]}"
+ exit 1
+fi
+
+MDEV_TYPE_PATH="/sys/bus/pci/devices/$PCI_ADDR/mdev_supported_types/$VGPU_TYPE"
+
+if [[ ! -d "$MDEV_TYPE_PATH" ]]; then
+ echo "ERROR: vGPU type $VGPU_TYPE not supported on $PCI_ADDR"
+ echo "Available types:"
+ ls "/sys/bus/pci/devices/$PCI_ADDR/mdev_supported_types/" 2>/dev/null || echo " (none - check driver loaded)"
+ exit 1
+fi
+
+# Check available instances
+AVAILABLE=$(cat "$MDEV_TYPE_PATH/available_instances" 2>/dev/null || echo "0")
+if [[ "$AVAILABLE" -le 0 ]]; then
+ echo "ERROR: No available instances for $VGPU_TYPE on $PCI_ADDR"
+ exit 1
+fi
+
+echo "Creating $VGPU_TYPE on $PCI_ADDR..."
+
+# Generate UUID
+UUID=$(uuidgen)
+echo "$UUID" | sudo tee "$MDEV_TYPE_PATH/create" > /dev/null
+
+# Verify creation
+MDEV_PATH="/sys/bus/mdev/devices/$UUID"
+if [[ -d "$MDEV_PATH" ]]; then
+ echo "SUCCESS: Created mdev device $UUID"
+ echo " Path: $MDEV_PATH"
+ echo " PCI: $PCI_ADDR"
+ echo " Type: $VGPU_TYPE"
+ echo ""
+ echo "For QEMU, use:"
+ echo " -device vfio-pci,sysfsdev=$MDEV_PATH,display=off"
+else
+ echo "ERROR: Failed to create mdev device"
+ exit 1
+fi \ No newline at end of file