Skip to main content

azarovo-hyper

CI License: MIT Python

High-level Python API to create, configure and control KVM and Xen virtual machines through libvirt: one line boots a guest, and its attributes cover everything an adaptive hypervisor controller needs — memory ballooning, memory and vCPU hot-plug, disk hot-plug, metrics, snapshots, screenshots.

Документация на русском

from azarovo_hyper import hyper

kvm1 = hyper().kvm(iso="~/Downloads/ubuntu.iso", preset="ubuntu").start()

kvm1.memory.set("3G")  # balloon
kvm1.memory.plug("1G")  # DIMM hot-plug
kvm1.cpu.set(4)  # vCPU hot-plug
print(kvm1.metrics())  # CPU %, balloon statistics, disk I/O
kvm1.delete()  # domain, disk and connection are gone

Features

  • Defaults for everything — hyper().kvm().start() is a working machine.
  • Two-command setup — uv add azarovo-hyper (pure Python, ctypes over the system libvirt) and azarovo-hyper setup for the hypervisor itself.
  • Host capacity without races — RAM, CPU and disk are checked and reserved atomically across threads and processes; InsufficientResourcesError leaves nothing behind; disks are preallocated by the kernel.
  • Built-in, schema-validated XML for KVM (q35, NUMA cell, maxMemory slots, spare PCIe ports, virtio balloon with stats, guest agent, SPICE + virtio GPU + USB tablet + vdagent) and Xen HVM (libxl, VNC, xen balloon).
  • Memory: balloon set/grow/shrink clamped to your limits, DIMM hot-plug on KVM, live memory ceiling on Xen, guest balloon statistics.
  • CPU: live vCPU hot-plug, per-machine CPU-load sampling.
  • Storage: live ISO insert/eject, disk hot-plug, I/O counters.
  • Snapshots, screenshots, viewer windows, IP addresses, NIC counters.
  • Threads, processes and asyncio: works from ThreadPoolExecutor, ProcessPoolExecutor (machines pickle, forking is safe) and asyncio.to_thread.
  • Thread-safe by design: a lock per machine, one shared connection per URI; many hypervisors and machines work in parallel without blocking each other.
  • Deterministic cleanup: stop() releases the connection, del vm / close() / with release everything, ephemeral=True also deletes the guest.
  • Presets for Ubuntu, Fedora, Debian, Alpine, Windows, ReactOS and Redox.
  • Clean architecture with pluggable drivers: @register_driver("name").

Installation

uv add azarovo-hyper              # no dependencies, nothing to compile
uv run azarovo-hyper setup        # once per machine: QEMU/KVM + libvirt, asks for sudo
uv run azarovo-hyper doctor       # optional: "ready to run guests"

Tested on and built for Linux, specifically Ubuntu (22.04, 24.04, 26.04). Support for other distributions and operating systems is planned.

Normal users get qemu:///session (no root needed); root gets qemu:///system. See installation.

Usage

from azarovo_hyper import VMState, hyper

h = hyper()
vm = h.kvm(
    "lab1",
    iso="~/isos/debian.iso",
    memory="4G",  # boot memory
    min_memory="1G",  # memory.set() never goes below
    max_memory="16G",  # hot-plug ceiling
    vcpus=2,
    max_vcpus=8,
    network="auto",  # user-mode in session, libvirt 'default' in system
)
vm.start()  # creates the qcow2, defines the domain, boots it

vm.state is VMState.RUNNING  # True
vm.display.uri  # 'spice://127.0.0.1:5900'
vm.display.open_viewer()  # virt-viewer window, closed together with the VM

stats = vm.memory.stats()  # MemoryStats(actual_mib=..., usable_mib=..., rss_mib=...)
vm.memory.set(stats.actual_mib - 512)
vm.cpu.usage()  # load since the previous call, %

vm.storage.eject()  # after the OS is installed
data = vm.storage.attach(size="50G")
vm.snapshots.create("installed")
vm.display.screenshot("screen.png")

vm.shutdown()  # ACPI, then power off after the timeout
vm.delete()

Xen works the same way: hyper().xen("x1", iso=...).start() on a Xen host.

Throw-away machines:

with hyper().kvm(memory="1G", ephemeral=True).start() as tmp:
    ...
# powered off, undefined, disk removed, connection closed

Many machines in parallel:

from concurrent.futures import ThreadPoolExecutor

machines = [h.kvm(f"node{i}") for i in range(8)]
with ThreadPoolExecutor(8) as pool:
    list(pool.map(lambda m: m.start(), machines))

Documentation

English Русский
Overview docs/en docs/ru
Quick start quickstart быстрый старт
Memory and CPU memory-cpu память и CPU
All options configuration конфигурация
Host capacity capacity ресурсы хоста
Threads and cleanup resources ресурсы

Development

uv sync --locked                 # exact versions from uv.lock
uv run ruff check . && uv run ruff format --check .
uv run pytest                    # unit tests + libvirt test:/// driver
AZAROVO_LIVE=1 uv run pytest     # also boots real KVM guests

License

MIT © 2026 Andrey Ferubko

Metadata

Release files for azarovo-hyper 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for azarovo-hyper 0.0.2
File Size Uploaded Provenance Actions
azarovo_hyper-0.0.2.tar.gz 115.6 kB Without provenance Details for azarovo_hyper-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for azarovo-hyper 0.0.2
File Interpreter ABI Platform Actions
azarovo_hyper-0.0.2-py3-none-any.whl Python 3 none any Details for azarovo_hyper-0.0.2-py3-none-any.whl

Total release size: 197.6 kB

Release files / azarovo_hyper-0.0.2.tar.gz

Download URL azarovo_hyper-0.0.2.tar.gz
Size 115.6 kB
Tags Source
SHA-256 checksum
How to use checksums
40e548f6cf7e84ae86b219a8af5e46f802de3e2f21a0ec94f29b15814840fc38
BLAKE2b-256 checksum
How to use checksums
b86fefd1fed09bd9dd0b7892a21a605af383ddedd87596d251a363bdf7a0982a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / azarovo_hyper-0.0.2-py3-none-any.whl

Download URL azarovo_hyper-0.0.2-py3-none-any.whl
Size 82.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b8df9008f1ddf2c9c576efae7c8d0ab55341ecd11fe54b996a364562116e027
BLAKE2b-256 checksum
How to use checksums
c8282f87c94229ff5033c2578639b9a8a585fa6c2688cc85bc3f07005580b0a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for azarovo-hyper 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page