Documentation
¶
Overview ¶
Package providerch provides the host-side implementations (process management, networking, rootfs preparation) backing cloud.ProviderCH, plus configuration loading from viper.
Index ¶
- func GetConfig() cloud.CHConfig
- func NewDHCPManager(stateDir string) cloud.DHCPManager
- func NewNetworkManager() cloud.NetworkManager
- func NewProcessManager(binPath string) cloud.CHProcess
- func NewRootfsPreparer() cloud.RootfsPreparer
- func NewWindowsGuestPreparer() cloud.WindowsGuestPreparer
- type ConfigDriveSeedPreparer
- type DebugfsRootfsPreparer
- type DnsmasqDHCPManager
- type LinuxNetworkManager
- type ProcessManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfig ¶
GetConfig reads ch.* settings from viper, applying defaults for anything that isn't set.
func NewDHCPManager ¶
func NewDHCPManager(stateDir string) cloud.DHCPManager
NewDHCPManager returns a cloud.DHCPManager backed by dnsmasq, storing its per-bridge state files under stateDir.
func NewNetworkManager ¶
func NewNetworkManager() cloud.NetworkManager
NewNetworkManager returns a cloud.NetworkManager backed by `ip`.
func NewProcessManager ¶
NewProcessManager returns a cloud.CHProcess backed by the cloud-hypervisor binary at binPath ("cloud-hypervisor" if empty).
func NewRootfsPreparer ¶
func NewRootfsPreparer() cloud.RootfsPreparer
NewRootfsPreparer returns a cloud.RootfsPreparer backed by `debugfs`.
func NewWindowsGuestPreparer ¶
func NewWindowsGuestPreparer() cloud.WindowsGuestPreparer
NewWindowsGuestPreparer returns a cloud.WindowsGuestPreparer backed by ConfigDriveSeedPreparer.
Types ¶
type ConfigDriveSeedPreparer ¶
type ConfigDriveSeedPreparer struct{}
ConfigDriveSeedPreparer is the real cloud.WindowsGuestPreparer implementation: it copies the base Windows disk image unmodified (Windows disks are NTFS, which onctl has no in-process tooling to modify — unlike DebugfsRootfsPreparer's ext4 debugfs trick, so it never touches the guest disk at all) and builds an OpenStack config-drive-format seed ISO for cloudbase-init (which must be pre-installed in the base image, alongside virtio-win drivers — see docs) to apply hostname/SSH-key configuration from at boot.
UNVERIFIED: this has not been exercised against a real cloudbase-init installation. The config-drive layout and meta_data.json fields below (openstack/latest/meta_data.json + public_keys) match OpenStack's and cloudbase-init's own documented ConfigDrive datasource, but should be confirmed by hand-booting one seed ISO against the actual cloudbase-init version in use before relying on this (see the plan's Verification § 0).
func (ConfigDriveSeedPreparer) BuildSeedISO ¶
func (ConfigDriveSeedPreparer) BuildSeedISO(destPath, hostname, sshPublicKey, username string) error
func (ConfigDriveSeedPreparer) PrepareDisk ¶
func (ConfigDriveSeedPreparer) PrepareDisk(baseImage, destPath string) error
type DebugfsRootfsPreparer ¶
type DebugfsRootfsPreparer struct{}
DebugfsRootfsPreparer is the real cloud.RootfsPreparer implementation: it copies the base rootfs image and injects the SSH public key with debugfs, avoiding the need to mount the image (and therefore root) on the host.
func (DebugfsRootfsPreparer) Prepare ¶
func (DebugfsRootfsPreparer) Prepare(baseImage, destPath, hostname, sshPublicKey, username string) error
type DnsmasqDHCPManager ¶
type DnsmasqDHCPManager struct {
// StateDir is where per-bridge dnsmasq PID/lease/hosts files live
// (Config.StateDir from CHConfig).
StateDir string
}
DnsmasqDHCPManager is the real cloud.DHCPManager implementation: it runs one dnsmasq instance per bridge, serving DHCP only (--port=0 disables its built-in DNS server, since onctl has no use for it and it would otherwise compete with the host's own resolver on port 53).
UNVERIFIED: like ConfigDriveSeedPreparer, this has not been run against a real dnsmasq/cloud-hypervisor/Windows-guest chain.
func (DnsmasqDHCPManager) AddReservation ¶
func (m DnsmasqDHCPManager) AddReservation(mac, ip string) error
AddReservation appends a "mac,ip" line to the bridge's dnsmasq --dhcp-hostsfile and asks dnsmasq to reread it. It relies on the caller (ProviderCH.Deploy) having called EnsureDHCP first for the same bridge — there is no bridge parameter here because CHVMConfig/DHCPManager's Deploy-time call sites don't thread it through per-reservation; if that turns out to be needed in practice (e.g. multiple ch.network.bridge values in use), this will need a bridge parameter added.
mac is lowercased before writing: dnsmasq's --dhcp-hostsfile matching is case-sensitive against the lowercase-normalized MAC a DHCP client actually sends, so any mixed-case address here would silently never match its own reservation (caught via chMAC, which used to emit "02:C4:..." — see its doc comment).
func (DnsmasqDHCPManager) EnsureDHCP ¶
func (m DnsmasqDHCPManager) EnsureDHCP(bridge, cidr string) error
EnsureDHCP starts a dnsmasq instance bound to bridge if one isn't already running, serving the whole of cidr's host range minus the gateway address. Idempotent, like NetworkManager.EnsureBridge.
func (DnsmasqDHCPManager) RemoveReservation ¶
func (m DnsmasqDHCPManager) RemoveReservation(mac string) error
RemoveReservation removes a "mac,..." line previously added by AddReservation, plus that MAC's own lease-file entry (if any), and restarts dnsmasq so both changes actually take effect.
The lease-file cleanup (not just the hosts-file one) matters because dnsmasq treats its lease file as its own persistent state, populated at startup and then owned/rewritten by the running process from then on — SIGHUP makes it reread the hosts file (see reload, still used by AddReservation) but does NOT make it forget or reread already-granted leases. Without this, a VM's MAC/IP stays "leased" in dnsmasq's memory after onctl destroy has removed the VM and its reservation, and the next VM that reuses that IP (chIPs allocates low addresses first, so this is the common case, not an edge case) has its real DHCP handshake silently redirected to a different address than the one onctl thinks it reserved — the new VM never gets its expected IP, and onctl create times out waiting for SSH on an address the guest never actually holds. Restarting dnsmasq (rather than a lighter-weight in-place fix — there is no SIGHUP-equivalent for "forget this one lease", short of adding a new dhcp_release/dnsmasq-utils host dependency) is what actually clears that in-memory state; see restartDnsmasq.
type LinuxNetworkManager ¶
type LinuxNetworkManager struct{}
LinuxNetworkManager is the real cloud.NetworkManager implementation, shelling out to `ip` (iproute2). Creating bridges and TAP devices requires CAP_NET_ADMIN (typically root).
func (LinuxNetworkManager) CreateTap ¶
func (LinuxNetworkManager) CreateTap(tapName, bridge string) error
func (LinuxNetworkManager) DeleteTap ¶
func (LinuxNetworkManager) DeleteTap(tapName string) error
func (LinuxNetworkManager) EnsureBridge ¶
func (LinuxNetworkManager) EnsureBridge(bridge, cidr string) error
func (LinuxNetworkManager) ForgetNeighbor ¶ added in v0.1.35
func (LinuxNetworkManager) ForgetNeighbor(bridge, ip string) error
type ProcessManager ¶
type ProcessManager struct {
BinPath string
}
ProcessManager is the real cloud.CHProcess implementation: it spawns the cloud-hypervisor binary, configures it over its API socket and manages the resulting OS process.
func (ProcessManager) IsRunning ¶
func (m ProcessManager) IsRunning(pid int) bool
func (ProcessManager) Owns ¶
func (m ProcessManager) Owns(pid int, socketPath string) bool
Owns reports whether pid is a cloud-hypervisor process bound to socketPath, by checking its command line for a "--api-socket socketPath" argument pair. This guards against a persisted PID having been reused by an unrelated host process after a VMM exit or host reboot.
func (ProcessManager) Start ¶
func (m ProcessManager) Start(socketPath string, cfg cloud.CHVMConfig, logFile string) (int, error)
func (ProcessManager) Stop ¶
func (m ProcessManager) Stop(pid int) error