Help us shape the future of Go! Take the 2026 Go Developer Survey

macos

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package macos provides macOS native virtualization.

Package macos provides macOS native virtualization backends. On non-darwin platforms, all backends are stubs that report unavailable and return errors when invoked.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultVMImage

func DefaultVMImage(arch string) string

DefaultVMImage returns the default VM image path for the given arch.

func GenerateSandboxProfile

func GenerateSandboxProfile(rootfs string, readOnly bool, network string) string

GenerateSandboxProfile produces a sandbox-exec profile string. The profile is tightened: process-exec is scoped to the rootfs and system paths (not unrestricted), mach-lookup is restricted to named services, and ipc-posix-shm is scoped.

Types

type Backend

type Backend interface {
	Name() string
	Available() bool
	MinVersion() string
	CreateVM(cfg *VMConfig) error
	StartVM(id string) error
	StopVM(id string, timeoutSec int) error
	DeleteVM(id string) error
	VMStatus(id string) (string, error)
	ShareHostDir(hostPath, guestPath, tag string, readOnly bool) error
	UnshareHostDir(tag string) error
	ForwardPort(hostPort, guestPort int, proto string) error
	RemoveForwardPort(hostPort int, proto string) error
	Stats(id string) (*VMStats, error)
}

func SelectBackend

func SelectBackend(caps *Capabilities) (Backend, error)

SelectBackend selects the best available backend based on detected capabilities. Returns (backend, error) — the error is non-nil if no backend is available.

type Capabilities

type Capabilities struct {
	Version        string
	Arch           string
	IsTahoe        bool
	IsAppleSilicon bool
	ASIF           bool
	NFSv41         bool
	VZ             bool
	VirtioFS       bool
	Rosetta        bool
	Hypervisor     bool
	QEMU           bool
	Sandbox        bool
	BestBackend    string
}

func DetectCapabilities

func DetectCapabilities() *Capabilities

type FSShare

type FSShare struct {
	HostPath  string
	GuestPath string
	ReadOnly  bool
	Tag       string
}

type PortForward

type PortForward struct {
	HostPort  int
	GuestPort int
	Protocol  string
	HostIP    string
}

type QEMUBackend

type QEMUBackend struct{}

QEMUBackend is a stub for the QEMU-based macOS virtualization backend.

func (*QEMUBackend) Available

func (b *QEMUBackend) Available() bool

func (*QEMUBackend) CreateVM

func (b *QEMUBackend) CreateVM(_ *VMConfig) error

func (*QEMUBackend) DeleteVM

func (b *QEMUBackend) DeleteVM(_ string) error

func (*QEMUBackend) ForwardPort

func (b *QEMUBackend) ForwardPort(_, _ int, _ string) error

func (*QEMUBackend) MinVersion

func (b *QEMUBackend) MinVersion() string

func (*QEMUBackend) Name

func (b *QEMUBackend) Name() string

func (*QEMUBackend) RemoveForwardPort

func (b *QEMUBackend) RemoveForwardPort(_ int, _ string) error

func (*QEMUBackend) ShareHostDir

func (b *QEMUBackend) ShareHostDir(_, _, _ string, _ bool) error

func (*QEMUBackend) StartVM

func (b *QEMUBackend) StartVM(_ string) error

func (*QEMUBackend) Stats

func (b *QEMUBackend) Stats(_ string) (*VMStats, error)

func (*QEMUBackend) StopVM

func (b *QEMUBackend) StopVM(_ string, _ int) error

func (*QEMUBackend) UnshareHostDir

func (b *QEMUBackend) UnshareHostDir(_ string) error

func (*QEMUBackend) VMStatus

func (b *QEMUBackend) VMStatus(_ string) (string, error)

type SandboxBackend

type SandboxBackend struct{}

SandboxBackend uses macOS sandbox-exec to run processes in a restricted sandbox profile. This is the lightest isolation backend and does not require Hypervisor.framework.

func (*SandboxBackend) Available

func (b *SandboxBackend) Available() bool

func (*SandboxBackend) CreateVM

func (b *SandboxBackend) CreateVM(_ *VMConfig) error

func (*SandboxBackend) DeleteVM

func (b *SandboxBackend) DeleteVM(_ string) error

func (*SandboxBackend) ForwardPort

func (b *SandboxBackend) ForwardPort(_, _ int, _ string) error

func (*SandboxBackend) MinVersion

func (b *SandboxBackend) MinVersion() string

func (*SandboxBackend) Name

func (b *SandboxBackend) Name() string

func (*SandboxBackend) RemoveForwardPort

func (b *SandboxBackend) RemoveForwardPort(_ int, _ string) error

func (*SandboxBackend) ShareHostDir

func (b *SandboxBackend) ShareHostDir(_, _, _ string, _ bool) error

func (*SandboxBackend) StartVM

func (b *SandboxBackend) StartVM(_ string) error

func (*SandboxBackend) Stats

func (b *SandboxBackend) Stats(_ string) (*VMStats, error)

func (*SandboxBackend) StopVM

func (b *SandboxBackend) StopVM(_ string, _ int) error

func (*SandboxBackend) UnshareHostDir

func (b *SandboxBackend) UnshareHostDir(_ string) error

func (*SandboxBackend) VMStatus

func (b *SandboxBackend) VMStatus(_ string) (string, error)

type VMConfig

type VMConfig struct {
	ID         string
	CPUs       int
	MemoryMB   int64
	DiskSizeGB int64
	DiskPath   string
	KernelPath string
	InitrdPath string
	Shares     []FSShare
	Ports      []PortForward
	Rosetta    bool
	Network    string
	Backend    string
}

type VMStats

type VMStats struct {
	CPUUsage    float64
	MemoryUsage int64
	MemoryTotal int64
	DiskRead    int64
	DiskWrite   int64
	NetRx       int64
	NetTx       int64
	State       string
}

type VZBackend

type VZBackend struct{}

VZBackend is a stub for the macOS Virtualization framework backend.

func (*VZBackend) Available

func (b *VZBackend) Available() bool

func (*VZBackend) CreateVM

func (b *VZBackend) CreateVM(_ *VMConfig) error

func (*VZBackend) DeleteVM

func (b *VZBackend) DeleteVM(_ string) error

func (*VZBackend) ForwardPort

func (b *VZBackend) ForwardPort(_, _ int, _ string) error

func (*VZBackend) MinVersion

func (b *VZBackend) MinVersion() string

func (*VZBackend) Name

func (b *VZBackend) Name() string

func (*VZBackend) RemoveForwardPort

func (b *VZBackend) RemoveForwardPort(_ int, _ string) error

func (*VZBackend) ShareHostDir

func (b *VZBackend) ShareHostDir(_, _, _ string, _ bool) error

func (*VZBackend) StartVM

func (b *VZBackend) StartVM(_ string) error

func (*VZBackend) Stats

func (b *VZBackend) Stats(_ string) (*VMStats, error)

func (*VZBackend) StopVM

func (b *VZBackend) StopVM(_ string, _ int) error

func (*VZBackend) UnshareHostDir

func (b *VZBackend) UnshareHostDir(_ string) error

func (*VZBackend) VMStatus

func (b *VZBackend) VMStatus(_ string) (string, error)

Jump to

Keyboard shortcuts

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