# cyberus-technology/cloud-hypervisor architecture

> Architecture diagram of the GitHub repository cyberus-technology/cloud-hypervisor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cyberus-technology/cloud-hypervisor
- Repository: https://github.com/cyberus-technology/cloud-hypervisor

## Overview

##### Main Components Overview

a. Host Layer
- KVM/MSHV Hypervisor integration
- Host OS kernel interface
- Hardware architecture support (x86_64 and AArch64)

b. Core VMM Layer
- Memory Management
- CPU Management
- Device Management
- Interrupt Handling
- Migration Support

c. Device Layer
- Virtio Devices
- PCI Devices
- VFIO/VFIO-user
- Platform-specific devices (ACPI, GIC, etc.)

d. API/Control Layer
- HTTP API
- DBus API
- Command Line Interface

##### Component Relationships

a. Control Flow
- API requests → VMM Core → Device Management
- Interrupt handling path: Hardware → KVM → VMM → Guest
- Device I/O path: Guest → Virtio → Host

b. Data Flow
- Memory mapping between guest and host
- Device DMA operations
- Network/Block I/O paths

##### Specific Implementation Details

Rust-specific components:

**virtio-devices/**
- Block devices
- Network devices
- Console
- Balloon
- IOMMU
- vhost-user devices

**hypervisor/**
- KVM implementation
- MSHV implementation
- Architecture-specific code

**vmm/**
- Memory management
- Device management
- Migration support

##### Key Architectural Patterns

Highlight:
- Modular design using Rust crates
- Separation between core VMM and device implementations
- Platform abstraction layers
- Security boundaries

##### Integration Points

Connections with:
- Host kernel (KVM/MSHV)
- Hardware devices (VFIO)
- External services (vhost-user)
- Management tools

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Host["Host Layer"]
        KVM["KVM/MSHV Integration"]:::host
        HostOS["Host OS Kernel Interface"]:::host
        Arch["Architecture Support"]:::host
    end

    subgraph Core["Core VMM Layer"]
        MemMgr["Memory Management"]:::core
        CPUMgr["CPU Management"]:::core
        DevMgr["Device Management"]:::core
        IntHandler["Interrupt Handling"]:::core
        Migration["Migration Support"]:::core
        VMCore["Virtual Machine Core"]:::core
    end

    subgraph Devices["Device Layer"]
        subgraph VirtIO["Virtio Devices"]
            VirtioBlock["Block Devices"]:::device
            VirtioNet["Network Devices"]:::device
            VirtioConsole["Console"]:::device
            VirtioBalloon["Balloon"]:::device
            VirtioIOMMU["IOMMU"]:::device
        end
        
        PCI["PCI Support"]:::device
        VFIO["VFIO/VFIO-user"]:::device
        DevBus["Device Bus"]:::device
    end

    subgraph API["API/Control Layer"]
        HTTP["HTTP API"]:::api
        DBus["DBus API"]:::api
        CLI["Command Line Interface"]:::api
    end

    %% Relationships
    HTTP & DBus & CLI --> VMCore
    VMCore --> MemMgr & CPUMgr & DevMgr
    DevMgr --> VirtIO & PCI & VFIO
    IntHandler --> DevMgr
    KVM --> IntHandler
    DevBus --> DevMgr
    Migration --> VMCore

    %% Click Events
    click KVM "https://github.com/cyberus-technology/cloud-hypervisor/tree/cyberus-lts/v37.x/hypervisor/src/kvm/"
    click Arch "https://github.com/cyberus-technology/cloud-hypervisor/tree/cyberus-lts/v37.x/arch/src/x86_64/"
    click MemMgr "https://github.com/cyberus-technology/cloud-hypervisor/blob/cyberus-lts/v37.x/vmm/src/memory_manager.rs"
    click CPUMgr "https://github.com/cyberus-technology/cloud-hypervisor/blob/cyberus-lts/v37.x/vmm/src/cpu.rs"
    click DevMgr "https://github.com/cyberus-technology/cloud-hypervisor/blob/cyberus-lts/v37.x/vmm/src/device_manager.rs"
    click Migration "https://github.com/cyberus-technology/cloud-hypervisor/tree/cyberus-lts/v37.x/vm-migration/src/"
    click VirtIO "https://github.com/cyberus-technology/cloud-hypervisor/tree/cyberus-lts/v37.x/virtio-devices/src/"
    click PCI "https://github.com/cyberus-technology/cloud-hypervisor/tree/cyberus-lts/v37.x/pci/src/"
    click VFIO "https://github.com/cyberus-technology/cloud-hypervisor/blob/cyberus-lts/v37.x/pci/src/vfio.rs"
    click HTTP "https://github.com/cyberus-technology/cloud-hypervisor/tree/cyberus-lts/v37.x/vmm/src/api/http/"
    click DBus "https://github.com/cyberus-technology/cloud-hypervisor/tree/cyberus-lts/v37.x/vmm/src/api/dbus/"
    click CLI "https://github.com/cyberus-technology/cloud-hypervisor/blob/cyberus-lts/v37.x/src/bin/ch-remote.rs"
    click IntHandler "https://github.com/cyberus-technology/cloud-hypervisor/blob/cyberus-lts/v37.x/vmm/src/interrupt.rs"
    click DevBus "https://github.com/cyberus-technology/cloud-hypervisor/blob/cyberus-lts/v37.x/vm-device/src/bus.rs"
    click VMCore "https://github.com/cyberus-technology/cloud-hypervisor/blob/cyberus-lts/v37.x/vmm/src/vm.rs"

    %% Styles
    classDef host fill:#gray,stroke:#333,stroke-width:2px
    classDef core fill:#blue,stroke:#333,stroke-width:2px
    classDef device fill:#green,stroke:#333,stroke-width:2px
    classDef api fill:#yellow,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        H["Host Component"]:::host
        C["Core Component"]:::core
        D["Device Component"]:::device
        A["API Component"]:::api
    end
```
