vmconfigs

package
v5.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const MachineConfigVersion = 1

Variables

View Source
var (
	SSHRemoteConnection     RemoteConnectionType = "ssh"
	DefaultIgnitionUserName                      = "core"
	ForwarderBinaryName                          = "gvproxy"
)

Functions

func LoadMachinesInDir

func LoadMachinesInDir(dirs *define.MachineDirs) (map[string]*MachineConfig, error)

LoadMachinesInDir returns all the machineconfigs located in given dir

func NormalizeMachineArch

func NormalizeMachineArch(arch string) (string, error)

func SplitVolume

func SplitVolume(idx int, volume string) (string, string, string, bool, string)

Types

type AppleHVConfig

type AppleHVConfig struct{}

Stubs

type HostUser

type HostUser struct {
	// Whether this machine should run in a rootful or rootless manner
	Rootful bool
	// UID is the numerical id of the user that called machine
	UID int
	// Whether one of these fields has changed and actions should be taken
	Modified bool `json:"HostUserModified"`
}

HostUser describes the host user

type HyperVConfig

type HyperVConfig struct{}

type MachineConfig

type MachineConfig struct {
	// Common stuff
	Created  time.Time
	GvProxy  gvproxy.GvproxyCommand
	HostUser HostUser

	LastUp time.Time

	Mounts []*Mount
	Name   string

	Resources ResourceConfig
	SSH       SSHConfig
	Version   uint

	ImagePath *define.VMFile // Temporary only until a proper image struct is worked out

	// Provider stuff
	AppleHypervisor  *AppleHVConfig `json:",omitempty"`
	QEMUHypervisor   *QEMUConfig    `json:",omitempty"`
	HyperVHypervisor *HyperVConfig  `json:",omitempty"`
	WSLHypervisor    *WSLConfig     `json:",omitempty"`

	// Starting is defined as "on" but not fully booted
	Starting bool
	// contains filtered or unexported fields
}

func LoadMachineByName

func LoadMachineByName(name string, dirs *define.MachineDirs) (*MachineConfig, error)

LoadMachineByName returns a machine config based on the vm name and provider

func NewMachineConfig

func NewMachineConfig(opts define.InitOptions, dirs *define.MachineDirs, sshIdentityPath string, vmtype define.VMType, machineLock *lockfile.LockFile) (*MachineConfig, error)

NewMachineConfig creates the initial machine configuration file from cli options.

func (*MachineConfig) ConfigDir

func (mc *MachineConfig) ConfigDir() (*define.VMFile, error)

ConfigDir is a simple helper to obtain the machine config dir

func (*MachineConfig) ConnectionInfo

func (mc *MachineConfig) ConnectionInfo(vmtype define.VMType) (*define.VMFile, *define.VMFile, error)

func (*MachineConfig) DataDir

func (mc *MachineConfig) DataDir() (*define.VMFile, error)

DataDir is a simple helper function to obtain the machine data dir

func (*MachineConfig) GVProxySocket

func (mc *MachineConfig) GVProxySocket() (*define.VMFile, error)

func (*MachineConfig) IgnitionFile

func (mc *MachineConfig) IgnitionFile() (*define.VMFile, error)

func (*MachineConfig) IsFirstBoot

func (mc *MachineConfig) IsFirstBoot() (bool, error)

func (*MachineConfig) Kind

func (mc *MachineConfig) Kind() (define.VMType, error)

func (*MachineConfig) Lock

func (mc *MachineConfig) Lock()

Lock creates a lock on the machine for single access

func (*MachineConfig) LogFile

func (mc *MachineConfig) LogFile() (*define.VMFile, error)

func (*MachineConfig) ReadySocket

func (mc *MachineConfig) ReadySocket() (*define.VMFile, error)

func (*MachineConfig) Refresh

func (mc *MachineConfig) Refresh() error

Refresh reloads the config file from disk

func (*MachineConfig) Remove

func (mc *MachineConfig) Remove(saveIgnition, saveImage bool) ([]string, func() error, error)

func (*MachineConfig) RuntimeDir

func (mc *MachineConfig) RuntimeDir() (*define.VMFile, error)

RuntimeDir is simple helper function to obtain the runtime dir

func (*MachineConfig) SetDirs

func (mc *MachineConfig) SetDirs(dirs *define.MachineDirs)

func (*MachineConfig) SetRootful

func (mc *MachineConfig) SetRootful(rootful bool) error

func (*MachineConfig) Unlock

func (mc *MachineConfig) Unlock()

Unlock removes an existing lock

func (*MachineConfig) Write

func (mc *MachineConfig) Write() error

write is a non-locking way to write the machine configuration file to disk

type Mount

type Mount struct {
	OriginalInput string
	ReadOnly      bool
	Source        string
	Tag           string
	Target        string
	Type          string
	VSockNumber   *uint64
}

type OCIMachineImage

type OCIMachineImage struct {

	// quay.io/podman/podman-machine-image:5.0
	FQImageReference string
}

type QEMUConfig

type QEMUConfig struct {
	// QMPMonitor is the qemu monitor object for sending commands
	QMPMonitor command.Monitor
	// QEMUPidPath is where to write the PID for QEMU when running
	QEMUPidPath *define.VMFile
}

type RemoteConnectionType

type RemoteConnectionType string

type ResourceConfig

type ResourceConfig struct {
	// CPUs to be assigned to the VM
	CPUs uint64
	// Disk size in gigabytes assigned to the vm
	DiskSize strongunits.GiB
	// Memory in megabytes assigned to the vm
	Memory strongunits.MiB
	// Usbs
	USBs []define.USBConfig
}

ResourceConfig describes physical attributes of the machine

type SSHConfig

type SSHConfig struct {
	// IdentityPath is the fq path to the ssh priv key
	IdentityPath string
	// SSH port for user networking
	Port int
	// RemoteUsername of the vm user
	RemoteUsername string
}

SSHConfig contains remote access information for SSH

type VMProvider

type VMProvider interface {
	CreateVM(opts define.CreateVMOpts, mc *MachineConfig, builder *ignition.IgnitionBuilder) error
	// GetDisk should be only temporary.  It is largely here only because WSL disk pulling is different
	// TODO
	// Let's deprecate this ASAP
	GetDisk(userInputPath string, dirs *define.MachineDirs, mc *MachineConfig) error
	PrepareIgnition(mc *MachineConfig, ignBuilder *ignition.IgnitionBuilder) (*ignition.ReadyUnitOpts, error)
	Exists(name string) (bool, error)
	MountType() VolumeMountType
	MountVolumesToVM(mc *MachineConfig, quiet bool) error
	Remove(mc *MachineConfig) ([]string, func() error, error)
	RemoveAndCleanMachines(dirs *define.MachineDirs) error
	SetProviderAttrs(mc *MachineConfig, opts define.SetOptions) error
	StartNetworking(mc *MachineConfig, cmd *gvproxy.GvproxyCommand) error
	PostStartNetworking(mc *MachineConfig, noInfo bool) error
	StartVM(mc *MachineConfig) (func() error, func() error, error)
	State(mc *MachineConfig, bypass bool) (define.Status, error)
	StopVM(mc *MachineConfig, hardStop bool) error
	StopHostNetworking(mc *MachineConfig, vmType define.VMType) error
	VMType() define.VMType
	UserModeNetworkEnabled(mc *MachineConfig) bool
	UseProviderNetworkSetup() bool
	RequireExclusiveActive() bool
	UpdateSSHPort(mc *MachineConfig, port int) error
}

type VMStats

type VMStats struct {
	// Created contains the original created time instead of querying the file mod time
	Created time.Time
	// LastUp contains the last recorded uptime
	LastUp time.Time
}

type VolumeMountType

type VolumeMountType int
const (
	NineP VolumeMountType = iota
	VirtIOFS
	Unknown
)

func (VolumeMountType) String

func (v VolumeMountType) String() string

type WSLConfig

type WSLConfig struct{}

Jump to

Keyboard shortcuts

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