qemu

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package qemu provides utilities for running QEMU virtual machines.

Index

Constants

View Source
const (
	// Architecture names used by QEMU.
	ArchX86_64  = "x86_64"
	ArchAarch64 = "aarch64"
)

Variables

This section is empty.

Functions

func BinaryAndPackageForArch

func BinaryAndPackageForArch(arch string) (binary, pkg string)

BinaryAndPackageForArch returns the QEMU binary name and package for the given architecture.

func CanUseKVM

func CanUseKVM(targetArch string) bool

CanUseKVM returns true if KVM acceleration can be used for the given target architecture. KVM is only available when the target architecture matches the host architecture.

func CheckPrerequisites

func CheckPrerequisites(ctx opctx.Ctx, arch string) error

CheckPrerequisites verifies that QEMU and sudo are available for the given architecture.

func GoArchToQEMUArch

func GoArchToQEMUArch(goarch string) string

GoArchToQEMUArch converts Go's GOARCH to QEMU architecture names.

func MachineAndCPUForArch

func MachineAndCPUForArch(arch string, useKVM bool) (machine, cpu string)

MachineAndCPUForArch returns the QEMU machine type and CPU for the given architecture.

func SupportedArchitectures

func SupportedArchitectures() []string

SupportedArchitectures returns the list of supported QEMU architectures.

Types

type Arch

type Arch string

Arch represents a QEMU architecture and implements pflag.Value for flag parsing.

func (*Arch) Set

func (a *Arch) Set(value string) error

Set parses and validates the architecture value from a string.

func (*Arch) String

func (a *Arch) String() string

func (*Arch) Type

func (a *Arch) Type() string

Type returns a descriptive string used in command-line help.

type RunOptions

type RunOptions struct {
	Arch             string
	FirmwarePath     string
	NVRAMPath        string
	DiskPath         string
	DiskType         string
	CloudInitISOPath string
	SecureBoot       bool
	SSHPort          int
	CPUs             int
	Memory           string
}

RunOptions contains configuration for running a QEMU VM.

type Runner

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

Runner encapsulates options and dependencies for invoking QEMU.

func NewRunner

func NewRunner(ctx opctx.Ctx) *Runner

NewRunner constructs a new Runner that can be used to invoke QEMU.

func (*Runner) FindFirmware

func (r *Runner) FindFirmware(arch string, secureBoot bool) (fwPath, nvramTemplatePath string, err error)

FindFirmware locates UEFI firmware and NVRAM template files for the given architecture. Returns paths to the firmware code and NVRAM template files.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, options RunOptions) error

Run starts a QEMU VM with the specified options. It runs the VM interactively with stdin/stdout/stderr attached.

Jump to

Keyboard shortcuts

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