Skip to main content

Pure Rust VM disk toolkit with beautiful output, Windows registry parsing, and VM migration support - Python bindings

Project description

guestctl

A pure Rust toolkit for VM disk inspection and manipulation with beautiful emoji-enhanced output. Inspect VM disks in seconds without booting them. Designed to work seamlessly with hyper2kvm and VM migration workflows.

License: LGPL v3 Rust Crates.io PyPI Downloads

โœจ Latest (v0.3.1):

  • ๐Ÿค– AI-Powered Diagnostics - OpenAI GPT-4o integration for intelligent VM troubleshooting (optional)
  • ๐ŸŽฎ Interactive Mode - 97+ commands across 28 categories for comprehensive VM management
  • ๐ŸŽฏ Killer Summary View - See OS, version, architecture at a glance with color-coded output
  • ๐ŸชŸ Windows Registry Parsing - Full Windows version detection via registry access
  • ๐Ÿ”„ VM Migration Support - Universal fstab/crypttab rewriter for cross-platform migration
  • ๐Ÿ’พ Smart LVM Cleanup - Automatic volume group cleanup for reliable operations
  • ๐Ÿ”„ Loop Device Primary - Built-in support for RAW/IMG/ISO without kernel modules

๐Ÿš€ Recent Enhancements (Q1 2026):

  • ๐Ÿ”ง Systemd Analysis Suite - Comprehensive systemd inspection without running the VM
    • systemd-journal - Analyze journal logs with filtering, statistics, and error detection
    • systemd-services - Inspect services, dependencies, and generate Mermaid diagrams
    • systemd-boot - Boot performance analysis with optimization recommendations
  • ๐Ÿ“Š Enhanced Export Capabilities
    • PDF reports with professional layout and configurable paper sizes
    • HTML reports with Chart.js visualizations and dark theme support
    • Markdown reports with Mermaid diagrams (architecture, network, storage)
    • Customizable template system with 8 built-in templates
  • โšก Performance Optimizations
    • Binary cache (bincode) - 5-10x faster serialization, 50-70% smaller files
    • Parallel batch processing - 4-8x speedup for multiple disk inspections
    • Memory optimization - Pre-allocated vectors for 2x faster allocations
    • Cache enabled by default for instant repeated inspections

๐Ÿš€ Quick Start

Installation

Python Package (Recommended for Python users):

pip install guestctl

Rust Crate (Recommended for Rust developers):

cargo install guestctl

From Source:

git clone https://github.com/ssahani/guestkit
cd guestkit
cargo build --release

Usage

Inspect a VM disk:

guestctl inspect vm.qcow2

Output:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Ubuntu 22.04.3 LTS                                      โ”‚
โ”‚ Type: linux | Arch: x86_64 | Hostname: webserver-prod โ”‚
โ”‚ Packages: deb | Init: systemd                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ’พ Block Devices
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  โ–ช /dev/sda 8589934592 bytes (8.59 GB)

๐Ÿ–ฅ๏ธ  Operating Systems
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
    ๐Ÿง Type:         linux
    ๐Ÿ“ฆ Distribution: ubuntu
    ๐Ÿท๏ธ Product:      Ubuntu 22.04.3 LTS
    ๐Ÿ  Hostname:     webserver-prod
    โšก Init system:  systemd

    ๐Ÿ’ป Language Runtimes
    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
      ๐Ÿ python3
      ๐ŸŸข Node.js

    ๐Ÿณ Container Runtimes
    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
      ๐Ÿณ Docker

Interactive mode with 97+ commands:

guestctl interactive vm.qcow2

AI-Powered Diagnostics (optional):

# Build with AI support
cargo build --release --features ai

# Set your OpenAI API key
export OPENAI_API_KEY='your-key-here'

# Use AI assistant in interactive mode
guestctl interactive vm.qcow2
> ai why won't this boot?
> ai what security issues do you see?
> ai analyze disk usage patterns

Interactive Mode - 97+ Commands:

The interactive shell provides comprehensive VM management capabilities organized into 28 categories:

guestctl interactive vm.qcow2

Command Categories:

  • System Information (2) - info, help
  • Filesystem Operations (5) - filesystems, mount, umount, mounts
  • File Operations (8) - ls, cat, head, find, stat, download, upload, edit
  • File Management (12) - write, copy, move, delete, mkdir, chmod, chown, symlink, large-files, disk-usage
  • Package Management (5) - packages, install, remove, update, search
  • System Inspection (4) - services, users, network
  • User Management (5) - adduser, deluser, passwd, usermod, groups
  • SSH Key Management (5) - ssh-addkey, ssh-removekey, ssh-listkeys, ssh-enable, ssh-config
  • System Configuration (4) - hostname, timezone, selinux, locale
  • Service Management (6) - enable, disable, restart, logs, failed, boot-time
  • Firewall Management (3) - firewall-add, firewall-remove, firewall-list
  • Cron/Scheduled Tasks (2) - cron-add, cron-list
  • System Cleanup (4) - clean-logs, clean-cache, clean-temp, clean-kernels
  • Backup & Safety (2) - backup, backups
  • Boot Configuration (3) - grub show, grub set, grub update
  • Network Configuration (4) - net-setip, net-setdns, net-route-add, net-dhcp
  • Process Management (3) - ps, kill, top
  • Security & Audit (4) - scan-ports, audit-perms, audit-suid, check-updates
  • Database Operations (2) - db-list, db-backup
  • Advanced File Operations (5) - grep-replace, diff, tree, compress, extract
  • Git Operations (2) - git-clone, git-pull
  • Performance Tuning (2) - tune-swappiness, tune-show
  • Quick Setup Wizards (3) - setup-webserver, setup-database, setup-docker
  • Monitoring & Metrics (2) - metrics, bandwidth
  • SELinux Advanced (2) - selinux-context, selinux-audit
  • Templates (1) - template-save
  • AI Assistant (1) - ai (requires --features ai)
  • Shell Commands (3) - clear, exit, quit

See COMMANDS_SUMMARY.md for complete command reference.

Python API:

from guestctl import Guestfs

with Guestfs() as g:
    g.add_drive("disk.qcow2")
    g.launch()

    roots = g.inspect_os()
    for root in roots:
        print(f"OS: {g.inspect_get_distro(root)}")
        users = g.inspect_users(root)
        for user in users:
            print(f"User: {user.username}")

๐Ÿ’ฟ Supported Disk Formats

guestctl automatically detects your disk format and uses the optimal mounting method:

๐Ÿ”„ Loop Device (Primary) - Built into Linux Kernel โšก Default

Formats: RAW, IMG, ISO Advantages:

  • โœ… No kernel modules needed - Built into Linux kernel
  • โœ… Faster setup - Immediate availability
  • โœ… More reliable - No QEMU dependencies
  • โœ… Zero configuration - Works out of the box Use case: Cloud images, raw disks, ISO files, DD images

๐ŸŒ NBD Device (Fallback) - Advanced Format Support

Formats: QCOW2, VMDK, VDI, VHD, VHDX Advantages:

  • โœ… Compressed formats - Efficient storage
  • โœ… Snapshots - Copy-on-write support
  • โœ… Auto-loads NBD module - Automatic setup
  • โœ… QEMU integration - Native QEMU format support Use case: QEMU/KVM, VMware, VirtualBox, Hyper-V images
# Loop device used automatically (fast path)
guestctl inspect disk.raw
guestctl inspect ubuntu.img
guestctl inspect debian.iso

# NBD device used automatically (advanced formats)
guestctl inspect vm.qcow2
guestctl inspect windows.vmdk
guestctl inspect virtualbox.vdi

๐Ÿ’ก Pro Tip: Convert QCOW2 to RAW for faster repeated inspections:

qemu-img convert -O raw vm.qcow2 vm.raw
guestctl inspect vm.raw  # Now uses loop device!

Features

Core Capabilities

  • ๐Ÿฆ€ Ergonomic Rust API - Type-safe enums, builder patterns, and fluent interfaces for modern Rust idioms
  • ๐Ÿ” Comprehensive API - 578 disk image manipulation functions (563 fully implemented, 15 API-defined) - 97.4% implementation coverage
  • ๐Ÿฆ€ Pure Rust - No C dependencies for core library, memory safe, high performance
  • โšก Compile-Time Safety - Type-safe filesystems, OS detection, and partition tables prevent runtime errors

Disk & Storage

  • ๐Ÿ’ฟ Disk Format Support - RAW/IMG/ISO via loop devices (default, built-in), QCOW2/VMDK/VDI/VHD via NBD (automatic fallback)
  • ๐Ÿ“Š Partition Tables - MBR and GPT parsing, partition creation/deletion/resizing
  • ๐Ÿ—‚๏ธ Filesystem Operations - Mount/unmount, create (mkfs), check (fsck), tune, trim, resize
  • ๐Ÿ” Encryption Support - LUKS encrypted volumes with full key management
  • ๐Ÿ“š LVM Support - Logical volume management with automatic cleanup
  • ๐Ÿ”ท Advanced Filesystems - ext2/3/4, XFS, Btrfs, NTFS, ZFS, F2FS, ReiserFS, JFS, and 10+ more
  • ๐Ÿ’พ Disk Image Management - Create, resize, convert, sparsify, snapshot disk images

OS Inspection & Detection

  • ๐Ÿ”Ž OS Inspection - Detect OS type, distro, version, architecture, hostname
  • ๐ŸชŸ Windows Support - Full Windows registry parsing for version detection, registry hive access
  • ๐Ÿง Linux Detection - 30+ distributions with detailed metadata
  • ๐Ÿ“ฆ Package Management - List and inspect dpkg/rpm/pacman packages
  • ๐Ÿฅพ Boot Configuration - Bootloader detection, kernel management, UEFI support

System Analysis

  • ๐Ÿ”ง Systemd Analysis Suite - Comprehensive systemd inspection without running the VM
    • Journal Analysis - Read and analyze systemd journal logs with filtering and statistics
    • Service Analysis - Inspect services, detect failures, analyze dependencies
    • Boot Performance - Boot timing analysis with optimization recommendations
    • Mermaid Diagrams - Visual dependency trees and boot timelines
  • ๐Ÿ‘ค System Configuration - Timezone, locale, users, groups, systemd units
  • ๐ŸŒ Network Configuration - Read hostname, DNS, interface config, DHCP status
  • ๐Ÿ” SSH Configuration - Analyze SSH settings with security recommendations
  • ๐Ÿ”ง Service Management - systemd/sysvinit service detection, timers, cron jobs
  • ๐Ÿ’ป Runtime Detection - Identify Python, Node.js, Java, Ruby, Go, Perl installations
  • ๐Ÿณ Container Runtimes - Detect Docker, Podman, containerd, CRI-O

VM Migration & Preparation

  • ๐Ÿ”„ Universal fstab/crypttab Rewriter - Modify mount configurations for cross-platform migration
  • ๐Ÿงน SysPrep Operations - Remove unique identifiers for VM cloning
  • ๐Ÿ“ Device Path Translation - Automatic translation for target systems
  • ๐Ÿ”‘ LUKS Migration - Rewrite crypttab entries for encrypted volumes

Advanced Operations

  • ๐Ÿ—œ๏ธ Archive Operations - tar, tgz, cpio creation and extraction
  • ๐Ÿ”‘ Checksums - MD5, SHA1, SHA256, SHA384, SHA512
  • ๐Ÿ›ก๏ธ Security Operations - SELinux, AppArmor, capabilities, ACLs
  • ๐Ÿ”‘ SSH Operations - SSH key management, certificates, authorized_keys
  • โš™๏ธ Configuration Editing - Augeas-based config file editing
  • ๐ŸŒณ Btrfs Advanced - Subvolumes, snapshots, balance, scrub operations
  • ๐Ÿ“Š File Metadata - Detailed stat operations, inode info, permissions
  • ๐Ÿ’ฟ ISO Operations - ISO creation, inspection, mounting
  • ๐Ÿ“ค Advanced Transfer - Offset-based downloads/uploads, device copying
  • ๐Ÿ’พ MD/RAID - Software RAID creation, management, inspection
  • ๐Ÿ”„ Rsync - rsync-based file synchronization
  • ๐Ÿ“” Journal - systemd journal reading, export, verification
  • ๐Ÿฆ  YARA - malware scanning with YARA rules
  • ๐Ÿ”ฌ TSK - forensics with The Sleuth Kit (deleted file recovery)
  • ๐Ÿฉบ SMART - disk health monitoring with smartctl

Developer Experience

  • ๐Ÿ Python Bindings - PyO3-based native Python bindings with 100+ methods
  • โšก Retry Logic - Built-in exponential backoff for reliable operations
  • ๐Ÿ”Œ Extensible - Modular architecture for easy extension
  • ๐Ÿ“– Rich Documentation - Comprehensive guides and API references

Advanced CLI Features (guestctl)

  • ๐Ÿค– AI-Powered Diagnostics (optional) - OpenAI GPT-4o integration for intelligent VM troubleshooting

    • Ask natural language questions about VM issues in plain English
    • Get expert analysis of boot failures, disk problems, and configuration issues
    • Context-aware diagnostics based on query keywords (boot, LVM, security, etc.)
    • Actionable recommendations with specific commands and warnings
    • Works seamlessly with 97+ interactive commands for VM modification
    • Requires --features ai build flag and OPENAI_API_KEY environment variable
    • Example queries: "why won't this boot?", "what security issues do you see?", "analyze disk usage patterns"
  • ๐ŸŽฎ Interactive Mode - Full-featured REPL shell for VM management

    • 97+ commands organized into 28 categories
    • Tab completion and command history (readline-style)
    • Direct VM modification: user management, SSH keys, system configuration
    • Package management: install/remove/update packages without booting
    • Network configuration: static IP, DNS, routes, DHCP setup
    • Security auditing: port scanning, permission checks, SUID detection
    • Database operations: MySQL/PostgreSQL backup and management
    • Quick setup wizards: webserver, database, Docker installation
    • Performance tuning: swappiness, system metrics, bandwidth monitoring
    • Beautiful colored output with context-aware prompts
  • ๐ŸŽฏ Killer Summary View - Quick summary box showing OS product, architecture, hostname at a glance

    • Color-coded information: Green (OS product), Cyan (architecture), Blue (hostname)
    • Boxed display for immediate visual impact
    • All key information in one line
  • ๐ŸŽจ Beautiful Visual Output - Emoji-enhanced terminal output with color coding for easy scanning

    • ๐Ÿ’พ Block devices with icons and visual hierarchy
    • ๐Ÿง OS detection with distribution-specific icons (Linux, Windows, FreeBSD)
    • ๐Ÿ”ด Package manager icons (RPM, DEB, Pacman)
    • ๐ŸŒ Network configuration display
    • Smart color coding: green (secure/active), red (issues/insecure), orange (key info), gray (unknown)
  • ๐Ÿ“Š Multiple Output Formats - JSON, YAML, CSV, and beautiful plain text for automation and scripting

  • ๐ŸŽฏ Inspection Profiles - Specialized analysis modes:

    • Security Profile - SSH hardening, firewall status, user security, SELinux/AppArmor, risk scoring
    • Migration Profile - Complete inventory for VM migration planning
    • Performance Profile - System tuning opportunities and bottleneck detection
  • ๐Ÿ”„ VM Comparison - Diff two VMs or compare multiple VMs against a baseline

  • ๐Ÿ“ค Report Export - Professional report generation for documentation and compliance

    • HTML Reports - Interactive reports with Chart.js visualizations, responsive design, dark theme support
    • PDF Reports - Professional layout with configurable paper sizes (A4, Letter, Legal)
    • Markdown Reports - GitHub/GitLab compatible with Mermaid diagrams (architecture, network topology, storage hierarchy)
    • Template System - Customizable reports with 8 built-in templates (minimal, standard, detailed)
  • ๐Ÿ”ง Systemd Analysis Commands - Deep systemd inspection for troubleshooting and optimization

    • systemd-journal - Journal log analysis with filtering, error detection, and statistics
    • systemd-services - Service inspection, dependency visualization, failed service detection
    • systemd-boot - Boot performance analysis with slowest services and optimization recommendations
  • โšก Result Caching - Binary cache (bincode) for 5-10x faster repeated inspections, 50-70% smaller cache files

  • ๐Ÿš€ Batch Processing - Parallel inspection with 4-8x speedup, configurable worker threads

Quick Start

Installation

# Install system dependencies (Fedora/RHEL)
sudo dnf install qemu-img

# From source
git clone https://github.com/ssahani/guestkit
cd guestctl
cargo build --release
cargo install --path .

CLI Tool

GuestCtl is a powerful command-line tool for inspecting and manipulating VM disk images without mounting them. Features beautiful emoji-enhanced output with color coding for better readability.

Example - Inspect a VMware Photon OS disk (5 seconds):

sudo guestctl inspect photon.vmdk

Output:

๐Ÿ’พ Block Devices
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  โ–ช /dev/sda 8589934592 bytes (8.59 GB)
    โ€ข Read-only: yes

๐Ÿ—‚  Partitions
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  ๐Ÿ“ฆ /dev/sda3
    โ€ข Size:   8574189056 bytes (8.57 GB)

๐Ÿ“ Filesystems
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  ๐Ÿง /dev/sda3 ext4
    โ€ข UUID:  311182bd-f262-4081-8a2d-56624799dbad

๐Ÿ–ฅ๏ธ  Operating Systems
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
    ๐Ÿง Type:         linux
    ๐Ÿ“ฆ Distribution: photon
    ๐Ÿท๏ธ Product:      VMware Photon OS/Linux 5.0
    ๐Ÿ  Hostname:     photon-2e2948360ed5
    ๐Ÿ”ด Packages:     rpm
    โšก Init system:  systemd
    ๐Ÿ’พ Disk usage:   15.1% (5.15 TB used / 34.14 TB total)
    ๐Ÿง Kernel:       vmlinuz-6.1.10-11.ph5

Key Features:

  • ๐ŸŽจ Color-coded output - Visual hierarchy with emojis and colors
  • โšก Fast - Complete OS detection in ~5 seconds
  • ๐Ÿ”’ Safe - Read-only by default
  • ๐ŸŒ Network detection - Automatic network config parsing
  • ๐Ÿ“Š Multiple formats - Pretty terminal, JSON, HTML, YAML

Basic Operations:

# Inspect with beautiful output
sudo guestctl inspect photon.vmdk

# JSON output for scripting
sudo guestctl inspect --json ubuntu.qcow2 | jq '.operating_systems[0].distro'

# List filesystems
sudo guestctl filesystems ubuntu.qcow2

# List installed packages
sudo guestctl packages ubuntu.qcow2

# Read a file
sudo guestctl cat ubuntu.qcow2 /etc/hostname

# List directory contents
sudo guestctl list ubuntu.qcow2 /etc

# Extract a file
sudo guestctl extract ubuntu.qcow2 /etc/passwd ./passwd

Advanced Features:

# Basic inspection
guestctl inspect vm.qcow2

# JSON output for automation
guestctl inspect vm.qcow2 --output json | jq '.os.hostname'

# Security audit profile
guestctl inspect vm.qcow2 --profile security

# Migration planning profile
guestctl inspect vm.qcow2 --profile migration --output json

# Performance tuning profile
guestctl inspect vm.qcow2 --profile performance

# Compare two VMs
guestctl diff vm-before.qcow2 vm-after.qcow2

# Compare multiple VMs against baseline
guestctl compare baseline.qcow2 vm1.qcow2 vm2.qcow2 vm3.qcow2

# Export HTML report with Chart.js visualizations
guestctl inspect vm.qcow2 --export html --export-output report.html

# Export PDF report with professional layout
guestctl inspect vm.qcow2 --export pdf --export-output report.pdf

# Export Markdown inventory with Mermaid diagrams
guestctl inspect vm.qcow2 --export markdown --export-output inventory.md

# Use custom template for export
guestctl inspect vm.qcow2 --export markdown --template detailed --export-output full-report.md

# Systemd journal analysis
guestctl systemd-journal vm.qcow2                     # View all journal entries
guestctl systemd-journal vm.qcow2 --errors            # Show only errors
guestctl systemd-journal vm.qcow2 --warnings          # Show only warnings
guestctl systemd-journal vm.qcow2 --stats             # Display statistics
guestctl systemd-journal vm.qcow2 --unit sshd.service  # Filter by unit
guestctl systemd-journal vm.qcow2 --priority 3 --limit 50  # Error level, max 50

# Systemd service analysis
guestctl systemd-services vm.qcow2                        # List all services
guestctl systemd-services vm.qcow2 --failed               # Show only failed services
guestctl systemd-services vm.qcow2 --service nginx.service  # Dependency tree
guestctl systemd-services vm.qcow2 --service sshd.service --diagram  # Mermaid diagram
guestctl systemd-services vm.qcow2 --output json         # JSON output

# Systemd boot performance analysis
guestctl systemd-boot vm.qcow2                      # Show boot timing and slowest services
guestctl systemd-boot vm.qcow2 --recommendations    # Get optimization recommendations
guestctl systemd-boot vm.qcow2 --summary            # Boot metrics summary
guestctl systemd-boot vm.qcow2 --timeline > boot.md  # Generate boot timeline Mermaid diagram
guestctl systemd-boot vm.qcow2 --top 20             # Show top 20 slowest services

# Use caching for faster repeated inspections (enabled by default)
guestctl inspect vm.qcow2  # First run: ~30s, subsequent: <0.5s with binary cache
guestctl inspect vm.qcow2 --no-cache  # Disable cache
guestctl inspect vm.qcow2 --cache-refresh  # Force refresh cache

# Batch inspect multiple VMs in parallel (4-8x speedup)
guestctl inspect-batch *.qcow2 --parallel 4

# Cache management
guestctl cache-stats
guestctl cache-clear

Available Commands:

  • inspect - Comprehensive VM inspection with profiles
  • interactive - Full-featured REPL shell with 97+ commands for VM management
  • diff - Compare two disk images
  • compare - Compare multiple VMs against baseline
  • inspect-batch - Parallel batch inspection
  • systemd-journal - Analyze systemd journal logs
  • systemd-services - Inspect systemd services and dependencies
  • systemd-boot - Analyze boot performance and optimization
  • list - List files in disk image
  • extract - Extract files from disk image
  • execute - Execute commands in guest
  • backup - Create tar backup from guest
  • convert - Convert disk image formats
  • create - Create new disk image
  • check - Filesystem check
  • usage - Disk usage statistics
  • detect - Detect disk image format
  • info - Disk image information
  • cache-stats - View cache statistics
  • cache-clear - Clear inspection cache
  • version - Show version information

Full Documentation: docs/user-guides/cli-guide.md


Basic Usage

Library (API)

use guestctl::guestfs::Guestfs;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create handle
    let mut g = Guestfs::new()?;

    // Add disk image (read-only)
    g.add_drive_ro("/path/to/disk.qcow2")?;

    // Launch (analyzes disk)
    g.launch()?;

    // Inspect OS
    let roots = g.inspect_os()?;
    for root in roots {
        println!("Found OS root: {}", root);
        println!("  Type: {}", g.inspect_get_type(&root)?);
        println!("  Distro: {}", g.inspect_get_distro(&root)?);
        println!("  Version: {}.{}",
            g.inspect_get_major_version(&root)?,
            g.inspect_get_minor_version(&root)?);
        println!("  Hostname: {}", g.inspect_get_hostname(&root)?);
    }

    // List partitions
    let partitions = g.list_partitions()?;
    for part in partitions {
        println!("Partition: {}", part);
        println!("  Filesystem: {}", g.vfs_type(&part)?);
        println!("  Label: {}", g.vfs_label(&part).unwrap_or_default());
    }

    // Cleanup
    g.shutdown()?;

    Ok(())
}

Ergonomic Rust API (Recommended)

GuestCtl provides modern Rust patterns for better type safety and ergonomics:

use guestctl::guestfs::{Guestfs, FilesystemType, OsType, Distro};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Builder pattern for configuration
    let mut g = Guestfs::builder()
        .add_drive_ro("/path/to/disk.qcow2")
        .verbose(true)
        .build_and_launch()?;

    // Type-safe filesystem creation
    g.mkfs("/dev/sda1")
        .ext4()              // Type-safe enum, not string!
        .label("rootfs")
        .blocksize(4096)
        .create()?;

    // Type-safe OS detection with pattern matching
    for root in g.inspect_os()? {
        let os_type = OsType::from_str(&g.inspect_get_type(&root)?);

        match os_type {
            OsType::Linux => {
                let distro = Distro::from_str(&g.inspect_get_distro(&root)?);

                // Smart methods on enums
                if let Some(pkg_mgr) = distro.package_manager() {
                    println!("Package manager: {}", pkg_mgr);  // "deb", "rpm", "pacman", etc.
                }

                // Exhaustive pattern matching
                match distro {
                    Distro::Ubuntu | Distro::Debian => println!("Debian-based"),
                    Distro::Fedora | Distro::Rhel => println!("RPM-based"),
                    Distro::Archlinux => println!("Arch Linux"),
                    _ => println!("Other Linux"),
                }
            }
            OsType::Windows => println!("Windows detected"),
            _ => println!("Other OS"),
        }
    }

    g.shutdown()?;
    Ok(())
}

See docs/api/ergonomic-design.md and docs/api/migration-guide.md for details.

Python Bindings

GuestCtl provides native Python bindings via PyO3 for seamless integration with Python workflows.

Installation:

# Quick build (recommended)
./build_python.sh

# Or manual build
python3 -m venv .venv
source .venv/bin/activate
pip install maturin
PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 maturin develop --features python-bindings

# Verify installation
python3 -c "import guestctl; print(guestctl.__version__)"

Basic Example:

from guestctl import Guestfs

# Create handle and configure
g = Guestfs()
g.add_drive_ro("/path/to/disk.qcow2")
g.launch()

# Inspect operating system
roots = g.inspect_os()
for root in roots:
    print(f"OS Type: {g.inspect_get_type(root)}")
    print(f"Distro: {g.inspect_get_distro(root)}")
    print(f"Version: {g.inspect_get_major_version(root)}.{g.inspect_get_minor_version(root)}")
    print(f"Hostname: {g.inspect_get_hostname(root)}")

# Mount and read files
mountpoints = g.inspect_get_mountpoints(root)
for mount_path, device in sorted(mountpoints, key=lambda x: len(x[0])):
    g.mount_ro(device, mount_path)

if g.is_file("/etc/hostname"):
    content = g.read_file("/etc/hostname")
    print(f"Hostname from file: {content.decode('utf-8').strip()}")

# List installed packages
apps = g.inspect_list_applications(root)
print(f"Total packages: {len(apps)}")

# Cleanup
g.umount_all()
g.shutdown()

More Examples:

Full Documentation:

Python API Coverage:

  • 58 Guestfs methods covering OS inspection, file operations, device management, LVM, archives, and more
  • 3 DiskConverter methods for format conversion and detection
  • Comprehensive error handling with Python exceptions
  • Full type conversion between Rust and Python types

Project Structure

guestctl/
โ”œโ”€โ”€ Cargo.toml
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ ARCHITECTURE.md                    # Architecture documentation
โ”œโ”€โ”€ GUESTFS_IMPLEMENTATION_STATUS.md   # Implementation status (578 functions)
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ lib.rs                         # Library entry point
โ”‚   โ”œโ”€โ”€ core/                          # Core utilities
โ”‚   โ”‚   โ”œโ”€โ”€ error.rs                   # Error types
โ”‚   โ”‚   โ”œโ”€โ”€ retry.rs                   # Retry logic
โ”‚   โ”‚   โ””โ”€โ”€ types.rs                   # Common types
โ”‚   โ”œโ”€โ”€ disk/                          # Disk operations (Pure Rust)
โ”‚   โ”‚   โ”œโ”€โ”€ reader.rs                  # Disk image reader (magic byte detection)
โ”‚   โ”‚   โ”œโ”€โ”€ partition.rs               # MBR/GPT parser
โ”‚   โ”‚   โ””โ”€โ”€ filesystem.rs              # Filesystem detection (ext4, NTFS, etc.)
โ”‚   โ”œโ”€โ”€ guestfs/                       # GuestFS-compatible API (486 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ handle.rs                  # Main handle (new/launch/shutdown)
โ”‚   โ”‚   โ”œโ”€โ”€ inspect.rs                 # OS inspection (12 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ device.rs                  # Device operations (9 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ partition.rs               # Partition operations (6 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ mount.rs                   # Mount operations (11 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ file_ops.rs                # File operations (35+ functions)
โ”‚   โ”‚   โ”œโ”€โ”€ lvm.rs                     # LVM operations (9 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ command.rs                 # Command execution (4 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ archive.rs                 # Archive operations (7 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ luks.rs                    # LUKS encryption (6 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ checksum.rs                # Checksums and file content (9 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ filesystem.rs              # Filesystem operations (8 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ utils.rs                   # File utilities (11 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ network.rs                 # Network configuration (7 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ package.rs                 # Package management (5 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ system.rs                  # System configuration (13 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ security.rs                # Security operations (10 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ boot.rs                    # Boot configuration (10 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ disk_ops.rs                # Advanced disk operations (12 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ service.rs                 # Service management (8 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ ssh.rs                     # SSH operations (10 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ part_mgmt.rs               # Partition management (9 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ augeas.rs                  # Configuration editing (11 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ resize.rs                  # Filesystem resize (7 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ windows.rs                 # Windows operations (12 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ btrfs.rs                   # Btrfs operations (12 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ metadata.rs                # File metadata (17 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ misc.rs                    # Miscellaneous utilities (22 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ xfs.rs                     # XFS operations (4 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ iso.rs                     # ISO operations (4 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ transfer.rs                # Advanced file transfer (8 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ disk_mgmt.rs               # Disk image management (10 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ internal.rs                # Internal operations (16 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ ntfs.rs                    # NTFS operations (5 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ ext_ops.rs                 # Extended filesystem ops (11 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ glob_ops.rs                # Glob operations (7 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ node_ops.rs                # Node operations (10 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ md_ops.rs                  # MD/RAID operations (5 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ selinux_ops.rs             # SELinux extended (4 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ cap_ops.rs                 # Capabilities (4 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ acl_ops.rs                 # ACL operations (8 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ hivex_ops.rs               # Hivex operations (16 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ rsync_ops.rs               # Rsync operations (2 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ syslinux_ops.rs            # Syslinux operations (2 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ journal_ops.rs             # Journal operations (11 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ inotify_ops.rs             # Inotify operations (6 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ squashfs_ops.rs            # SquashFS operations (3 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ yara_ops.rs                # YARA operations (4 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ tsk_ops.rs                 # TSK operations (4 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ zfs_ops.rs                 # ZFS operations (10 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ ldm_ops.rs                 # LDM operations (8 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ mpath_ops.rs               # Multipath operations (5 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ grub_ops.rs                # GRUB operations (7 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ f2fs_ops.rs                # F2FS operations (4 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ bcache_ops.rs              # Bcache operations (5 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ dosfs_ops.rs               # DOSFS operations (5 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ cpio_ops.rs                # CPIO operations (3 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ nilfs_ops.rs               # NILFS operations (4 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ ufs_ops.rs                 # UFS operations (3 functions)
โ”‚   โ”‚   โ”œโ”€โ”€ inspect_enhanced.rs        # Enhanced inspection with profiles
โ”‚   โ”‚   โ””โ”€โ”€ windows_registry.rs        # Windows registry parsing
โ”‚   โ”œโ”€โ”€ python.rs                      # Python bindings (PyO3, 100+ methods)
โ”‚   โ”œโ”€โ”€ converters/                    # Disk format converters
โ”‚   โ”‚   โ””โ”€โ”€ disk_converter.rs          # qemu-img wrapper
โ”‚   โ””โ”€โ”€ cli/                           # CLI implementation
โ”‚       โ”œโ”€โ”€ commands.rs                # CLI commands
โ”‚       โ”œโ”€โ”€ profiles/                  # Inspection profiles
โ”‚       โ”œโ”€โ”€ exporters/                 # HTML/Markdown exporters
โ”‚       โ”œโ”€โ”€ formatters.rs              # Output formatters
โ”‚       โ”œโ”€โ”€ templates/                 # Askama templates
โ”‚       โ”œโ”€โ”€ diff.rs                    # VM comparison
โ”‚       โ””โ”€โ”€ cache.rs                   # Result caching
โ”œโ”€โ”€ examples/                          # Example programs
โ”‚   โ”œโ”€โ”€ rust/
โ”‚   โ”‚   โ”œโ”€โ”€ inspect_disk.rs
โ”‚   โ”‚   โ””โ”€โ”€ list_partitions.rs
โ”‚   โ””โ”€โ”€ python/                        # Python examples
โ”‚       โ”œโ”€โ”€ test_bindings.py           # Comprehensive test suite
โ”‚       โ”œโ”€โ”€ comprehensive_example.py   # Full-featured example
โ”‚       โ”œโ”€โ”€ archive_example.py         # Archive operations
โ”‚       โ”œโ”€โ”€ extract_files.py           # File extraction
โ”‚       โ””โ”€โ”€ README.md                  # Python examples guide
โ”œโ”€โ”€ docs/                              # Documentation (organized)
โ”‚   โ”œโ”€โ”€ README.md                      # Documentation index
โ”‚   โ”œโ”€โ”€ guides/                        # User guides
โ”‚   โ”œโ”€โ”€ api/                           # API documentation
โ”‚   โ”œโ”€โ”€ architecture/                  # Architecture docs
โ”‚   โ”œโ”€โ”€ development/                   # Contributor docs
โ”‚   โ”œโ”€โ”€ testing/                       # Testing docs
โ”‚   โ”œโ”€โ”€ status/                        # Implementation status
โ”‚   โ””โ”€โ”€ archive/                       # Historical docs
โ”œโ”€โ”€ pyproject.toml                     # Python package config
โ”œโ”€โ”€ build_python.sh                    # Python build script
โ””โ”€โ”€ tests/                             # Integration tests

Documentation

๐Ÿ“š Complete documentation is organized in docs/

Quick Links:

See docs/README.md for complete documentation index.

Architecture

See docs/architecture/overview.md for detailed architecture documentation.

Core Modules

guestfs - GuestFS-Compatible API (115 functions)

  • handle.rs - Main GuestFS handle (lifecycle management)
  • inspect.rs - OS inspection (12 functions, fully working)
  • device.rs - Device operations (9 functions, fully working)
  • partition.rs - Partition operations (6 functions, fully working)
  • mount.rs - Mount operations (11 functions, API-defined, needs NBD)
  • file_ops.rs - File operations (35+ functions, API-defined, needs FS parser or NBD)
  • lvm.rs - LVM operations (5 functions, API-defined)
  • command.rs - Command execution (4 functions, API-defined)
  • archive.rs - Archive operations (8 functions, API-defined)

disk - Pure Rust Disk Operations

  • reader.rs - Disk image reader with format detection via magic bytes
  • partition.rs - MBR and GPT partition table parser
  • filesystem.rs - Filesystem detection (ext4, NTFS, XFS, Btrfs, FAT32)

core - Core Utilities

  • error.rs - Error types using thiserror
  • retry.rs - Exponential backoff retry logic
  • types.rs - Common types (DiskFormat, GuestType, etc.)

Implementation Status

Category Functions Status
Total APIs 115 35 working, 80 API-defined
Lifecycle 8 โœ… Fully working
Inspection 12 โœ… Fully working
Device Ops 9 โœ… Fully working
Partition Ops 6 โœ… Fully working
Mount Ops 11 โš ๏ธ API-only (needs NBD)
File Ops 35+ โš ๏ธ API-only (needs FS parser)
LVM 5 โš ๏ธ API-only
Commands 4 โš ๏ธ API-only
Archives 8 โš ๏ธ API-only

See GUESTFS_IMPLEMENTATION_STATUS.md for complete function implementation status.

Design Principles

  1. Pure Rust - No C dependencies (except qemu-img tool)
  2. Memory Safety - Leveraging Rust's ownership system
  3. Zero-cost Abstractions - High-level APIs with no runtime overhead
  4. Clean API Design - Intuitive function signatures and error handling
  5. Modularity - Clean separation of concerns
  6. Testability - Comprehensive test coverage (33 tests passing)

Examples

See the examples/ directory for complete examples:

  • convert_disk.rs - Convert disk image formats
  • detect_format.rs - Detect and inspect disk images
  • retry_example.rs - Using retry logic with exponential backoff

Run examples with:

cargo run --example convert_disk
cargo run --example detect_format

Implementation Details

Pure Rust: No C dependencies, memory safe

Working Features:

  • โœ… Disk format detection and conversion
  • โœ… Partition table parsing (MBR, GPT)
  • โœ… Filesystem detection and mounting
  • โœ… OS inspection (Linux and Windows)
  • โœ… LVM support
  • โœ… Windows registry parsing

VM Migration Support

guestctl provides comprehensive VM migration capabilities for cross-platform migrations:

Universal fstab/crypttab Rewriter

Modify disk images to work in different environments:

use guestctl::guestfs::Guestfs;

let mut g = Guestfs::new()?;
g.add_drive("/path/to/disk.qcow2")?;
g.launch()?;

// Rewrite fstab for new environment
g.rewrite_fstab(root, old_device_mapping, new_device_mapping)?;

// Rewrite crypttab for encrypted volumes
g.rewrite_crypttab(root, luks_device_mapping)?;

Migration Features

  • Device Path Translation - Automatically translate device paths (e.g., /dev/sda โ†’ /dev/vda)
  • LUKS Support - Rewrite encrypted volume configurations
  • Cross-Platform - Migrate between different hypervisors (Hyper-V โ†’ KVM, VMware โ†’ KVM)
  • Network Configuration - Update network interface names and configurations
  • Boot Configuration - Modify bootloader settings for new environment

Use Cases

  • Hyper-V to KVM migration (via hyper2kvm)
  • VMware to KVM migration
  • Physical to virtual (P2V) conversions
  • Cloud migrations (AWS โ†’ Azure, etc.)

Integration with hyper2kvm

guestctl is designed to work seamlessly with hyper2kvm:

use guestctl::guestfs::Guestfs;

// Simple, intuitive API
let mut g = Guestfs::new()?;
g.add_drive_ro("/path/to/disk.qcow2")?;
g.launch()?;

// Inspect VM
let roots = g.inspect_os()?;
for root in &roots {
    println!("OS: {}", g.inspect_get_distro(root)?);
    println!("Version: {}.{}",
        g.inspect_get_major_version(root)?,
        g.inspect_get_minor_version(root)?);
}

Benefits for hyper2kvm and VM migration:

  • โœ… No root required for read-only operations
  • โœ… Faster - Pure Rust implementation
  • โœ… Simpler - No C dependencies
  • โœ… Safer - Rust memory safety
  • โœ… VM Migration - Universal fstab/crypttab rewriter
  • โœ… Windows Support - Full registry parsing for version detection
  • โœ… Comprehensive - 578 functions, 97.4% implementation coverage

Dependencies

System Dependencies

  • qemu-img - Disk image manipulation (QEMU tools) - Optional, for format conversion
# Fedora/RHEL
sudo dnf install qemu-img

# Ubuntu/Debian
sudo apt install qemu-utils

# Arch Linux
sudo pacman -S qemu

Note: guestctl is a pure Rust implementation with no C library dependencies!

Rust Dependencies

See Cargo.toml for complete list:

  • thiserror - Custom error types
  • byteorder - Binary parsing
  • memmap2 - Memory-mapped I/O
  • regex - Pattern matching
  • pyo3 (optional) - Python bindings
  • serde / serde_json - Serialization

Development

Building

# Debug build
cargo build

# Release build (optimized)
cargo build --release

# Run tests
cargo test

# Run with logging
RUST_LOG=debug cargo run -- convert --source test.vmdk --output test.qcow2

Running Tests

Rust Tests:

# Unit tests
cargo test

# Integration tests
cargo test --test '*'

# With coverage
cargo tarpaulin --out Html

Python Tests:

# Install pytest (if not already installed)
pip install pytest

# Run Python bindings tests
pytest tests/test_python_bindings.py -v

# Run with test disk image
export GUESTKIT_TEST_IMAGE=/path/to/test.qcow2
pytest tests/test_python_bindings.py -v

Comprehensive Testing:

# Run all tests (Rust + Python)
cargo test --all-features
pytest tests/test_python_bindings.py -v

# Example Python integration test
cd examples/python
sudo python3 test_bindings.py /path/to/disk.img

Note on Permissions: Some tests require root access for mounting disk images.

See CONTRIBUTING.md for complete testing documentation.

Code Quality

# Format code
cargo fmt

# Lint
cargo clippy

# Check documentation
cargo doc --no-deps --open

Cargo Features

guestctl uses Cargo features for optional functionality:

  • disk-ops (default) - Disk operation utilities
  • guest-inspect (default) - Guest OS inspection
  • python-bindings (optional) - PyO3 Python bindings
  • ai (optional) - AI-powered diagnostics with OpenAI GPT-4o integration
[dependencies]
guestctl = { version = "0.3", features = ["guest-inspect"] }

# With Python bindings
guestctl = { version = "0.3", features = ["python-bindings"] }

# With AI diagnostics
guestctl = { version = "0.3", features = ["ai"] }

Build with optional features:

# Python bindings
cargo build --features python-bindings

# AI diagnostics (requires OPENAI_API_KEY environment variable)
cargo build --features ai

# All features
cargo build --all-features

Roadmap

See GUESTFS_IMPLEMENTATION_STATUS.md for detailed implementation status.

Phase 0: Foundation (โœ… COMPLETE)

  • Pure Rust architecture (no C dependencies)
  • Disk format detection (QCOW2, VMDK, RAW)
  • Partition table parsing (MBR, GPT)
  • Filesystem detection (ext4, NTFS, XFS, Btrfs, FAT32)
  • Comprehensive API structure (578 functions, 97.4% implemented)
  • OS inspection (30+ functions fully working)
  • Device operations (20+ functions fully working)
  • Partition operations (15+ functions fully working)
  • Python bindings foundation (PyO3)

Phase 1: Essential Operations (๐Ÿ”„ PLANNED - 3 weeks)

Implement for 90% hyper2kvm compatibility:

  • NBD mounting - qemu-nbd integration for filesystem access
  • Command execution (4 functions) - command, sh, sh_lines
  • Archive operations (8 functions) - tar_in, tar_out, tgz_in, tgz_out
  • File operations (10 functions) - cp, mv, download, upload, grep, find
  • LUKS operations (6 functions) - luks_open, luks_close, luks_format
  • LVM activation (4 functions) - vg_activate_all, lvcreate, lvremove

Total: 30+ critical functions

Phase 2: Filesystem Operations (๐Ÿ“… FUTURE - 2 weeks)

  • Filesystem creation (mkfs, mke2fs, mkfs_btrfs)
  • Filesystem repair (fsck, e2fsck, ntfsfix, xfs_repair)
  • Extended attributes (getxattr, setxattr)
  • Resize operations (resize2fs, ntfsresize)

Phase 3: Advanced Features (๐Ÿ“… FUTURE - 4 weeks)

  • Augeas (config file editing)
  • Windows registry (Hivex operations)
  • Partition management (add/delete/resize)
  • SELinux relabeling

Phase 4: Specialized (๐Ÿ“… OPTIONAL)

  • Btrfs advanced features (subvolumes, snapshots)
  • ZFS support
  • YARA malware scanning
  • File recovery (TSK)

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Write tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

See CONTRIBUTING.md for detailed guidelines.

License

This project is licensed under the GNU Lesser General Public License v3.0 (LGPL-3.0).

See LICENSE for full license text.

Acknowledgments

  • hyper2kvm - Primary use case and integration target
  • QEMU - Disk format conversion tools
  • Rust Community - For excellent crates and tooling

Support

Related Projects

  • hyper2kvm - Production-grade VM migration toolkit
  • hypersdk - High-performance hypervisor SDK

Made with โค๏ธ for reliable VM operations

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

guestkit-0.3.1-cp314-cp314-manylinux_2_39_x86_64.whl (653.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.39+ x86-64

File details

Details for the file guestkit-0.3.1-cp314-cp314-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for guestkit-0.3.1-cp314-cp314-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 c831dffbcb8623f5a4bd76b5d3a25d26089436e107c52986f583d657477fbe3a
MD5 710b771953849c8c5c7c8831af28e234
BLAKE2b-256 a510e25c108ed1a0499c29f0a69b103b2072563f2784662267c0a5905387c900

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