usbpassthrough

package
v0.6.20 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 10 Imported by: ? modules, 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.

Documentation

Rendered for darwin/amd64

Overview

Package usbpassthrough provides runtime USB passthrough helpers.

It is intended to wrap the private USB controller, XHCI controller, and host passthrough device configuration APIs so callers can capture host USB devices and attach or detach them from a running virtual machine.

The package covers:

Host device discovery and lookup
Passthrough and mass-storage device creation for a live VM
Runtime USB device introspection (kind, UUID, mass-storage backing path)
Passthrough device capture and release
Live attach and detach through a controller

This package handles runtime USB passthrough. Static USB-backed storage configuration remains separate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeviceSignature

func DeviceSignature(cfg pvz.VZIOUSBHostPassthroughDeviceConfiguration) []byte

DeviceSignature returns the opaque signature bytes for a host passthrough configuration.

func MakeHostPassthroughDeviceFromLocationID

func MakeHostPassthroughDeviceFromLocationID(locationID uint32, machine vz.VZVirtualMachine) (vz.VZUSBDeviceObject, error)

MakeHostPassthroughDeviceFromLocationID creates a live host USB passthrough device for machine from an IOKit USB location ID.

func MakeHostPassthroughDeviceFromService

func MakeHostPassthroughDeviceFromService(service uint32, machine vz.VZVirtualMachine) (vz.VZUSBDeviceObject, error)

MakeHostPassthroughDeviceFromService creates a live host USB passthrough device for machine from an IOKit service ID.

func MakeUSBMassStorageDevice

func MakeUSBMassStorageDevice(cfg vz.VZUSBMassStorageDeviceConfiguration, machine vz.VZVirtualMachine) (vz.VZUSBDeviceObject, error)

MakeUSBMassStorageDevice creates a live USB mass-storage device for machine from a public VZUSBMassStorageDeviceConfiguration.

func MassStorageDetails

func MassStorageDetails(device objectivec.IObject) (path string, readOnly bool, ok bool)

MassStorageDetails inspects a live USB mass-storage device and returns its backing disk-image path and read-only flag when backed by a disk image.

func NewControllerConfiguration

func NewControllerConfiguration() vz.VZXHCIControllerConfiguration

NewControllerConfiguration creates an XHCI controller configuration.

func NewHostPassthroughConfigurationFromLocationID

func NewHostPassthroughConfigurationFromLocationID(locationID uint32) (pvz.VZIOUSBHostPassthroughDeviceConfiguration, error)

NewHostPassthroughConfigurationFromLocationID creates a host passthrough configuration from a location ID.

func NewHostPassthroughConfigurationFromService

func NewHostPassthroughConfigurationFromService(service uint32) (pvz.VZIOUSBHostPassthroughDeviceConfiguration, error)

NewHostPassthroughConfigurationFromService creates a host passthrough configuration from a service ID.

func NewUSBPassthroughConfigurationFromDevice

func NewUSBPassthroughConfigurationFromDevice(device objectivec.IObject) (pvz.VZUSBPassthroughDeviceConfiguration, error)

NewUSBPassthroughConfigurationFromDevice creates a passthrough configuration for an accessory device.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller wraps a live XHCI controller.

func NewController

func NewController(config vz.VZXHCIControllerConfiguration, vm objectivec.IObject, index uint64, devices objectivec.IObject) (Controller, error)

NewController creates a live XHCI controller for a VM.

func (Controller) Attach

func (c Controller) Attach(ctx context.Context, device objectivec.IObject) error

Attach attaches a device to the controller.

func (Controller) Capture

func (c Controller) Capture(ctx context.Context) error

Capture asks the controller to capture host passthrough devices.

func (Controller) Detach

func (c Controller) Detach(ctx context.Context, device objectivec.IObject) error

Detach detaches a device from the controller.

func (Controller) Raw

Raw returns the underlying controller.

func (Controller) Release

func (c Controller) Release()

Release releases captured passthrough devices.

type DeviceInfo

type DeviceInfo struct {
	Kind        string
	Description string
	UUID        string
	Path        string
	ReadOnly    bool
}

DeviceInfo describes a live USB device attached to a virtual machine controller.

func InspectDevice

func InspectDevice(device objectivec.IObject) DeviceInfo

InspectDevice returns runtime metadata describing a live USB device.

type HostDevice

type HostDevice struct {
	// contains filtered or unexported fields
}

HostDevice wraps a live host USB passthrough device.

func NewHostDevice

NewHostDevice creates a passthrough device from configuration.

func NewHostDeviceWithLocationID

func NewHostDeviceWithLocationID(locationID uint32) (HostDevice, error)

NewHostDeviceWithLocationID is a convenience wrapper for location-based lookup.

func NewHostDeviceWithService

func NewHostDeviceWithService(service uint32) (HostDevice, error)

NewHostDeviceWithService is a convenience wrapper for service-based lookup.

func (HostDevice) Configuration

Configuration returns the attached configuration, if any.

func (HostDevice) Raw

Raw returns the underlying host passthrough device.

func (HostDevice) Release

func (d HostDevice) Release()

Release asks the device to release the host USB device.

Jump to

Keyboard shortcuts

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