# sosuku325/aerovm architecture

> Architecture diagram of the GitHub repository sosuku325/aerovm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sosuku325/aerovm
- Repository: https://github.com/sosuku325/aerovm

## Overview

#### Purpose and Entry Points
AeroVM packages QEMU virtual machines as a Pterodactyl egg. Pterodactyl imports `egg/egg-aerovm.json`, selects a published Docker image, and invokes the container startup command. The runtime entry point is `scripts/start.sh`; it translates egg environment variables into persistent VM state and a QEMU process.

#### Pterodactyl Integration Boundary
The egg defines server variables, Docker image choices, allocations, and startup behavior consumed by Pterodactyl/Wings: `egg/egg-aerovm.json`. AeroVM relies on Pterodactyl to expose assigned container ports; QEMU forwarding alone cannot make a port reachable. The server container persists VM artifacts under `/home/container`, notably `disk.qcow2`, optional installer ISOs, cloud-init seed data, and generated password state.

#### VM Bootstrap and Validation
`scripts/start.sh` is the central control plane. It validates resource, hostname, password/key, display, KVM, networking, and port-collision inputs before launching anything. It derives RAM/disk defaults from Pterodactyl limits where available, protects against invalid numeric values, and chooses whether to use UEFI/OVMF and SMBIOS overrides.

#### Storage Provisioning Modes
Blank-disk images create and retain an empty qcow2 disk, optionally download and attach `os.iso`, and boot the installer until an OS is installed. Cloud-image variants copy a bundled base qcow2 into the persistent disk location and expand it when requested. Image construction and guest-image bundling are separated by Dockerfiles, including `docker/Dockerfile.alpine`, `docker/Dockerfile.ubuntu-24.04`, and `docker/Dockerfile.guest-debian-12`.

#### Cloud-Init Guest Configuration
For cloud-image containers, `scripts/start.sh` generates a NoCloud seed ISO from egg variables. It configures hostname, credentials, SSH keys, package updates, and a settings-derived instance ID so changed panel settings re-provision on restart. Graphical modes additionally cause guest-side desktop/RDP/SPICE setup through cloud-init. This is a guest boundary: AeroVM prepares seed media, while cloud-init inside the guest applies it.

#### QEMU Runtime, Networking, and Display
The startup script launches `qemu-system-x86_64` with virtio disk/network, memory balloon, RNG, optional UEFI, and either KVM or TCG emulation. User-mode QEMU networking maps the primary allocation to guest SSH and can add RDP, low-port, and explicit forwarding rules. Display selection is also assembled here: serial console, VNC/noVNC, SPICE, RDP forwarding, or headless operation. VNC/SPICE passwords are supplied through QEMU file-backed secrets rather than process arguments.

#### Optional Host KVM Enablement
Wings normally starts containers with explicit numeric identities that do not retain image group membership. The optional host-side patch exposes `/dev/kvm` and injects the host KVM group into each server container: `wings-patch/install.sh`, `wings-patch/container.go.txt`, and `wings-patch/container_legacy.go.txt`. The installer version-selects the Wings overlay, builds a replacement Go Wings binary, backs up the prior binary, configures udev permissions, and restarts Wings. At runtime, `scripts/start.sh` still decides whether KVM is safe—defaulting away from nested virtualization.

#### Distribution and Infrastructure
Docker images are published to GitHub Container Registry (`ghcr.io/sosuku325/aerovm`) and built across blank-disk, cloud-init, and debug-shell variants. The build/publish automation is ` .github/workflows/build.yml`; the debug image uses `docker/Dockerfile.shell` and `scripts/shell.sh`. Material dependencies are Docker, Pterodactyl Panel/Wings, QEMU, cloud-init guest images, xorriso, and optionally Go plus systemd/udev for the Wings KVM patch.

Main entry points: [`scripts/start.sh`](https://github.com/sosuku325/aerovm/blob/main/scripts/start.sh) (VM startup control plane), [`.github/workflows/build.yml`](https://github.com/sosuku325/aerovm/blob/main/.github/workflows/build.yml) (Build/publish workflow), [`docker/Dockerfile.guest-debian-12`](https://github.com/sosuku325/aerovm/blob/main/docker/Dockerfile.guest-debian-12) (Bundled Debian guest image), [`docker/Dockerfile.alpine`](https://github.com/sosuku325/aerovm/blob/main/docker/Dockerfile.alpine) (Runtime image variants)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_distribution["Build &amp; distribution"]
  node_registry[("GitHub Container Registry<br/>image registry")]
  node_build["Build/publish workflow<br/>CI workflow<br/>[build.yml]"]
  node_runtime_images["Runtime image variants<br/>Docker images<br/>[Dockerfile.alpine]"]
  node_guest_image["Bundled Debian guest image<br/>guest-image build"]
  node_debug_image["Debug shell image<br/>Docker image<br/>[Dockerfile.shell]"]
  node_shell["Debug shell entrypoint<br/>shell script<br/>[shell.sh]"]
end

subgraph group_runtime["Container VM runtime"]
  node_startup{{"VM startup control plane<br/>startup script<br/>[start.sh]"}}
  node_persistent_state[("Persistent VM state<br/>container volume")]
  node_blank_disk["Blank-disk provisioning<br/>storage mode"]
  node_cloud_disk["Cloud-image provisioning<br/>storage mode"]
  node_seed["NoCloud seed ISO<br/>cloud-init media"]
  node_cloud_init["Guest cloud-init<br/>guest agent"]
  node_qemu{{"QEMU VM process<br/>hypervisor"}}
  node_guest["Guest operating system<br/>virtual machine"]
end

subgraph group_hostpatch["Optional Wings KVM patch"]
  node_kvm_installer["Wings KVM patch installer<br/>host patch script<br/>[install.sh]"]
  node_wings_overlay["Patched Wings overlay<br/>Go source overlay<br/>[container.go.txt]"]
end

node_panel{{"Pterodactyl Panel/Wings<br/>orchestrator"}}
node_egg["AeroVM egg<br/>pterodactyl egg<br/>[egg-aerovm.json]"]

node_egg -->|"imported by"| node_panel
node_panel -->|"starts container"| node_startup
node_build -->|"builds"| node_runtime_images
node_build -->|"builds"| node_guest_image
node_build -->|"builds"| node_debug_image
node_runtime_images -->|"publishes"| node_registry
node_guest_image -->|"publishes"| node_registry
node_debug_image -->|"uses"| node_shell
node_registry -->|"selected image"| node_panel
node_startup -->|"selects mode"| node_blank_disk
node_startup -->|"selects mode"| node_cloud_disk
node_blank_disk -->|"creates disk and ISO state"| node_persistent_state
node_cloud_disk -->|"creates persistent disk"| node_persistent_state
node_guest_image -->|"supplies base qcow2"| node_cloud_disk
node_startup -->|"generates for cloud images"| node_seed
node_seed -->|"configures"| node_cloud_init
node_persistent_state -->|"attaches disk and media"| node_qemu
node_startup -->|"launches and configures"| node_qemu
node_qemu -->|"runs"| node_guest
node_cloud_init -->|"provisions"| node_guest
node_panel -.->|"exposes assigned ports"| node_qemu
node_kvm_installer -->|"installs"| node_wings_overlay
node_wings_overlay -->|"patches Wings runtime"| node_panel
node_panel -.->|"optionally grants /dev/kvm"| node_startup

click node_egg "https://github.com/sosuku325/aerovm/blob/main/egg/egg-aerovm.json"
click node_build "https://github.com/sosuku325/aerovm/blob/main/.github/workflows/build.yml"
click node_runtime_images "https://github.com/sosuku325/aerovm/blob/main/docker/Dockerfile.alpine"
click node_guest_image "https://github.com/sosuku325/aerovm/blob/main/docker/Dockerfile.guest-debian-12"
click node_debug_image "https://github.com/sosuku325/aerovm/blob/main/docker/Dockerfile.shell"
click node_shell "https://github.com/sosuku325/aerovm/blob/main/scripts/shell.sh"
click node_startup "https://github.com/sosuku325/aerovm/blob/main/scripts/start.sh"
click node_kvm_installer "https://github.com/sosuku325/aerovm/blob/main/wings-patch/install.sh"
click node_wings_overlay "https://github.com/sosuku325/aerovm/blob/main/wings-patch/container.go.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_registry,node_build,node_runtime_images,node_guest_image,node_debug_image,node_shell toneBlue
class node_startup,node_persistent_state,node_blank_disk,node_cloud_disk,node_seed,node_cloud_init,node_qemu,node_guest toneAmber
class node_kvm_installer,node_wings_overlay toneMint
class node_panel,node_egg toneNeutral
```

## Components

### Build & distribution

- **GitHub Container Registry**: image registry
- [Build/publish workflow](https://github.com/sosuku325/aerovm/blob/main/.github/workflows/build.yml): CI workflow · Builds blank-disk, cloud-init, and debug images. · `.github/workflows/build.yml`
- [Runtime image variants](https://github.com/sosuku325/aerovm/blob/main/docker/Dockerfile.alpine): Docker images · Alpine and Ubuntu images provide AeroVM runtime variants. · `docker/Dockerfile.alpine`
- [Bundled Debian guest image](https://github.com/sosuku325/aerovm/blob/main/docker/Dockerfile.guest-debian-12): guest-image build · Produces the cloud-image base qcow2. · `docker/Dockerfile.guest-debian-12`
- [Debug shell image](https://github.com/sosuku325/aerovm/blob/main/docker/Dockerfile.shell): Docker image · `docker/Dockerfile.shell`
- [Debug shell entrypoint](https://github.com/sosuku325/aerovm/blob/main/scripts/shell.sh): shell script · `scripts/shell.sh`

### Container VM runtime

- [VM startup control plane](https://github.com/sosuku325/aerovm/blob/main/scripts/start.sh): startup script · Validates settings, provisions state, and assembles QEMU. · `scripts/start.sh`
- **Persistent VM state**: container volume · Retains qcow2 disks, ISOs, seed media, and password state.
- **Blank-disk provisioning**: storage mode · Creates a persistent disk and optionally attaches an installer ISO.
- **Cloud-image provisioning**: storage mode · Copies and optionally expands the bundled qcow2 base image.
- **NoCloud seed ISO**: cloud-init media · Carries hostname, credentials, keys, packages, and instance ID.
- **Guest cloud-init**: guest agent · Applies seed configuration, including graphical guest setup.
- **QEMU VM process**: hypervisor · Runs the guest with virtio devices, UEFI, KVM-or-TCG, networking, and display.
- **Guest operating system**: virtual machine

### Optional Wings KVM patch

- [Wings KVM patch installer](https://github.com/sosuku325/aerovm/blob/main/wings-patch/install.sh): host patch script · Builds and installs a version-selected Wings overlay and configures udev. · `wings-patch/install.sh`
- [Patched Wings overlay](https://github.com/sosuku325/aerovm/blob/main/wings-patch/container.go.txt): Go source overlay · Injects the host KVM group and exposes /dev/kvm to server containers. · `wings-patch/container.go.txt`

### Other components

- **Pterodactyl Panel/Wings**: orchestrator · Imports the egg and runs server containers.
- [AeroVM egg](https://github.com/sosuku325/aerovm/blob/main/egg/egg-aerovm.json): pterodactyl egg · Defines variables, allocations, images, and startup behavior. · `egg/egg-aerovm.json`

## Connections

- AeroVM egg → Pterodactyl Panel/Wings: imported by
- Pterodactyl Panel/Wings → VM startup control plane: starts container
- Build/publish workflow → Runtime image variants: builds
- Build/publish workflow → Bundled Debian guest image: builds
- Build/publish workflow → Debug shell image: builds
- Runtime image variants → GitHub Container Registry: publishes
- Bundled Debian guest image → GitHub Container Registry: publishes
- Debug shell image → Debug shell entrypoint: uses
- GitHub Container Registry → Pterodactyl Panel/Wings: selected image
- VM startup control plane → Blank-disk provisioning: selects mode
- VM startup control plane → Cloud-image provisioning: selects mode
- Blank-disk provisioning → Persistent VM state: creates disk and ISO state
- Cloud-image provisioning → Persistent VM state: creates persistent disk
- Bundled Debian guest image → Cloud-image provisioning: supplies base qcow2
- VM startup control plane → NoCloud seed ISO: generates for cloud images
- NoCloud seed ISO → Guest cloud-init: configures
- Persistent VM state → QEMU VM process: attaches disk and media
- VM startup control plane → QEMU VM process: launches and configures
- QEMU VM process → Guest operating system: runs
- Guest cloud-init → Guest operating system: provisions
- Pterodactyl Panel/Wings → QEMU VM process: exposes assigned ports · Panel allocations are required for host reachability.
- Wings KVM patch installer → Patched Wings overlay: installs
- Patched Wings overlay → Pterodactyl Panel/Wings: patches Wings runtime
- Pterodactyl Panel/Wings → VM startup control plane: optionally grants /dev/kvm
