Documentation
¶
Overview ¶
Package qemu implements the local VM manager using QEMU.
Index ¶
- Constants
- func NetMacAddress(suffix string) string
- func NewQemu(opts Options) vm.Manager
- func NormalizeKernelCmdline(arch, raw string) string
- func QemuArguments(monitor bool, ...) []string
- func QemuBinary(arch string) string
- func QemuRequiredBinaries(arch string) []string
- type Options
- type Qemu
- func (m *Qemu) Addr() string
- func (m *Qemu) CloudInitDataDiskPath() string
- func (m *Qemu) Console() error
- func (m *Qemu) Create(baseImage string) error
- func (m *Qemu) Delete() error
- func (m *Qemu) Exists() (bool, error)
- func (m *Qemu) PID() (int, error)
- func (m *Qemu) Running() (bool, error)
- func (m *Qemu) SerialConsolePath() string
- func (m *Qemu) SetOutput(output io.Writer)
- func (m *Qemu) Shell(ctx context.Context, command string, sshPort int, identityFile string, ...) ([]byte, error)
- func (m *Qemu) Start(userData, cpus, memory, sshAuthorizedKey string, monitor bool, ...) error
- func (m *Qemu) Stop() error
- func (m *Qemu) Sync(from, to, chown string, excludes []string, sshPort int, identityFile string) error
- func (m *Qemu) VMImageDirectory() string
- func (m *Qemu) VMImagePath() string
- func (m *Qemu) VMPIDDirectory() string
- func (m *Qemu) VMPIDFile() (pid.PIDFile, error)
- func (m *Qemu) VMPIDFilename() string
Constants ¶
const NET_CIDR = "192.168.1.0/24"
const NET_END = "192.168.1.20"
const NET_MACPREFIX = "52:52:00:00:00:"
const NET_MASK = "255.255.255.0"
const NET_START = "192.168.1.1"
const NET_SUBNET = "192.168.1.0"
Networking constants Alternatives: NET_CIDR="172.18.0.0/16" NET_START="172.18.0.1" # 172.18.0.1 NET_END="192.18.0.2" # 172.18.255.254 NET_MASK="255.255.0.0" # /16
Variables ¶
This section is empty.
Functions ¶
func NetMacAddress ¶
func NormalizeKernelCmdline ¶
NormalizeKernelCmdline adapts the manifest's raw boot-entry cmdline for local QEMU direct boot while preserving device/root arguments.
func QemuArguments ¶
func QemuArguments(monitor bool, arch, vmImage, cloudInitDataISOPath, serialConsolePath, cpus, memory string, directBoot *vm.DirectBootOptions, ports []vm.PortForward) []string
QemuArguments builds the command arguments to pass to qemu based on the architecture specified. cloudInitDataISOPath is the path to a NoCloud cidata ISO that delivers user-data to the guest. When directBoot is present, QEMU loads the kernel/initrd directly and the qcow2 remains attached as the virtio root disk. When monitor is true, qemu is also started with "-monitor stdio" so the operator can interact with it from the terminal that launched `podplane local start --monitor`.
func QemuBinary ¶
QemuBinary returns the qemu binary name based on the arch
func QemuRequiredBinaries ¶
QemuRequiredBinaries returns the required binaries for qemu
Types ¶
type Options ¶
type Options struct {
// Arch is the target architecture, e.g. "amd64" or "arm64".
Arch string
// ClusterID is used to derive a stable per-cluster VM name
// ("podplane-local-<ClusterID>").
ClusterID string
// DataDir is the on-disk root for durable VM data (qcow2 images).
// Concretely: <DataDir>/vms/<vmname>.<arch>.image.qcow2.
DataDir string
// RuntimeDir is the on-disk root for ephemeral VM runtime files (PIDs).
// Concretely: <RuntimeDir>/vms/<vmname>.<arch>.pid.json.
RuntimeDir string
}
type Qemu ¶
type Qemu struct {
VMName string
// contains filtered or unexported fields
}
Qemu handles interactions with qemu
func (*Qemu) CloudInitDataDiskPath ¶
CloudInitDataDiskPath returns the path to the cloud-init data ISO image for a VM
func (*Qemu) Create ¶
Create creates a new Qemu VM image, using the supplied base image path as the qcow2 backing file.
func (*Qemu) Running ¶
Running checks if a Qemu VM is currently running, first by loading our PID file, then by verifying the process is running.
func (*Qemu) SerialConsolePath ¶
SerialConsolePath returns the path to the QEMU serial console Unix socket.
func (*Qemu) SetOutput ¶
SetOutput sets where user-facing qemu lifecycle messages and child process output are written.
func (*Qemu) Shell ¶
func (m *Qemu) Shell(ctx context.Context, command string, sshPort int, identityFile string, opts vm.ShellOptions) ([]byte, error)
Shell opens a shell session into a qemu VM, or if a command is provided, executes that command instead of opening interactive shell
func (*Qemu) Start ¶
func (m *Qemu) Start(userData, cpus, memory, sshAuthorizedKey string, monitor bool, boot *vm.DirectBootOptions, ports []vm.PortForward) error
Start starts a qemu VM. The userData string is the rendered cloud-init user-data script; it is written into a NoCloud cidata ISO and attached to the VM as a cdrom drive.
func (*Qemu) Sync ¶
func (m *Qemu) Sync(from, to, chown string, excludes []string, sshPort int, identityFile string) error
Sync rsync's files into the running local cluster qemu VM.
func (*Qemu) VMImageDirectory ¶
VMImageDirectory returns the path to the directory for VM image files
func (*Qemu) VMImagePath ¶
VMImagePath returns the path to the VM image file for the given arch
func (*Qemu) VMPIDDirectory ¶
VMPIDDirectory return the path to the directory for VM PID files
func (*Qemu) VMPIDFilename ¶
VMPIDFilename returns the filename to use for a VM PID file