devices

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 25 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Device Passthrough

This package provides GPU, vGPU, and PCI device passthrough for virtual machines.

Overview

hypeman supports two GPU modes:

Mode Description Use Case
vGPU (SR-IOV) Virtual GPUs via mdev on SR-IOV VFs Multi-tenant, shared GPU resources
Passthrough Whole GPU VFIO passthrough Dedicated GPU per instance

For GPU-specific documentation, see GPU.md.

Package Structure

lib/devices/
├── types.go         # Device, AvailableDevice, GPUProfile, MdevDevice types
├── errors.go        # Error definitions
├── discovery.go     # PCI device discovery from sysfs
├── vfio.go          # VFIO bind/unbind operations
├── gpu_mode.go      # GPU mode detection (vGPU vs passthrough)
├── mdev.go          # mdev lifecycle (create, destroy, list, reconcile)
├── manager.go       # Manager interface and implementation
├── manager_test.go  # Unit tests
├── gpu_e2e_test.go  # End-to-end GPU passthrough test
├── GPU.md           # GPU and vGPU documentation
└── scripts/
    └── gpu-reset.sh # GPU recovery script

Quick Start

# Check available profiles
curl localhost:4973/resources | jq .gpu

# Create instance with vGPU
curl -X POST localhost:4973/instances \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ml-training",
    "image": "nvidia/cuda:12.4-runtime-ubuntu22.04",
    "gpu": {"profile": "L40S-1Q"}
  }'

# Inside VM: verify GPU
nvidia-smi
Passthrough Mode (Dedicated GPU)
# Discover available devices
curl localhost:4973/devices/available

# Register the GPU
curl -X POST localhost:4973/devices \
  -d '{"name": "l4-gpu", "pci_address": "0000:a2:00.0"}'

# Create instance with GPU
curl -X POST localhost:4973/instances \
  -d '{"name": "ml-training", "image": "nvidia/cuda:12.0-base", "devices": ["l4-gpu"]}'

# Inside VM: verify GPU
nvidia-smi

# Delete instance (auto-unbinds from VFIO)
curl -X DELETE localhost:4973/instances/{id}

Device Lifecycle

Registration (Passthrough Mode)

Register a device for whole-GPU passthrough:

POST /devices
{
  "name": "l4-gpu",
  "pci_address": "0000:a2:00.0"
}
Instance Creation

vGPU Mode:

{
  "name": "gpu-workload",
  "image": "nvidia/cuda:12.4-runtime",
  "gpu": {"profile": "L40S-1Q"}
}

Passthrough Mode:

{
  "name": "gpu-workload", 
  "image": "nvidia/cuda:12.4-runtime",
  "devices": ["l4-gpu"]
}
Automatic Cleanup
  • vGPU: mdev destroyed when instance is deleted
  • Passthrough: Device unbound from VFIO when instance is deleted
  • Orphaned mdevs: Cleaned up on server startup

Hypervisor Integration

Both Cloud Hypervisor and QEMU receive device paths:

VFIO passthrough:

/sys/bus/pci/devices/0000:a2:00.0/

mdev (vGPU):

/sys/bus/mdev/devices/<uuid>/

Guest Driver Requirements

Important: Guest images must include pre-installed NVIDIA drivers.

FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04
RUN apt-get update && apt-get install -y nvidia-utils-550

hypeman does NOT inject drivers into guests.

Constraints and Limitations

IOMMU Requirements
  • IOMMU must be enabled in BIOS and kernel (intel_iommu=on or amd_iommu=on)
  • All devices in an IOMMU group must be passed through together
VFIO Module Requirements
modprobe vfio_pci
modprobe vfio_iommu_type1
Single Attachment

A device (or vGPU profile slot) can only be attached to one instance at a time.

No Hot-Plug

Devices must be specified at instance creation time.

Troubleshooting

GPU Reset Script

If GPU passthrough tests fail or hang:

# Reset all NVIDIA GPUs
sudo ./lib/devices/scripts/gpu-reset.sh

# Reset specific GPU
sudo ./lib/devices/scripts/gpu-reset.sh 0000:a2:00.0
Common Issues
VFIO Bind Hangs

Solution: Code automatically stops nvidia-persistenced. For manual testing:

sudo systemctl stop nvidia-persistenced
GPU Not Restored After Test
sudo sh -c 'echo 0000:a2:00.0 > /sys/bus/pci/drivers_probe'
sudo systemctl start nvidia-persistenced
vGPU Profile Not Available

Check available slots:

curl localhost:4973/resources | jq '.gpu.profiles'
Running the E2E Test
# Prerequisites
sudo modprobe vfio_pci vfio_iommu_type1

# Run test (auto-skips if no GPU)
sudo env PATH=$PATH:/sbin:/usr/sbin \
  go test -v -run TestGPUPassthrough -timeout 5m ./lib/devices/...

Why root is required: sysfs driver operations require writing to files owned by root with mode 0200.

Documentation

Index

Constants

View Source
const (
	VGPUFrameworkNone       VGPUFramework = ""
	VGPUFrameworkMdev       VGPUFramework = "mdev"
	VGPUFrameworkVendorVFIO VGPUFramework = "vendor-vfio"

	// GPUModePassthrough indicates whole GPU VFIO passthrough
	GPUModePassthrough GPUMode = "passthrough"
	// GPUModeVGPU indicates vGPU mode
	GPUModeVGPU GPUMode = "vgpu"
	// GPUModeNone indicates no GPU available
	GPUModeNone GPUMode = "none"
)

Variables

View Source
var (
	// ErrNotFound is returned when a device is not found
	ErrNotFound = errors.New("device not found")

	// ErrInUse is returned when a device is currently attached to an instance
	ErrInUse = errors.New("device is in use")

	// ErrNotBound is returned when a VFIO operation requires the device to be bound
	ErrNotBound = errors.New("device is not bound to VFIO")

	// ErrAlreadyBound is returned when trying to bind a device that's already bound to VFIO
	ErrAlreadyBound = errors.New("device is already bound to VFIO")

	// ErrAlreadyExists is returned when trying to register a device that already exists
	ErrAlreadyExists = errors.New("device already exists")

	// ErrInvalidName is returned when the device name doesn't match the required pattern
	ErrInvalidName = errors.New("device name must match pattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]+$")

	// ErrNameExists is returned when a device with the same name already exists
	ErrNameExists = errors.New("device name already exists")

	// ErrInvalidPCIAddress is returned when the PCI address format is invalid
	ErrInvalidPCIAddress = errors.New("invalid PCI address format")

	// ErrDeviceNotFound is returned when the PCI device doesn't exist on the host
	ErrDeviceNotFound = errors.New("PCI device not found on host")

	// ErrVFIONotAvailable is returned when VFIO modules are not loaded
	ErrVFIONotAvailable = errors.New("VFIO is not available (modules not loaded)")

	// ErrIOMMUGroupConflict is returned when not all devices in IOMMU group can be passed through
	ErrIOMMUGroupConflict = errors.New("IOMMU group contains other devices that must also be passed through")

	// ErrVGPUNotSupportedOnMacOS is returned for vGPU operations on macOS
	ErrVGPUNotSupportedOnMacOS = errors.New("vGPU (mdev) is not supported on macOS")
)
View Source
var DeviceNamePattern = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_.-]+$`)

DeviceNamePattern is the regex pattern for valid device names Must start with alphanumeric, followed by alphanumeric, underscore, dot, or dash

Functions

func ConfigureVGPU added in v0.4.0

func ConfigureVGPU(ctx context.Context, vfAddress, profileType string) error

ConfigureVGPU idempotently configures a claimed vendor VFIO VF. A failed configure may still have written the type, so the cached placements are refreshed either way.

func DestroyMdev added in v0.0.5

func DestroyMdev(ctx context.Context, mdevUUID string) error

DestroyMdev removes an mdev device.

func DestroyVGPU added in v0.4.0

func DestroyVGPU(ctx context.Context, assignment VGPUAssignment) error

func DiscoverVGPU added in v0.4.0

func DiscoverVGPU() (VGPUFramework, []VirtualFunction, error)

DiscoverVGPU returns the host's active vGPU framework and virtual functions.

func FormatVFAssignedAt added in v0.4.0

func FormatVFAssignedAt(claimedAt time.Time) string

FormatVFAssignedAt renders a claim time as the AssignedAt key used in VF health reports.

func GetDeviceSysfsPath

func GetDeviceSysfsPath(pciAddress string) string

GetDeviceSysfsPath returns the sysfs path for a PCI device (used by cloud-hypervisor)

func GetIOMMUGroupDevices

func GetIOMMUGroupDevices(iommuGroup int) ([]string, error)

GetIOMMUGroupDevices returns all PCI devices in the same IOMMU group

func InitVFHealth added in v0.4.0

func InitVFHealth(path string, threshold int) error

InitVFHealth loads persisted VF health state from path and evaluates the loaded tallies against threshold, the number of failed assignments that quarantine a VF. A lowered threshold therefore applies to failures persisted before the change. An error leaves the store unavailable, which fails vGPU placement closed until a later load or write succeeds. An empty path keeps state in memory only.

func IsMdevInUse added in v0.0.5

func IsMdevInUse(mdevUUID string) bool

IsMdevInUse checks if an mdev device is currently bound to a driver (in use by a VM). An mdev with a driver symlink is actively attached to a hypervisor/VFIO.

func ListVendorVFIOProfileTypes added in v0.4.0

func ListVendorVFIOProfileTypes(vfs []VirtualFunction) (map[string][]VGPUProfileType, error)

ListVendorVFIOProfileTypes returns the profiles advertised by each VF.

func NVMLFallbacks added in v0.4.0

func NVMLFallbacks() map[string]int64

NVMLFallbacks returns how many creatable-placement queries have fallen back to the sysfs lists for at least one GPU since startup, by reason: NVML failed (error), every GPU it failed for is in equal-size mode (equal_size), it timed out (timeout), or an earlier timed-out query had not returned yet (stuck).

func QuarantinedVFAddresses added in v0.4.0

func QuarantinedVFAddresses() (map[string]struct{}, error)

QuarantinedVFAddresses returns the PCI addresses of quarantined VFs. It fails while the health store is unavailable so placement fails closed.

func ReconcileMdevs added in v0.0.5

func ReconcileMdevs(ctx context.Context, instanceInfos []MdevReconcileInfo) error

ReconcileMdevs destroys orphaned mdevs on managed VFs.

Policy:

  • Consider only mdevs whose parent VF is currently managed by hypeman (discoverable via /sys/class/mdev_bus)
  • Keep mdevs claimed by live instance metadata
  • Keep mdevs whose VFIO group has an open file handle (/dev/vfio/<group>)
  • Keep mdevs younger than a short grace period to avoid racing very recent state transitions
  • Delete all remaining mdevs

func ReconcileVGPUs added in v0.4.0

func ReconcileVGPUs(ctx context.Context, protectedDevicePaths map[string]struct{}) error

ReconcileVGPUs releases orphaned vGPU assignments.

func RefreshVGPUCapacity added in v0.4.0

func RefreshVGPUCapacity()

RefreshVGPUCapacity reloads the vendor VFIO placements /resources counts from. It does nothing on hosts without vendor VFIO vGPUs.

func RepairVFHealthStore added in v0.4.0

func RepairVFHealthStore() error

RepairVFHealthStore retries a failed load or persist so the store recovers without waiting for a placement or /resources read to do it. It takes vendorVFIOMu like the report paths, so a reload that changes the quarantine set cannot interleave with a vendor-VFIO configure. The same retry also runs from checkedAddresses under only s.mu; there, configure's own re-check under vendorVFIOMu covers the selection-to-configure window instead. It returns without taking either lock while the store is healthy.

func SetGPUProfileCacheTTL added in v0.0.6

func SetGPUProfileCacheTTL(ttl string)

SetGPUProfileCacheTTL sets the TTL for GPU profile metadata cache. Should be called during application startup with the config value.

func TotalQuarantinedVFs added in v0.4.0

func TotalQuarantinedVFs() int

TotalQuarantinedVFs returns the number of quarantined VFs in persisted state.

func VFHealthStoreUnavailable added in v0.4.0

func VFHealthStoreUnavailable() bool

VFHealthStoreUnavailable reports whether persisted state failed to load or the last write failed.

func ValidateDeviceName

func ValidateDeviceName(name string) bool

ValidateDeviceName validates that a device name matches the required pattern

func ValidatePCIAddress

func ValidatePCIAddress(addr string) bool

ValidatePCIAddress validates that a string is a valid PCI address format

Types

type AvailableDevice

type AvailableDevice struct {
	PCIAddress    string  `json:"pci_address"`
	VendorID      string  `json:"vendor_id"`
	DeviceID      string  `json:"device_id"`
	VendorName    string  `json:"vendor_name"`
	DeviceName    string  `json:"device_name"`
	IOMMUGroup    int     `json:"iommu_group"`
	CurrentDriver *string `json:"current_driver"` // nil if no driver bound
}

AvailableDevice represents a PCI device discovered on the host

func DiscoverAvailableDevices

func DiscoverAvailableDevices() ([]AvailableDevice, error)

DiscoverAvailableDevices scans sysfs for PCI devices that can be used for passthrough It filters for devices that are likely candidates (GPUs, network cards, etc.)

func GetDeviceInfo

func GetDeviceInfo(pciAddress string) (*AvailableDevice, error)

GetDeviceInfo reads information about a specific PCI device

type CreateDeviceRequest

type CreateDeviceRequest struct {
	Name       string    `json:"name,omitempty"` // optional: globally unique name (auto-generated if not provided)
	PCIAddress string    `json:"pci_address"`    // required: PCI address (e.g., "0000:a2:00.0")
	Tags       tags.Tags `json:"tags,omitempty"`
}

CreateDeviceRequest is the request to register a new device

type Device

type Device struct {
	Id          string     `json:"id"`             // cuid2 identifier
	Name        string     `json:"name"`           // user-provided globally unique name
	Type        DeviceType `json:"type"`           // gpu or pci
	Tags        tags.Tags  `json:"tags,omitempty"` // user-defined key-value tags
	PCIAddress  string     `json:"pci_address"`    // e.g., "0000:a2:00.0"
	VendorID    string     `json:"vendor_id"`      // e.g., "10de"
	DeviceID    string     `json:"device_id"`      // e.g., "27b8"
	IOMMUGroup  int        `json:"iommu_group"`    // IOMMU group number
	BoundToVFIO bool       `json:"bound_to_vfio"`  // whether device is bound to vfio-pci
	AttachedTo  *string    `json:"attached_to"`    // instance ID if attached, nil otherwise
	CreatedAt   time.Time  `json:"created_at"`
}

Device represents a registered PCI device for passthrough

type DeviceType

type DeviceType string

DeviceType represents the type of PCI device

const (
	DeviceTypeGPU     DeviceType = "gpu"
	DeviceTypeGeneric DeviceType = "pci"
)

func DetermineDeviceType

func DetermineDeviceType(device *AvailableDevice) DeviceType

DetermineDeviceType determines the DeviceType based on device properties

type GPUMode added in v0.0.5

type GPUMode string

GPUMode represents the host's GPU configuration mode

type GPUProfile added in v0.0.5

type GPUProfile struct {
	Name          string `json:"name"`           // user-facing name, e.g., "L40S-1Q"
	FramebufferMB int    `json:"framebuffer_mb"` // frame buffer size in MB
	Available     int    `json:"available"`      // more instances that fit if only this profile is added
}

GPUProfile describes an available vGPU profile type

func ListGPUProfiles added in v0.0.5

func ListGPUProfiles() ([]GPUProfile, error)

ListGPUProfiles returns available vGPU profiles with availability counts.

func ListGPUProfilesWithVFs added in v0.0.5

func ListGPUProfilesWithVFs(framework VGPUFramework, vfs []VirtualFunction, quarantined map[string]struct{}) ([]GPUProfile, error)

ListGPUProfilesWithVFs returns available profiles for discovered VFs. Quarantined VFs are excluded from vendor VFIO counts, which come from the cached placements rather than a driver query.

type HostCapabilities added in v0.4.0

type HostCapabilities struct {
	// SupportsVGPU indicates whether the platform supports mediated vGPU operations.
	SupportsVGPU bool
}

HostCapabilities describes optional device features supported by the host platform.

func Capabilities added in v0.4.0

func Capabilities() HostCapabilities

Capabilities returns the device features supported on Linux.

type InstanceLivenessChecker

type InstanceLivenessChecker interface {
	// IsInstanceRunning returns true if the instance exists and is in a running state
	// (i.e., has an active VMM process). Returns false if the instance doesn't exist
	// or is stopped/standby/unknown.
	IsInstanceRunning(ctx context.Context, instanceID string) bool

	// GetInstanceDevices returns the list of device IDs attached to an instance.
	// Returns nil if the instance doesn't exist.
	GetInstanceDevices(ctx context.Context, instanceID string) []string

	// ListAllInstanceDevices returns a map of instanceID -> []deviceIDs for all instances.
	ListAllInstanceDevices(ctx context.Context) map[string][]string

	// DetectSuspiciousVMMProcesses finds cloud-hypervisor processes that don't match
	// known instances and logs warnings. Returns the count of suspicious processes found.
	DetectSuspiciousVMMProcesses(ctx context.Context) int
}

InstanceLivenessChecker provides a way to check if an instance is running. This interface allows devices to query instance state without a circular dependency.

type Manager

type Manager interface {
	// ListDevices returns all registered devices
	ListDevices(ctx context.Context) ([]Device, error)

	// ListAvailableDevices discovers passthrough-capable devices on the host
	ListAvailableDevices(ctx context.Context) ([]AvailableDevice, error)

	// CreateDevice registers a new device for passthrough
	CreateDevice(ctx context.Context, req CreateDeviceRequest) (*Device, error)

	// GetDevice returns a device by ID or name
	GetDevice(ctx context.Context, idOrName string) (*Device, error)

	// DeleteDevice unregisters a device
	DeleteDevice(ctx context.Context, id string) error

	// BindToVFIO binds a device to vfio-pci driver
	BindToVFIO(ctx context.Context, id string) error

	// UnbindFromVFIO unbinds a device from vfio-pci driver
	UnbindFromVFIO(ctx context.Context, id string) error

	// MarkAttached marks a device as attached to an instance
	MarkAttached(ctx context.Context, deviceID, instanceID string) error

	// MarkDetached marks a device as detached from an instance
	MarkDetached(ctx context.Context, deviceID string) error

	// ReconcileDevices cleans up stale device state on startup.
	// It detects devices with AttachedTo referencing non-existent instances
	// and clears the orphaned attachment state.
	ReconcileDevices(ctx context.Context) error

	// SetLivenessChecker sets the instance liveness checker after construction.
	// This allows breaking the circular dependency between device and instance managers.
	SetLivenessChecker(checker InstanceLivenessChecker)
}

Manager provides device management operations

func NewManager

func NewManager(p *paths.Paths) Manager

NewManager creates a new device manager. Use SetLivenessChecker after construction to enable accurate orphan detection.

type MdevDevice added in v0.0.5

type MdevDevice struct {
	UUID        string `json:"uuid"`         // e.g., "aa618089-8b16-4d01-a136-25a0f3c73123"
	VFAddress   string `json:"vf_address"`   // VF this mdev resides on
	ProfileType string `json:"profile_type"` // internal type name, e.g., "nvidia-556"
	ProfileName string `json:"profile_name"` // user-facing name, e.g., "L40S-1Q"
	SysfsPath   string `json:"sysfs_path"`   // path for VMM device attachment
	InstanceID  string `json:"instance_id"`  // instance this mdev is attached to
}

MdevDevice represents an active mediated device (vGPU instance)

func CreateMdev added in v0.0.5

func CreateMdev(ctx context.Context, profileName, instanceID string) (*MdevDevice, error)

CreateMdev creates an mdev device for the given profile and instance. It finds an available VF and creates the mdev, returning the device info. This function is thread-safe and uses a mutex to prevent race conditions when multiple instances request vGPUs concurrently.

func ListMdevDevices added in v0.0.5

func ListMdevDevices() ([]MdevDevice, error)

ListMdevDevices returns all active mdev devices on the host. Scans sysfs directly for fast, consistent results without external process overhead.

type MdevReconcileInfo added in v0.0.5

type MdevReconcileInfo struct {
	InstanceID string
	MdevUUID   string
	IsRunning  bool // true if instance's VMM is running or state is unknown
}

MdevReconcileInfo contains information needed to reconcile mdevs for an instance

type PassthroughDevice added in v0.0.5

type PassthroughDevice struct {
	Name      string `json:"name"`      // GPU name, e.g., "NVIDIA L40S"
	Available bool   `json:"available"` // true if not attached to an instance
}

PassthroughDevice describes a physical GPU available for passthrough

type VFIOBinder

type VFIOBinder struct{}

VFIOBinder handles binding and unbinding devices to/from VFIO

func NewVFIOBinder

func NewVFIOBinder() *VFIOBinder

NewVFIOBinder creates a new VFIOBinder

func (*VFIOBinder) BindToVFIO

func (v *VFIOBinder) BindToVFIO(pciAddress string) error

BindToVFIO binds a PCI device to the vfio-pci driver This requires: 1. Stopping any processes using the device (e.g., nvidia-persistenced for NVIDIA GPUs) 2. Unbinding the device from its current driver (if any) 3. Binding it to vfio-pci

func (*VFIOBinder) CheckIOMMUGroupSafe

func (v *VFIOBinder) CheckIOMMUGroupSafe(pciAddress string, allowedDevices []string) error

CheckIOMMUGroupSafe checks if all devices in the IOMMU group are safe to pass through Returns an error if there are other devices in the group that aren't being passed through

func (*VFIOBinder) GetVFIOGroupPath

func (v *VFIOBinder) GetVFIOGroupPath(pciAddress string) (string, error)

GetVFIOGroupPath returns the path to the VFIO group device for a PCI device

func (*VFIOBinder) IsDeviceBoundToVFIO

func (v *VFIOBinder) IsDeviceBoundToVFIO(pciAddress string) bool

IsDeviceBoundToVFIO checks if a device is currently bound to vfio-pci

func (*VFIOBinder) IsVFIOAvailable

func (v *VFIOBinder) IsVFIOAvailable() bool

IsVFIOAvailable checks if VFIO is available on the system

func (*VFIOBinder) UnbindFromVFIO

func (v *VFIOBinder) UnbindFromVFIO(pciAddress string) error

UnbindFromVFIO unbinds a device from vfio-pci and restores the original driver

type VFInitFailureReport added in v0.4.0

type VFInitFailureReport struct {
	VFAddress  string
	InstanceID string
	AssignedAt string
}

VFInitFailureReport describes one guest-reported driver init failure.

InstanceID and AssignedAt together identify the assignment. AssignedAt is the instance's stored GPUClaimedAt rendered with FormatVFAssignedAt; a success report only clears a failure whose AssignedAt string matches exactly, so every reporter must use that formatting.

type VFInitSuccessReport added in v0.4.0

type VFInitSuccessReport struct {
	VFAddress  string
	InstanceID string
	AssignedAt string
}

VFInitSuccessReport identifies the assignment that successfully initialized. AssignedAt follows the same format as VFInitFailureReport.AssignedAt.

A success clears the matched failure and every older tally. It rescinds a quarantine only when the matched failure is the most recent one recorded: the report that crossed the threshold, or the newest tally when a lowered threshold quarantined the VF at load.

type VFReportOutcome added in v0.4.0

type VFReportOutcome int

VFReportOutcome describes how a failure report changed a VF's health state.

const (
	// VFReportUnchanged means the VF was already quarantined or this
	// assignment was already recorded.
	VFReportUnchanged VFReportOutcome = iota
	// VFReportRecorded means the failure was tallied below the quarantine threshold.
	VFReportRecorded
	// VFReportQuarantined means this report crossed the threshold and quarantined the VF.
	VFReportQuarantined
)

type VFReportResult added in v0.4.0

type VFReportResult struct {
	Outcome   VFReportOutcome
	Failures  int
	Threshold int
}

VFReportResult is the outcome of recording a driver init failure.

func ReportVFInitFailure added in v0.4.0

func ReportVFInitFailure(report VFInitFailureReport) (VFReportResult, error)

ReportVFInitFailure records a guest-reported driver init failure and quarantines the VF once failures from enough distinct assignments accumulate.

type VFSuccessResult added in v0.4.0

type VFSuccessResult struct {
	Cleared   int
	Rescinded bool
}

VFSuccessResult describes how a successful init changed a VF's health state.

func ReportVFInitSuccess added in v0.4.0

func ReportVFInitSuccess(report VFInitSuccessReport) (VFSuccessResult, error)

ReportVFInitSuccess clears failures through an exactly matched successful assignment. A quarantine is rescinded only when that assignment triggered it.

type VGPUAssignment added in v0.4.0

type VGPUAssignment struct {
	Framework  VGPUFramework
	DevicePath string
	MdevUUID   string
	InstanceID string
}

VGPUAssignment identifies an existing vGPU assignment to release.

type VGPUAvailability added in v0.4.0

type VGPUAvailability struct {
	AllocatableSlots int // free VFs eligible for placement
	QuarantinedSlots int
	Quarantined      map[string]struct{} // PCI addresses of quarantined VFs
}

VGPUAvailability is one VF health snapshot applied to discovered VFs. Pass Quarantined to ListGPUProfilesWithVFs so profile availability is computed from the same snapshot without reading the store again.

func GetVGPUAvailability added in v0.4.0

func GetVGPUAvailability(framework VGPUFramework, vfs []VirtualFunction) (VGPUAvailability, error)

GetVGPUAvailability counts free allocatable and quarantined VFs. It fails while the health store is unavailable so callers fail closed.

type VGPUDevice added in v0.4.0

type VGPUDevice struct {
	Framework   VGPUFramework
	VFAddress   string
	ProfileType string
	ProfileName string
	SysfsPath   string
	MdevUUID    string
}

func CreateVGPU added in v0.4.0

func CreateVGPU(ctx context.Context, profileName, instanceID string) (*VGPUDevice, error)

type VGPUFramework added in v0.4.0

type VGPUFramework string

type VGPUProfileType added in v0.4.0

type VGPUProfileType struct {
	TypeName      string
	Name          string
	FramebufferMB int
}

VGPUProfileType describes a driver profile that can be configured on a VF.

type VirtualFunction added in v0.0.5

type VirtualFunction struct {
	PCIAddress  string `json:"pci_address"` // e.g., "0000:82:00.4"
	ParentGPU   string `json:"parent_gpu"`  // e.g., "0000:82:00.0"
	Allocated   bool   `json:"allocated"`   // true if a vGPU is assigned to this VF
	ProfileType string `json:"profile_type,omitempty"`
}

VirtualFunction represents an SR-IOV Virtual Function for vGPU

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL