Documentation ¶
Overview ¶
Package scsi handles SCSI device attachment and mounting for VMs. The primary entrypoint to the package is Manager.
The backend implementation of working with disks for a given VM is provided by the interfaces [Attacher], [Mounter], and [Unplugger].
Index ¶
- Variables
- type GuestBackend
- type HostBackend
- type Manager
- func (m *Manager) AddExtensibleVirtualDisk(ctx context.Context, hostPath string, readOnly bool, mc *MountConfig) (*Mount, error)
- func (m *Manager) AddPhysicalDisk(ctx context.Context, hostPath string, readOnly bool, vmID string, ...) (*Mount, error)
- func (m *Manager) AddVirtualDisk(ctx context.Context, hostPath string, readOnly bool, vmID string, ...) (*Mount, error)
- type Mount
- type MountConfig
- type Slot
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoAvailableLocation indicates that a new SCSI attachment failed because // no new slots were available. ErrNoAvailableLocation = errors.New("no available location") // ErrNotInitialized is returned when a method is invoked on a nil [Manager]. ErrNotInitialized = errors.New("SCSI manager not initialized") // ErrAlreadyReleased is returned when [Mount.Release] is called on a Mount // that had already been released. ErrAlreadyReleased = errors.New("mount was already released") )
Functions ¶
This section is empty.
Types ¶
type GuestBackend ¶
type GuestBackend interface {
// contains filtered or unexported methods
}
GuestBackend provides the guest-side operations needed to manage SCSI, such as mount/unmount and unplug.
func NewBridgeGuestBackend ¶
func NewBridgeGuestBackend(gc *gcs.GuestConnection, osType string) GuestBackend
NewBridgeGuestBackend provides a GuestBackend using a gcs.GuestConnection.
osType should be either "windows" or "linux".
func NewHCSGuestBackend ¶
func NewHCSGuestBackend(system *hcs.System, osType string) GuestBackend
NewHCSGuestBackend provides a GuestBackend using a hcs.System.
osType should be either "windows" or "linux".
type HostBackend ¶
type HostBackend interface {
// contains filtered or unexported methods
}
HostBackend provides the host-side operations needed to manage SCSI, such as attach/detach.
func NewHCSHostBackend ¶
func NewHCSHostBackend(system *hcs.System) HostBackend
NewHCSHostBackend provides a HostBackend using a hcs.System.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the primary entrypoint for managing SCSI devices on a VM. It tracks the state of what devices have been attached to the VM, and mounted inside the guest OS.
func NewManager ¶
func NewManager( hb HostBackend, gb GuestBackend, numControllers int, numLUNsPerController int, guestMountFmt string, reservedSlots []Slot, ) (*Manager, error)
NewManager creates a new Manager using the provided host and guest backends, as well as other configuration parameters.
guestMountFmt is the format string to use for mounts of SCSI devices in the guest OS. It should have a single %d format parameter.
reservedSlots indicates which SCSI slots to treat as already used. They will not be handed out again by the Manager.
func (*Manager) AddExtensibleVirtualDisk ¶
func (m *Manager) AddExtensibleVirtualDisk( ctx context.Context, hostPath string, readOnly bool, mc *MountConfig, ) (*Mount, error)
AddExtensibleVirtualDisk attaches and mounts an extensible virtual disk (EVD) to the VM. EVDs are made available by special drivers on the host which interact with the Hyper-V synthetic SCSI stack. If the same physical disk has already been attached to the VM, the existing attachment will be reused. If the same physical disk has already been mounted in the guest OS with the same MountConfig, the same mount will be reused.
hostPath must adhere to the format "evd://<evdType>/<evdMountPath>".
mc determines the settings to apply on the guest OS mount. If it is nil, no guest OS mount is performed.
func (*Manager) AddPhysicalDisk ¶
func (m *Manager) AddPhysicalDisk( ctx context.Context, hostPath string, readOnly bool, vmID string, mc *MountConfig, ) (*Mount, error)
AddPhysicalDisk attaches and mounts a physical disk on the host to the VM. If the same physical disk has already been attached to the VM, the existing attachment will be reused. If the same physical disk has already been mounted in the guest OS with the same MountConfig, the same mount will be reused.
If vmID is non-empty an ACL will be added to the disk so that the specified VHD can access it.
mc determines the settings to apply on the guest OS mount. If it is nil, no guest OS mount is performed.
func (*Manager) AddVirtualDisk ¶
func (m *Manager) AddVirtualDisk( ctx context.Context, hostPath string, readOnly bool, vmID string, mc *MountConfig, ) (*Mount, error)
AddVirtualDisk attaches and mounts a VHD on the host to the VM. If the same VHD has already been attached to the VM, the existing attachment will be reused. If the same VHD has already been mounted in the guest OS with the same MountConfig, the same mount will be reused.
If vmID is non-empty an ACL will be added to the VHD so that the specified VHD can access it.
mc determines the settings to apply on the guest OS mount. If it is nil, no guest OS mount is performed.
type Mount ¶
type Mount struct {
// contains filtered or unexported fields
}
Mount represents a SCSI device that has been attached to a VM, and potentially also mounted into the guest OS.
func (*Mount) Controller ¶
Controller returns the controller number that the SCSI device is attached to.
func (*Mount) GuestPath ¶
GuestPath returns the path inside the guest OS where the SCSI device was mounted. Will return an empty string if no guest mount was performed.
func (*Mount) Release ¶
Release releases the SCSI mount. Refcount tracking is used in case multiple instances of the same attachment or mount are used. If the refcount for the guest OS mount reaches 0, the guest OS mount is removed. If the refcount for the SCSI attachment reaches 0, the SCSI attachment is removed.
type MountConfig ¶
type MountConfig struct { // Partition is the target partition index on a partitioned device to // mount. Partitions are 1-based indexed. // This is only supported for LCOW. Partition uint64 // Encrypted indicates if we should encrypt the device with dm-crypt. // This is only supported for LCOW. Encrypted bool // Options are options such as propagation options, flags, or data to // pass to the mount call. // This is only supported for LCOW. Options []string // EnsureFilesystem indicates to format the mount as `Filesystem` // if it is not already formatted with that fs type. // This is only supported for LCOW. EnsureFilesystem bool // Filesystem is the target filesystem that a device will be // mounted as. // This is only supported for LCOW. Filesystem string }
MountConfig specifies the options to apply for mounting a SCSI device in the guest OS.