driverqemu

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 13 Imported by: 0

README

driver-qemu

kutti driver for Qemu using libvirt

PkgGoDev GitHub release (latest by date)

Images

This driver depends on .qcow2 VM images published via the kuttiproject/driver-qemu-images repository. The details of the driver-to-VM interface are documented there.

The releases of that repository are the default source for this driver. The list of available/deprecated images and the images themselves are published there. The releases of that repository follow the major and minor (rarely, also the patch) versions of this repository, but sometimes may lag by one version. The ImagesVersion constant specifies the version of the images repository that is used by a particular version of this driver.

Documentation

Overview

Package driverqemu implements a kutti driver for QEMU/KVM on Linux using libvirt. It orchestrates VMs and networks via the system-wide libvirt daemon (qemu:///system) through the virsh command line utility.

For cluster networking, it creates dedicated virtual networks for each cluster with their own bridge interface and NAT routing. For VM creation, it copies a cached Debian QCOW2 image and defines KVM domains. IP addresses are leased from dnsmasq and kept stable using static DHCP host mappings.

Index

Constants

View Source
const ImagesVersion = "0.1"

ImagesVersion defines the image repository version for the current version of the driver.

Variables

View Source
var ImagesSourceURL = "https://github.com/kuttiproject/driver-qemu-images/releases/download/v" + ImagesVersion + "/" + imagesConfigFile

ImagesSourceURL is the location where the master list of images can be found.

Functions

This section is empty.

Types

type Driver

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

Driver implements the drivercore.Driver interface for QEMU/libvirt.

func (*Driver) DeleteMachine

func (d *Driver) DeleteMachine(machinename string, clustername string) error

DeleteMachine stops, undefines the VM, removes its lease, and deletes its disk file.

func (*Driver) DeleteNetwork

func (d *Driver) DeleteNetwork(clustername string) error

DeleteNetwork destroys and undefines the libvirt virtual network.

func (*Driver) Description

func (d *Driver) Description() string

Description returns a short description of the driver.

func (*Driver) Error

func (d *Driver) Error() string

Error returns the last error reported by the Driver.

func (*Driver) GetImage

func (d *Driver) GetImage(k8sversion string) (drivercore.Image, error)

GetImage returns an image corresponding to a Kubernetes version, or an error.

func (*Driver) GetMachine

func (d *Driver) GetMachine(machinename string, clustername string) (drivercore.Machine, error)

GetMachine returns a Machine instance if defined in libvirt.

func (*Driver) K8sVersions

func (d *Driver) K8sVersions() []string

K8sVersions returns all Kubernetes versions currently supported by kutti.

func (*Driver) ListImages

func (d *Driver) ListImages() ([]drivercore.Image, error)

ListImages lists the currently available Images.

func (*Driver) Name

func (d *Driver) Name() string

Name returns "qemu".

func (*Driver) NewMachine

func (d *Driver) NewMachine(machinename string, clustername string, k8sversion string) (drivercore.Machine, error)

NewMachine defines a new QEMU VM in libvirt and configures its static DHCP lease.

func (*Driver) NewNetwork

func (d *Driver) NewNetwork(clustername string) (drivercore.Network, error)

NewNetwork creates a new libvirt NAT-based bridge network with an unused IP subnet.

func (*Driver) QualifiedMachineName

func (d *Driver) QualifiedMachineName(machinename string, clustername string) string

QualifiedMachineName returns the qualified name of a machine.

func (*Driver) QualifiedNetworkName

func (d *Driver) QualifiedNetworkName(clustername string) string

QualifiedNetworkName returns the name of the libvirt network for the given cluster.

func (*Driver) Status

func (d *Driver) Status() string

Status returns the current status of the Driver.

func (*Driver) UpdateImageList

func (d *Driver) UpdateImageList() error

UpdateImageList fetches the latest list of VM images from the driver source URL.

func (*Driver) UsesNATNetworking

func (d *Driver) UsesNATNetworking() bool

UsesNATNetworking returns false. The host bridge directly routes traffic to guest IPs without port forwarding.

func (*Driver) UsesPerClusterNetworking

func (d *Driver) UsesPerClusterNetworking() bool

UsesPerClusterNetworking returns true as we build dedicated networks.

func (*Driver) ValidK8sVersion

func (d *Driver) ValidK8sVersion(k8sversion string) bool

ValidK8sVersion returns true if the specified Kubernetes version is available.

type Image

type Image = imagecore.Image

Image implements the drivercore.Image interface for QEMU. It is the image of the imagecore package, which the qemu driver shares with the other drivers.

type Machine

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

Machine implements the drivercore.Machine interface.

func (*Machine) Error

func (m *Machine) Error() string

Error returns the last error message from driver interaction.

func (*Machine) ExecuteCommand

func (m *Machine) ExecuteCommand(command drivercore.PredefinedCommand, params ...string) error

ExecuteCommand runs a predefined command in the VM guest.

func (*Machine) ForceStop

func (m *Machine) ForceStop() error

ForceStop kills the VM immediately.

func (*Machine) ForwardPort

func (m *Machine) ForwardPort(hostport int, machineport int) error

ForwardPort is a no-op as direct routing is used.

func (*Machine) ForwardSSHPort

func (m *Machine) ForwardSSHPort(hostport int) error

ForwardSSHPort is a no-op as direct routing is used.

func (*Machine) IPAddress

func (m *Machine) IPAddress() string

IPAddress returns the assigned IP address of this machine.

func (*Machine) ImplementsCommand

func (m *Machine) ImplementsCommand(command drivercore.PredefinedCommand) bool

ImplementsCommand returns true if the predefined command is supported.

func (*Machine) Name

func (m *Machine) Name() string

Name returns the name of the machine.

func (*Machine) SSHAddress

func (m *Machine) SSHAddress() string

SSHAddress returns the SSH host and port.

func (*Machine) Start

func (m *Machine) Start() error

Start boots the VM via virsh.

func (*Machine) Status

func (m *Machine) Status() drivercore.MachineStatus

Status returns the current running status of the machine.

func (*Machine) Stop

func (m *Machine) Stop() error

Stop stops the VM gracefully via ACPI shutdown.

func (*Machine) UnforwardPort

func (m *Machine) UnforwardPort(machineport int) error

UnforwardPort is a no-op as direct routing is used.

func (*Machine) WaitForStateChange

func (m *Machine) WaitForStateChange(timeoutinseconds int)

WaitForStateChange polls status until it changes or timeout.

type Network

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

Network implements the drivercore.Network interface.

func (*Network) CIDR

func (n *Network) CIDR() string

CIDR returns the network's IPv4 address range.

func (*Network) Name

func (n *Network) Name() string

Name returns the name of the network.

func (*Network) SetCIDR

func (n *Network) SetCIDR(cidr string)

SetCIDR is not supported/implemented for QEMU driver.

Jump to

Keyboard shortcuts

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