Documentation
¶
Overview ¶
Package qemu provides utilities for running QEMU virtual machines.
Index ¶
- Constants
- func BinaryAndPackageForArch(arch string) (binary, pkg string)
- func CanUseKVM(targetArch string) bool
- func CheckPrerequisites(ctx opctx.Ctx, arch string) error
- func CheckQEMUImgPrerequisite(ctx opctx.Ctx) error
- func GoArchToQEMUArch(goarch string) string
- func MachineAndCPUForArch(arch string, useKVM bool) (machine, cpu string)
- func SupportedArchitectures() []string
- type Arch
- type RunOptions
- type Runner
Constants ¶
const ( // Architecture names used by QEMU. ArchX86_64 = "x86_64" ArchAarch64 = "aarch64" )
Variables ¶
This section is empty.
Functions ¶
func BinaryAndPackageForArch ¶
BinaryAndPackageForArch returns the QEMU binary name and package for the given architecture.
func CanUseKVM ¶
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 ¶
CheckPrerequisites verifies that QEMU and sudo are available for the given architecture.
func CheckQEMUImgPrerequisite ¶ added in v0.2.0
CheckQEMUImgPrerequisite verifies that the 'qemu-img' tool is available.
func GoArchToQEMUArch ¶
GoArchToQEMUArch converts Go's GOARCH to QEMU architecture names.
func MachineAndCPUForArch ¶
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.
type RunOptions ¶
type RunOptions struct {
Arch string
FirmwarePath string
NVRAMPath string
DiskPath string
DiskType string
// CloudInitISOPath is an optional cloud-init NoCloud seed ISO. When set, it is
// attached as a non-bootable IDE CD-ROM, independent of any install ISO.
CloudInitISOPath string
// InstallISOPath is an optional ISO to boot from (e.g., a livecd or installer).
// When set, it is attached as a SCSI CD-ROM with bootindex=2 (fallback). The disk
// keeps bootindex=1 so that after installation the system boots from disk.
InstallISOPath 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 (*Runner) CreateEmptyQcow2 ¶ added in v0.2.0
CreateEmptyQcow2 creates an empty qcow2 disk image at the given path with the specified size. The size should be a QEMU-compatible size string (e.g., "10G", "512M").