Documentation
¶
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 ¶
- func DeviceSignature(cfg pvz.VZIOUSBHostPassthroughDeviceConfiguration) []byte
- func MakeHostPassthroughDeviceFromLocationID(locationID uint32, machine vz.VZVirtualMachine) (vz.VZUSBDeviceObject, error)
- func MakeHostPassthroughDeviceFromService(service uint32, machine vz.VZVirtualMachine) (vz.VZUSBDeviceObject, error)
- func MakeUSBMassStorageDevice(cfg vz.VZUSBMassStorageDeviceConfiguration, machine vz.VZVirtualMachine) (vz.VZUSBDeviceObject, error)
- func MassStorageDetails(device objectivec.IObject) (path string, readOnly bool, ok bool)
- func NewControllerConfiguration() vz.VZXHCIControllerConfiguration
- func NewHostPassthroughConfigurationFromLocationID(locationID uint32) (pvz.VZIOUSBHostPassthroughDeviceConfiguration, error)
- func NewHostPassthroughConfigurationFromService(service uint32) (pvz.VZIOUSBHostPassthroughDeviceConfiguration, error)
- func NewUSBPassthroughConfigurationFromDevice(device objectivec.IObject) (pvz.VZUSBPassthroughDeviceConfiguration, error)
- type Controller
- type DeviceInfo
- type HostDevice
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 ¶
func (c Controller) Raw() pvz.VZXHCIController
Raw returns the underlying controller.
func (Controller) Release ¶
func (c Controller) Release()
Release releases captured passthrough devices.
type DeviceInfo ¶
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 ¶
func NewHostDevice(cfg pvz.VZIOUSBHostPassthroughDeviceConfiguration) (HostDevice, error)
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 ¶
func (d HostDevice) Configuration() pvz.IVZIOUSBHostPassthroughDeviceConfiguration
Configuration returns the attached configuration, if any.
func (HostDevice) Raw ¶
func (d HostDevice) Raw() pvz.VZIOUSBHostPassthroughDevice
Raw returns the underlying host passthrough device.
func (HostDevice) Release ¶
func (d HostDevice) Release()
Release asks the device to release the host USB device.