qemu

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright (c) Ultraviolet SPDX-License-Identifier: Apache-2.0

Copyright (c) Ultraviolet SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	KernelFile = "bzImage"
)

Variables

This section is empty.

Functions

func CreateVM

func CreateVM(ctx context.Context, cfg Config) (*exec.Cmd, error)

func ExecutableAndArgs

func ExecutableAndArgs(cfg Config) (string, []string, error)

Types

type Config

type Config struct {
	QemuBinPath  string `env:"BIN_PATH" envDefault:"qemu-system-x86_64"`
	TmpFileLoc   string `env:"TMP_FILE_LOC" envDefault:"tmp"`
	UseSudo      bool   `env:"USE_SUDO" envDefault:"false"`
	EnableSEV    bool   `env:"ENABLE_SEV" envDefault:"false"`
	EnableSEVSNP bool   `env:"ENABLE_SEV_SNP" envDefault:"true"`

	EnableKVM bool `env:"ENABLE_KVM" envDefault:"true"`

	// machine, CPU, RAM
	Machine  string `env:"MACHINE" envDefault:"q35"`
	CPU      string `env:"CPU" envDefault:"EPYC"`
	SMPCount int    `env:"SMP_COUNT" envDefault:"4"`
	MaxCPUs  int    `env:"SMP_MAXCPUS" envDefault:"64"`
	MemID    string `env:"MEM_ID" envDefault:"ram1"`
	MemoryConfig

	// Kernel hash
	KernelHash bool `env:"KERNEL_HASH" envDefault:"false"`

	// OVMF
	OVMFCodeConfig
	OVMFVarsConfig

	// network
	NetDevConfig
	VirtioNetPciConfig

	// Vsock
	VSockConfig

	// disk
	DiskImgConfig

	// SEV
	SevConfig

	// display
	NoGraphic bool   `env:"NO_GRAPHIC" envDefault:"true"`
	Monitor   string `env:"MONITOR" envDefault:"pty"`
}

type DiskImgConfig

type DiskImgConfig struct {
	KernelFile string `env:"DISK_IMG_KERNEL_FILE" envDefault:"img/bzImage"`
	RootFsFile string `env:"DISK_IMG_ROOTFS_FILE" envDefault:"img/rootfs.cpio.gz"`
}

type MemoryConfig

type MemoryConfig struct {
	Size  string `env:"MEMORY_SIZE" envDefault:"2048M"`
	Slots int    `env:"MEMORY_SLOTS" envDefault:"5"`
	Max   string `env:"MAX_MEMORY" envDefault:"30G"`
}

type NetDevConfig

type NetDevConfig struct {
	ID            string `env:"NETDEV_ID"       envDefault:"vmnic"`
	HostFwdAgent  int    `env:"HOST_FWD_AGENT"  envDefault:"7020"`
	GuestFwdAgent int    `env:"GUEST_FWD_AGENT" envDefault:"7002"`
}

type OVMFCodeConfig

type OVMFCodeConfig struct {
	If       string `env:"OVMF_CODE_IF" envDefault:"pflash"`
	Format   string `env:"OVMF_CODE_FORMAT" envDefault:"raw"`
	Unit     int    `env:"OVMF_CODE_UNIT" envDefault:"0"`
	File     string `env:"OVMF_CODE_FILE" envDefault:"/usr/share/OVMF/OVMF_CODE.fd"`
	ReadOnly string `env:"OVMF_CODE_READONLY" envDefault:"on"`
}

type OVMFVarsConfig

type OVMFVarsConfig struct {
	If     string `env:"OVMF_VARS_IF" envDefault:"pflash"`
	Format string `env:"OVMF_VARS_FORMAT" envDefault:"raw"`
	Unit   int    `env:"OVMF_VARS_UNIT" envDefault:"1"`
	File   string `env:"OVMF_VARS_FILE" envDefault:"/usr/share/OVMF/OVMF_VARS.fd"`
}

type SevConfig

type SevConfig struct {
	ID              string `env:"SEV_ID" envDefault:"sev0"`
	CBitPos         int    `env:"SEV_CBITPOS" envDefault:"51"`
	ReducedPhysBits int    `env:"SEV_REDUCED_PHYS_BITS" envDefault:"1"`
}

type VSockConfig added in v0.0.2

type VSockConfig struct {
	ID       string `env:"VSOCK_ID"        envDefault:"vhost-vsock-pci0"`
	GuestCID int    `env:"VSOCK_GUEST_CID" envDefault:"3"`
	// contains filtered or unexported fields
}

type VirtioNetPciConfig

type VirtioNetPciConfig struct {
	DisableLegacy string `env:"VIRTIO_NET_PCI_DISABLE_LEGACY" envDefault:"on"`
	IOMMUPlatform bool   `env:"VIRTIO_NET_PCI_IOMMU_PLATFORM" envDefault:"true"`
	Addr          string `env:"VIRTIO_NET_PCI_ADDR" envDefault:"0x2"`
	ROMFile       string `env:"VIRTIO_NET_PCI_ROMFILE"`
}

Jump to

Keyboard shortcuts

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