Skip to main content

M4x0n's QEMU Tool - A Python-based QEMU automation framework for VM running

Project description

MAQET

Warning: Most of the code was written using AI. This product is a work in progress and should not be used in production environments under any circumstances.

MAQET (M4x0n's QEMU Tool) is a VM management system that implements unified API generation. Methods decorated with @api_method automatically become CLI commands, Python API methods, and configuration-driven calls.

Quick Start

Installation

pip install maqet

Optional Dependencies:

  • psutil - Enhanced process management and validation (recommended)

    pip install psutil
    

    Without psutil, basic PID tracking still works but ownership validation is skipped.

Core Concept

Write once, use everywhere. A single method becomes a CLI command, Python API, and configuration option:

@api_method(cli_name="start", description="Start a virtual machine", category="vm")
def start(self, vm_id: str, detach: bool = False):
    """Start a virtual machine."""
    # Single implementation

This automatically creates:

  • CLI: maqet start myvm --detach
  • Python API: maqet.start("myvm", detach=True)
  • Config: VM settings only (no commands in YAML)

Usage

Command Line Interface

# Create a VM
maqet add --config config.yaml --name myvm

# Start VM
maqet start myvm

# List all VMs
maqet ls

# Check VM status
maqet status myvm

# Execute QMP command
maqet qmp myvm system_powerdown

# Remove VM
maqet rm myvm --force

Python API

from maqet import Maqet

maqet = Maqet()

# Create and start VM
vm_id = maqet.add(name='myvm', memory='4G', cpu=2)
maqet.start(vm_id)

# Manage VM
status = maqet.status(vm_id)
maqet.qmp(vm_id, 'system_powerdown')
maqet.rm(vm_id, force=True)

Configuration Files

# config.yaml - VM configuration only
name: myvm
binary: /usr/bin/qemu-system-x86_64
memory: 4G
cpu: 2
storage:
  - name: hdd
    size: 20G
    type: qcow2
    interface: virtio
# Use configuration file
maqet add --config config.yaml
maqet start myvm --detach

Configuration Features:

  • Deep-merge multiple config files
  • Lists are concatenated (storage, network)
  • Command-line args override config values
  • Full QEMU argument support

See Configuration Guide for details.

Core Commands

Command Description Example
add Create new VM maqet add --config config.yaml --name myvm
start Start VM maqet start myvm
stop Stop VM maqet stop myvm --force
rm Remove VM maqet rm myvm --force
ls List VMs maqet ls --status running
status Show VM status maqet status myvm
apply Apply configuration maqet apply myvm --memory 8G
snapshot Manage snapshots maqet snapshot myvm create hdd snap1

QMP Commands

Command Description Example
qmp keys Send key combination maqet qmp keys myvm ctrl alt f2
qmp type Type text to VM maqet qmp type myvm "hello world"
qmp screendump Take screenshot maqet qmp screendump myvm screenshot.ppm
qmp pause Pause VM maqet qmp pause myvm
qmp resume Resume VM maqet qmp resume myvm
qmp device-add Hot-plug device maqet qmp device-add myvm usb-storage
qmp device-del Hot-unplug device maqet qmp device-del myvm usb1

Global Options

Option Description
-v, --verbose Increase verbosity (-v, -vv, -vvv)
-q, --quiet Suppress non-error output
--data-dir Override data directory
--log-file Enable file logging

Documentation

Full Documentation

Architecture

  • Unified API System - Single methods generate CLI, Python API, and config
  • State Management - SQLite backend with XDG compliance
  • QEMU Integration - Full QMP protocol support
  • Storage System - QCOW2, Raw, VirtFS support with snapshots

See QEMU Internal Architecture for details.

Development

# Run tests
python tests/run_tests.py

# Run pre-commit checks
pre-commit run --all-files

See Testing Guide for details on running tests and contributing.

Roadmap

See Roadmap and Future Features for planned improvements.

Features

  • Write Once, Use Everywhere - Single method for CLI, API, and config
  • XDG Compliant - Follows Linux directory standards
  • Production Ready - Security hardened, tested, robust error handling
  • Full QMP Support - Complete QEMU Machine Protocol integration
  • Snapshot Management - Create, load, list, and delete snapshots
  • Hot-plug Support - Add/remove devices while VM is running

Contributing

Contributions welcome! See Development Guide for contributing guidelines.

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maqet-0.0.10.tar.gz (317.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maqet-0.0.10-py3-none-any.whl (201.7 kB view details)

Uploaded Python 3

File details

Details for the file maqet-0.0.10.tar.gz.

File metadata

  • Download URL: maqet-0.0.10.tar.gz
  • Upload date:
  • Size: 317.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for maqet-0.0.10.tar.gz
Algorithm Hash digest
SHA256 47b458c3fac65f9e0855da7359470a69acc15c8f1782b177878660a060d8faa9
MD5 73267c67d719adab494be2d303d2adad
BLAKE2b-256 bd7a915f9860bc6d5f8e6a574e65b59bfac9eac046db62777def4b8dcc882e45

See more details on using hashes here.

File details

Details for the file maqet-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: maqet-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 201.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for maqet-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 dc9a6177168bd53a42c8736a413420ca67bf369174cb967f4b22ce8661b50352
MD5 0866f15bfb161348339c22185898a34c
BLAKE2b-256 57ed1d7e9c42f644d2ae25f61d6d4a9fe09364b951d0ad67a83eea899e5d852d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page