disk

package
v0.15.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Disk

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

Disk represents a SCSI disk attached to the VM. It manages the lifecycle of the disk attachment as well as the guest mounts on the disk partitions.

All operations on the disk are expected to be ordered by the caller. No locking is done at this layer.

func NewReserved

func NewReserved(controller, lun uint, config DiskConfig) *Disk

NewReserved creates a new Disk in the reserved state with the provided configuration.

func (*Disk) AttachToVM

func (d *Disk) AttachToVM(ctx context.Context, vm VMSCSIAdder) error

func (*Disk) Config

func (d *Disk) Config() DiskConfig

func (*Disk) DetachFromVM

func (d *Disk) DetachFromVM(ctx context.Context, vm VMSCSIRemover, lGuest LinuxGuestSCSIEjector) error

func (*Disk) HostPath

func (d *Disk) HostPath() string

func (*Disk) MountPartitionToGuest

func (d *Disk) MountPartitionToGuest(ctx context.Context, partition uint64, linuxGuest mount.LinuxGuestSCSIMounter, windowsGuest mount.WindowsGuestSCSIMounter) (string, error)

func (*Disk) ReservePartition

func (d *Disk) ReservePartition(ctx context.Context, config mount.MountConfig) (*mount.Mount, error)

func (*Disk) State

func (d *Disk) State() DiskState

func (*Disk) UnmountPartitionFromGuest

func (d *Disk) UnmountPartitionFromGuest(ctx context.Context, partition uint64, linuxGuest mount.LinuxGuestSCSIUnmounter, windowsGuest mount.WindowsGuestSCSIUnmounter) error

type DiskConfig

type DiskConfig struct {
	// HostPath is the path on the host to the disk to be attached.
	HostPath string
	// ReadOnly specifies whether the disk should be attached with read-only access.
	ReadOnly bool
	// Type specifies the attachment protocol to use when attaching the disk.
	Type DiskType
	// EVDType is the EVD provider name.
	// Only populated when Type is [DiskTypeExtensibleVirtualDisk].
	EVDType string
}

DiskConfig describes the host-side disk to attach to the VM's SCSI bus.

func (DiskConfig) Equals

func (d DiskConfig) Equals(other DiskConfig) bool

equals reports whether two DiskConfig values describe the same attachment parameters.

type DiskState

type DiskState int
const (
	// The disk has never been attached.
	DiskStateReserved DiskState = iota
	// The disk is currently attached to the guest.
	DiskStateAttached
	// The disk was previously attached and ejected and must be detached.
	DiskStateEjected
	// The disk was previously attached and detached, this is terminal.
	DiskStateDetached
)

type DiskType

type DiskType string

DiskType identifies the attachment protocol used when adding a disk to the VM's SCSI bus.

const (
	// DiskTypeVirtualDisk attaches the disk as a virtual hard disk (VHD/VHDX).
	DiskTypeVirtualDisk DiskType = "VirtualDisk"

	// DiskTypePassThru attaches a physical disk directly to the VM with pass-through access.
	DiskTypePassThru DiskType = "PassThru"

	// DiskTypeExtensibleVirtualDisk attaches a disk via an extensible virtual disk (EVD) provider.
	// The hostPath must be in the form evd://<type>/<mountPath>.
	DiskTypeExtensibleVirtualDisk DiskType = "ExtensibleVirtualDisk"
)

type LinuxGuestSCSIEjector

type LinuxGuestSCSIEjector interface {
	RemoveSCSIDevice(ctx context.Context, settings guestresource.SCSIDevice) error
}

type VMSCSIAdder

type VMSCSIAdder interface {
	AddSCSIDisk(ctx context.Context, disk hcsschema.Attachment, controller uint, lun uint) error
}

type VMSCSIRemover

type VMSCSIRemover interface {
	RemoveSCSIDisk(ctx context.Context, controller uint, lun uint) error
}

Jump to

Keyboard shortcuts

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