$ show canonical/multipass
Multipass is a production-grade virtual machine orchestration tool that provides a daemon (multipassd) with a gRPC API and multiple clients (CLI, Flutter GUI). The daemon manages the full VM lifecycle—launch, start, stop, suspend, snapshot, clone, delete—across several hypervisor backends: QEMU/KVM (Linux/macOS), Apple VZ (macOS), Hyper‑V/HCS (Windows), and VirtualBox (legacy). The codebase demonstrates a client–server architecture where the CLI binary dispatches commands to the daemon via gRPC using protobuf messages, and output is formatted in table/JSON/CSV/YAML. All VMs are provisioned with cloud‑init, and images are fetched from Ubuntu's SimpleStreams or custom HTTP sources with caching and hash verification. Network bridges, DNSMasq on Linux, and HCN/HCS on Windows provide connectivity; mounts are handled via SSHFS (or SMB on Windows). The design includes a plugin‑style backtracking for hypervisors, a persistent settings system backed by QSettings and JSON files, an extensible logging framework (journald, syslog, Windows Event Log), and a new‑release monitor that polls GitHub releases. The repository also contains a Rust component for petname generation and logging, a Python distro‑scraper that periodically refreshes cloud image metadata, and a comprehensive test suite with C++ unit tests (Google Test/Mock) and Python integration tests (pytest, pexpect). Overall, it is a mature, cross‑platform application with strong engineering practices but carries some technical debt from legacy backends and ongoing migrations.
The LLM identified 5 files worth highlighting for reuse:
Implements a generic, mockable Singleton<T> base class used extensively throughout the codebase for global services (Platform, Settings, ProcessFactory, FileOps, etc.). The pattern allows swapping in a mock instance for unit tests via `mock()` and `reset()` static methods. It is self-contained (only depends on standard headers) and can be extracted for any C++ project that needs testable singletons.
Defines an abstract `SettingSpec` with key, default value, optional interpreter (free function for validation/transformation), and derived types like `BoolSettingSpec`. The settings system includes `SettingsHandler` for persistence backends (QSettings, JSON), and `PersistentSettingsHandler` with transactional writes. This component is cleanly separated from the rest of the application and could serve as a foundation for any app requiring typed, interpreted settings with multiple storage backends.
Provides `ProcessSpec` base class and concrete implementations (`SimpleProcessSpec`, `QemuImgProcessSpec`) that describe external processes (program, arguments, working directory, environment, AppArmor profile on Linux). Combined with `ProcessFactory` singleton and `BasicProcess` execution wrapper, this creates a platform-independent interface for running external processes with argument verification and mocking support. The spec pattern is reusable for any application that needs to manage multiple external subprocesses with varying configurations.
Wraps libssh's SFTP operations into a higher-level `SFTPClient` class supporting push, pull, recursive directory transfers, and progress monitoring. Uses RAII for session management and handles symlinks, permissions, and error reporting. This component is self-contained (depends only on libssh and standard types) and could be extracted to provide SFTP file transfer capabilities in any C++ SSH application without reinventing the low‑level API.
Provides `Subnet` (CIDR representation with prefix length, subnet mask, broadcast, usable address range) and `SubnetAllocator` (sequential allocation from a pool of subnets, singleton for availability zones). The classes are pure math (no external dependencies) and can be reused in any networking context requiring IP subnet calculation and allocation, such as virtual networking, container IPAM, or VPN configuration.