Production-Grade Hypervisor to KVM/QEMU Migration Toolkit
Project description
hyper2kvm ๐
Production-Grade Hypervisor to KVM/QEMU Migration Toolkit โก
hyper2kvm is a comprehensive toolkit for migrating virtual machines from multiple hypervisors and disk ecosystems (VMware, Hyper-V, cloud images, raw artifacts, physical exports) into reliable, bootable KVM/QEMU systems.
Key Differentiator: Unlike traditional migration tools that rely on "boot and hope," hyper2kvm applies deterministic offline fixes to ensure first-boot success through deep inspection, bootloader repair, driver injection, and network stabilization.
๐ฉ Built for the Enterprise Linux Ecosystem
hyper2kvm is designed with Fedora and Red Hat Enterprise Linux (RHEL) as first-class platforms, leveraging the powerful open-source virtualization stack that powers cloud infrastructure worldwide.
Why Fedora/RHEL? ๐
- Native KVM Integration: Red Hat invented and maintains KVM - the Linux kernel virtualization module that powers AWS, Google Cloud, and OpenStack
- libguestfs Excellence: Deep integration with libguestfs (also Red Hat-originated) for safe, offline VM manipulation
- SELinux Security: First-class support for SELinux-enabled migrations - critical for enterprise deployments
- Dracut Framework: Advanced initramfs handling for RHEL/Fedora/CentOS systems
- Enterprise DNA: Built on the same stack that powers mission-critical workloads globally
Perfect Fit for:
- ๐ข RHEL 9/10 infrastructure migrations
- ๐ VMware to OpenStack transitions (RH OpenStack, RDO)
- โ๏ธ Hybrid cloud deployments (AWS โ โ On-Premises RHEL)
- ๐ง Fedora workstation/server consolidation
- ๐ฏ CentOS Stream development environments
Whether you're running Fedora 43, RHEL 10, CentOS Stream, or Rocky Linux, hyper2kvm speaks your language natively - from NetworkManager to systemd-networkd, from dracut to grub2-mkconfig.
Quick Start ๐ฏ
Installation
From PyPI (Recommended)
# Install system dependencies (Fedora/RHEL)
sudo dnf install -y python3-libguestfs libguestfs-tools qemu-img qemu-system-x86
# Minimal installation (works on RHEL 10 without additional repos)
pip install hyper2kvm
# Or with UI enhancements (recommended, requires rich library)
pip install hyper2kvm[ui]
# With vSphere support
pip install hyper2kvm[vsphere]
# Full installation with all features
pip install hyper2kvm[full]
Note for RHEL 10: The Rich library for progress bars is not available in RHEL 10 base repositories. hyper2kvm works perfectly without it, falling back to simple progress logging. See Optional Dependencies for details.
From Source
# Install system dependencies (Fedora/RHEL)
sudo dnf install -y python3-libguestfs libguestfs-tools qemu-img qemu-system-x86
# Clone and install
git clone https://github.com/ssahani/hyper2kvm.git
cd hyper2kvm
pip install -e .
Package Locations
- PyPI: https://pypi.org/project/hyper2kvm/ (v0.1.0+)
- GitHub: https://github.com/hyper2kvm/hyper2kvm (primary development)
- GitLab: https://gitlab.com/hyper2kvm/hyper2kvm (auto-synced mirror)
- Documentation: docs/
- Examples: examples/
See docs/INSTALL.md for Ubuntu/Debian, Arch, Alpine, macOS, and Windows (WSL).
Shell Completion (Optional)
Enable intelligent tab completion for bash, zsh, or fish shells:
# Install argcomplete
pip install argcomplete
# Install completion for your shell (interactive)
./completions/install-completions.sh
# Or install for a specific shell
./completions/install-completions.sh bash
./completions/install-completions.sh zsh
./completions/install-completions.sh fish
After installation, you can use tab completion:
hyper2kvm --<TAB> # Shows all available options
hyper2kvm --vm<TAB> # Completes to --vmdk, --vm-name, etc.
hyper2kvm --vmdk /path/<TAB> # Path completion
See completions/README.md for detailed installation instructions and troubleshooting.
Basic Usage
# Convert local VMDK to qcow2 with automatic fixes
sudo python -m hyper2kvm local \
--vmdk /path/to/disk.vmdk \
--to-output /output/disk.qcow2 \
--flatten --compress
# Migrate from vSphere with full inspection and fixes
# (powered by hypersdk for enterprise-grade VMware API integration)
sudo python -m hyper2kvm vsphere \
--vcenter vcenter.example.com \
--username admin@vsphere.local \
--vm-name "Production-VM" \
--vs-action export \
--to-output /output/
# Live fix a running Linux VM via SSH
sudo python -m hyper2kvm live-fix \
--host 192.168.1.100 \
--user root \
--fix-fstab --fix-grub --fix-network
For more examples, see docs/QUICKSTART.md and examples/README.md.
High-Performance vSphere Exports (Optional) โก
For 3-5x faster VM exports from vSphere/ESXi, install the optional hypersdk daemon:
# Install hypersdk (Fedora/RHEL)
sudo dnf install hypersdk
sudo systemctl start hypervisord
sudo systemctl enable hypervisord
# Or from source
git clone https://github.com/ssahani/hypersdk
cd hypersdk
go build -o hypervisord ./cmd/hypervisord
sudo ./install.sh
Once installed, hyper2kvm automatically detects and uses hyperctl for exports:
from hyper2kvm.vmware.transports import HYPERCTL_AVAILABLE, export_vm_hyperctl
if HYPERCTL_AVAILABLE:
# Use high-performance daemon (parallel downloads, resume support)
result = export_vm_hyperctl(
vm_path="/datacenter/vm/my-vm",
output_path="/output/",
parallel_downloads=8, # Concurrent downloads
)
Benefits:
- โก 3-5x faster exports via parallel downloads
- ๐ Resumable downloads with automatic retry
- ๐ Real-time progress tracking
- ๐ Background daemon mode for automation
- ๐ฆ Batch processing for multiple VMs
See docs/HYPERCTL_INTEGRATION.md and INTEGRATION_SUMMARY.md for details.
Features โจ
Core Capabilities ๐ช
- Multi-Hypervisor Support: VMware (vSphere, ESXi, Workstation), Hyper-V, AWS AMI, cloud images, raw disks ๐
- Offline Fixing: Deterministic repairs using libguestfs without booting the VM ๐ ๏ธ
- Windows VirtIO Injection: Automated driver injection with two-phase boot strategy ๐ช
- Linux Bootloader Repair: GRUB/GRUB2 regeneration for BIOS and UEFI systems with enhanced chroot (bind-mounted /proc, /dev, /sys for reliable bootloader operations) ๐ง
- Network Stabilization: Remove MAC pinning, clean VMware artifacts, support multiple network managers ๐
- Snapshot Handling: Intelligent flattening of VMware snapshot chains ๐ธ
- Format Conversion: VMDK, VHD/VHDX, QCOW2, RAW, VDI with compression support ๐พ
- Validation: Boot smoke tests via libvirt or direct QEMU โ
VMCraft - Advanced VM Manipulation Platform ๐
VMCraft v9.1 is hyper2kvm's modular disk image manipulation library - a pure Python platform for comprehensive VM analysis and automation.
- 343+ Methods across 58 specialized modules (26,500+ lines of code)
- Lightning-Fast Performance: Native Python with ~1.9s launch, 2-3x faster parallel mounts, 30-40% fewer system calls
- Enterprise Intelligence:
- ๐ค AI/ML Analytics: Anomaly detection, behavior prediction, workload classification
- โ๏ธ Cloud Optimization: Multi-cloud migration planning (AWS, Azure, GCP), cost analysis
- ๐ก๏ธ Disaster Recovery: RTO/RPO planning, backup strategies, failover procedures
- ๐ Audit Trail: Multi-standard compliance (SOC2, PCI-DSS, HIPAA, GDPR)
- โ๏ธ Resource Orchestration: Auto-scaling, workload balancing, maintenance scheduling
- Cross-Platform Support:
- ๐ง Linux: 15+ distributions, package management, service control, driver analysis
- ๐ช Windows: 20+ versions, registry operations, driver injection, user management
- Modern Architecture: Modular design with NBD, LVM, LUKS, RAID, ZFS support
See: VMCraft Documentation | VMCraft v9.0 Summary
Production-Ready Features ๐ญ
- YAML Configuration: Version-controlled, mergeable configuration files ๐
- Batch Processing: Parallel multi-VM migrations โ๏ธ
- Resume Support: Crash recovery with checkpointing ๐
- Dry-Run Mode: Preview changes without applying them ๐
- Detailed Reporting: Comprehensive migration reports and logs ๐
- vSphere Integration: Native API support via govc, pyvmomi, and hyperctl (high-performance provider) โ๏ธ
Batch Migration Features ๐
Enterprise-grade batch migration capabilities for large-scale VM conversions:
- Batch Orchestration: Multi-VM parallel conversions with configurable worker limits ๐
- Migration Profiles: 7 built-in profiles (production, testing, minimal, fast, windows, archive, debug) + custom profile support with inheritance ๐
- Pre/Post Hooks: Execute custom scripts, Python functions, or HTTP webhooks at 7 pipeline stages โก
- Hook stages: pre_extraction, post_extraction, pre_fix, post_fix, pre_convert, post_convert, post_validate
- Retry logic with exponential backoff
- Template variable substitution (15+ variables)
- Libvirt XML Import: Parse and convert existing libvirt VMs with automatic domain creation ๐
- Network & Storage Mapping: Transform source networks/storage to target infrastructure ๐บ๏ธ
- Source network to target bridge mapping
- MAC address policies (preserve/regenerate/custom)
- Per-disk storage pool mappings
- Direct Libvirt Integration: Automatic domain definition, disk import to storage pools, snapshot creation ๐
- Checkpoint/Resume: Crash-safe batch conversions with atomic checkpoint saves ๐พ
- Progress Tracking: Real-time progress persistence to JSON for external monitoring ๐
- Validation Framework: Extensible validation with 4 severity levels (INFO, WARNING, ERROR, CRITICAL) โ
- Profile Caching: Performance optimization with mtime-based invalidation ๐
See: Batch Migration Guide | Quick Reference
Safety Mechanisms ๐
- Automatic backups (unless explicitly disabled) ๐พ
- Atomic file operations โ๏ธ
- Validation at every pipeline stage โ
- Rollback capability for critical operations ๐
- Security scanning (Bandit, pip-audit) via GitHub Actions ๐ก๏ธ
Documentation ๐
Getting Started ๐
- Quick Start Guide - Get migrating in 5 minutes โก
- Installation Guide - Comprehensive installation for all platforms ๐ง
- CLI Reference - Complete command-line documentation ๐
- YAML Examples - Configuration file templates ๐
Deep Dive ๐ฌ
- Architecture - System design and internal structure ๐๏ธ
- Cookbook - Common migration scenarios and solutions ๐จโ๐ณ
- Failure Modes - Troubleshooting guide ๐ง
Platform-Specific ๐ฅ๏ธ
- Windows Migrations - Windows-specific guide and VirtIO driver injection ๐ช
- PhotonOS - VMware PhotonOS specific notes ๐ง
- RHEL 10 - RHEL 10 migration guide ๐ฉ
Examples ๐ก
- Example Configurations - 40+ working examples ๐ฆ
Table of Contents
- Scope and Non-Goals
- Design Principles
- Codebase Architecture
- VMCraft - libguestfs Replacement
- Supported Inputs and Execution Modes
- Pipeline Model
- Control-Plane vs Data-Plane
- Linux Fixes
- Windows Handling
- Snapshots and Flattening
- Output Formats and Validation
- YAML Configuration Model
- Multi-VM and Batch Processing
- Live-Fix Mode (SSH)
- ESXi and vSphere Integration
- Safety Mechanisms
- Daemon Mode and Automation
- Testing and Verification
- Failure Modes and Troubleshooting
- When Not to Use This Tool
- Documentation Index and References
1. Scope and Non-Goals
What This Tool Does
- Converts hypervisor disks into KVM-usable formats
- Repairs Linux and Windows guests offline
- Applies selected Linux fixes live over SSH
- Stabilizes storage and network identifiers across hypervisors
- Injects Windows VirtIO drivers safely (storage first, always)
- Uses a two-phase Windows boot strategy (SATA bootstrap โ VirtIO final) to guarantee driver activation
- Flattens snapshot chains deterministically
- Enables repeatable, automatable migrations via mergeable YAML
- Validates results using libvirt / QEMU smoke tests
While VMware remains the deepest and most battle-tested integration,
hyper2kvm is intentionally disk-centric, not platform-centric.
If it can be reduced to disks + metadata, it can enter the pipeline.
2. Installation ๐ง
Quick Install โก
# 1. Install system dependencies (Fedora/RHEL/CentOS)
sudo dnf install -y python3-libguestfs libguestfs-tools qemu-img
# 2. Install Python dependencies
pip install -r requirements.txt
# 3. Install hyper2kvm
pip install -e .
Important: libguestfs and hivex are system packages, NOT pip packages. They must be installed via your OS package manager (dnf, apt, zypper).
See docs/INSTALL.md for detailed installation instructions for all Linux distributions, macOS, and Windows (WSL).
3. Design Principles
hyper2kvm is built around a small set of non-negotiable principles:
-
Determinism over luck
Every action should be repeatable, inspectable, and explainable.
If a migration โjust happens to boot,โ something is missing. -
Disk-centric, not platform-centric
Hypervisors are treated as sources of disks and metadata, not as sacred systems. -
Control-plane separated from data-plane
Decisions are made before bytes move.
Byte movers never guess. -
Offline-first repairs
Guests should boot correctly on first power-on in KVM, without emergency console work. -
Explicit plans over implicit behavior
Snapshot flattening, driver injection, and boot strategy are always planned, never inferred mid-flight. -
Safety by default
Backups, atomic writes, and reversible changes are standardโnot optional.
These principles are enforced structurally, not by convention.
3. Codebase Architecture
hyper2kvm is organized into 14 logical packages with clear separation of concerns, making it easy to navigate, extend, and maintain.
Package Structure
hyper2kvm/
โโโ cli/
โ โโโ args/ # CLI argument parsing (6 modules)
โ โโโ builder.py # HelpFormatter + epilog builder
โ โโโ groups.py # 21 argument group builders
โ โโโ validators.py # 18 validation functions
โ โโโ helpers.py # Helper functions (_merged_*, _require, etc.)
โ โโโ parser.py # Main parser orchestration
โ โโโ __init__.py # Package exports
โ
โโโ config/ # YAML configuration loading and merging
โ
โโโ converters/ # Format conversion
โ โโโ extractors/ # Disk format extractors (4 modules)
โ โ โโโ ami.py # AWS AMI extraction (1,019 lines)
โ โ โโโ ovf.py # OVF/OVA handling (567 lines)
โ โ โโโ raw.py # RAW disk processing (646 lines)
โ โ โโโ vhd.py # VHD/VHDX handling (669 lines)
โ โโโ qemu/ # QEMU conversion (1 module)
โ โโโ converter.py # qemu-img wrapper (879 lines)
โ
โโโ core/ # Core utilities and logging
โ
โโโ fixers/ # Guest OS repair modules
โ โโโ bootloader/ # Bootloader fixes (2 modules)
โ โ โโโ fixer.py # Generic bootloader fixer (641 lines)
โ โ โโโ grub.py # GRUB-specific fixes (1,102 lines)
โ โโโ filesystem/ # Filesystem fixes (2 modules)
โ โ โโโ fixer.py # Filesystem repair (923 lines)
โ โ โโโ fstab.py # /etc/fstab rewriting (178 lines)
โ โโโ live/ # Live migration (SSH) (2 modules)
โ โ โโโ mode.py # Live-fix orchestrator
โ โ โโโ ssh_client.py # SSH connection handling
โ โโโ network/ # Network configuration fixes (6 modules)
โ โ โโโ model.py # Data models and enums (434 lines)
โ โ โโโ discovery.py # Config file discovery (362 lines)
โ โ โโโ topology.py # Topology graph building (417 lines)
โ โ โโโ validation.py # Post-fix validation (131 lines)
โ โ โโโ backend.py # Backend-specific fixers (859 lines)
โ โ โโโ core.py # Main orchestrator (418 lines)
โ โโโ offline/ # Offline helper utilities (5 modules)
โ โ โโโ mount.py # Disk mounting (566 lines)
โ โ โโโ vmware_tools_remover.py # VMware Tools cleanup (454 lines)
โ โ โโโ fstab_crypttab_rewriter.py
โ โ โโโ spec_converter.py
โ โ โโโ validation_manager.py
โ โโโ windows/ # Windows fixes (3-tier structure, 18 modules)
โ โโโ registry/ # Registry manipulation (6 modules)
โ โ โโโ base.py # Base registry operations
โ โ โโโ driver.py # Driver registry edits
โ โ โโโ bcd.py # BCD handling
โ โ โโโ ...
โ โโโ virtio/ # VirtIO driver injection (7 modules)
โ โโโ injector.py # Driver injection orchestrator
โ โโโ scanner.py # Driver file discovery
โ โโโ ...
โ
โโโ modes/ # Operational modes
โ โโโ inventory_mode.py # VM inventory scanning (318 lines)
โ โโโ plan_mode.py # Migration planning (161 lines)
โ
โโโ orchestrator/ # Pipeline orchestration
โ โโโ orchestrator.py # Main pipeline coordinator (358 lines)
โ โโโ disk_processor.py # Disk processing (335 lines)
โ โโโ vsphere_exporter.py # vSphere export (264 lines)
โ โโโ disk_discovery.py # Disk discovery (247 lines)
โ
โโโ vmware/ # VMware integration
โโโ clients/ # VMware API clients (3 modules)
โ โโโ client.py # VMwareClient (vSphere API)
โ โโโ vddk_client.py # VDDK client (1,245 lines)
โ โโโ govc_client.py # govc wrapper
โโโ transports/ # Download/export methods (8 modules)
โ โโโ http_client.py # HTTPS download with progress
โ โโโ ssh_client.py # SSH/SCP fallback
โ โโโ ovftool_client.py # ovftool wrapper
โ โโโ session_cookie.py # vSphere session management
โ โโโ ...
โโโ vsphere/ # vSphere-specific implementations (4 modules)
โ โโโ mode.py # Main vSphere orchestrator (1,470 lines)
โ โโโ command.py # vSphere CLI commands
โ โโโ ...
โโโ utils/ # VMware utilities (4 modules)
โโโ vmdk_parser.py # VMDK descriptor parsing
โโโ vmx_parser.py # VMX file parsing
โโโ ...
Package Descriptions
cli/args/
Purpose: CLI argument parsing split into focused modules
- builder.py - Custom HelpFormatter and epilog generation
- groups.py - 21 functions adding argument groups (vsphere, OVF, AMI, etc.)
- validators.py - 18 validation functions for command-line arguments
- helpers.py - Utility functions for config merging and resolution
- parser.py - Main
build_parser()andparse_args_with_config()orchestration
Key Pattern: Backward compatibility maintained via __init__.py re-exports
converters/
Purpose: Disk format conversion and extraction
extractors/ - Format-specific extraction logic:
- ami.py - AWS AMI extraction with partition handling
- ovf.py - OVF/OVA parsing and disk extraction
- raw.py - RAW disk format processing
- vhd.py - VHD/VHDX extraction (Hyper-V disks)
qemu/ - QEMU-based conversion:
- converter.py - qemu-img wrapper for format conversion (vmdk โ qcow2, etc.)
fixers/
Purpose: Guest OS repair modules (Linux and Windows)
bootloader/ - Bootloader repair:
- fixer.py - Generic bootloader detection and fixing
- grub.py - GRUB-specific fixes (BIOS and UEFI)
filesystem/ - Filesystem repairs:
- fixer.py - Filesystem check and repair (fsck, etc.)
- fstab.py -
/etc/fstabrewriting with UUID stabilization
network/ - Network configuration fixes (7 backends supported):
- model.py - Data models (
NetworkConfig,FixLevel, enums) - discovery.py - Config file discovery across distros
- topology.py - Dependency graph building for interface renames
- validation.py - Post-fix validation
- backend.py - Backend-specific fixers (netplan, systemd-networkd, ifcfg-rh, etc.)
- core.py - Main
NetworkFixerorchestrator
offline/ - Offline repair utilities:
- mount.py - Disk mounting and inspection via libguestfs
- vmware_tools_remover.py - VMware Tools cleanup
- fstab_crypttab_rewriter.py - fstab/crypttab rewriting
- spec_converter.py - Device specifier conversion (LABEL โ UUID)
- validation_manager.py - Validation orchestration
windows/ - Windows-specific fixes (3-tier structure):
- registry/ - Windows registry manipulation (6 modules)
base.py- Base registry operationsdriver.py- Driver registry editsbcd.py- BCD (Boot Configuration Database) handling
- virtio/ - VirtIO driver injection (7 modules)
injector.py- Main driver injection orchestratorscanner.py- Driver file discovery and validation
live/ - Live migration over SSH:
- mode.py - Live-fix orchestrator (apply fixes to running VMs)
- ssh_client.py - SSH connection and command execution
modes/
Purpose: Operational modes (inventory, planning)
- inventory_mode.py - VM inventory scanning and risk assessment (318 lines)
- plan_mode.py - Migration planning and preview (161 lines)
Note: Both files are small, focused, and require no further refactoring.
orchestrator/
Purpose: Pipeline orchestration (FETCH โ FLATTEN โ FIX โ CONVERT โ VALIDATE)
- orchestrator.py - Main pipeline coordinator (358 lines)
- disk_processor.py - Disk processing logic (335 lines)
- vsphere_exporter.py - vSphere export coordination (264 lines)
- disk_discovery.py - Disk discovery and metadata extraction (247 lines)
vmware/
Purpose: VMware integration (vSphere, ESXi, govc, VDDK)
clients/ - VMware API clients:
- client.py - Main VMwareClient (pyvmomi/pyVim wrapper)
- vddk_client.py - VDDK (VMware Virtual Disk Development Kit) client
- govc_client.py - govc CLI wrapper
transports/ - Data-plane download/export methods:
- http_client.py - HTTPS download with progress and resume support
- hyperctl_common.py - hyperctl CLI wrapper (hypersdk daemon, 3-5x faster than govc)
- ssh_client.py - SSH/SCP fallback transport
- ovftool_client.py - ovftool wrapper for OVF/OVA export
- session_cookie.py - vSphere session cookie management
- vddk_transport.py - VDDK-based disk export
vsphere/ - vSphere-specific orchestration:
- mode.py - Main vSphere mode orchestrator (1,470 lines)
- command.py - vSphere CLI command implementations
utils/ - VMware utilities:
- vmdk_parser.py - VMDK descriptor parsing
- vmx_parser.py - VMX configuration file parsing
Import Patterns
Package-Level Imports (Recommended)
# Network fixer
from hyper2kvm.fixers.network import NetworkFixer
# Converters
from hyper2kvm.converters.extractors import AMI, OVF, RAW, VHD
from hyper2kvm.converters.qemu import Convert
# VMware clients
from hyper2kvm.vmware.clients import VMwareClient
from hyper2kvm.vmware.transports import HTTPDownloadClient
# CLI args
from hyper2kvm.cli.args import build_parser, validate_args
Backward Compatibility (Still Works)
# Old-style imports still work via wrapper modules
from hyper2kvm.fixers.network_fixer import NetworkFixer
from hyper2kvm.vmware.vmware_client import VMwareClient
from hyper2kvm.cli.argument_parser import build_parser
All modules maintain backward compatibility via wrapper files in original locations.
4. VMCraft - Advanced VM Manipulation Platform
Overview
VMCraft v9.1 is hyper2kvm's pure Python disk image manipulation library designed for production-grade VM analysis and automation. With 343+ methods across 58 specialized modules and 26,500+ lines of code, VMCraft provides comprehensive VM inspection, modification, and intelligence capabilities with enterprise-grade performance optimizations.
Performance Characteristics
VMCraft delivers exceptional performance through native Python implementation:
| Operation | Time | Notes |
|---|---|---|
| Launch | ~1.9s | NBD connection + storage activation |
| NBD Connection | ~1.4s | Attach disk via qemu-nbd |
| OS Inspection | ~0.3s | Detect OS type, version, distribution |
| File Operations | <100ms | Read/write files, directory operations |
| Registry Operations | ~200ms | Windows registry read/write |
Architecture
VMCraft uses a modular architecture with specialized components:
hyper2kvm/core/vmcraft/
โโโ Core Infrastructure
โ โโโ main.py # VMCraft orchestrator
โ โโโ nbd.py # NBD device management
โ โโโ storage.py # LVM, LUKS, RAID, ZFS activation
โ โโโ mount.py # Filesystem mounting
โ โโโ file_ops.py # File operations (70+ methods)
โ
โโโ OS Detection
โ โโโ inspection.py # OS inspection orchestration
โ โโโ linux_detection.py # Linux distro detection
โ โโโ windows_detection.py # Windows version detection
โ
โโโ Windows Support
โ โโโ windows_registry.py # Registry operations
โ โโโ windows_drivers.py # Driver injection
โ โโโ windows_users.py # User management
โ โโโ windows_services.py # Service control
โ โโโ windows_applications.py # App detection
โ
โโโ Linux Support
โ โโโ linux_services.py # Systemd/init service control
โ โโโ [Package managers, SELinux, etc.]
โ
โโโ Enterprise Features (v9.0)
โ โโโ ml_analyzer.py # AI/ML analytics (7 methods)
โ โโโ cloud_optimizer.py # Cloud migration (6 methods)
โ โโโ disaster_recovery.py # DR planning (6 methods)
โ โโโ audit_trail.py # Compliance logging (7 methods)
โ โโโ resource_orchestrator.py # Auto-scaling (7 methods)
โ
โโโ Operational Tools
โโโ backup.py # Backup and restore
โโโ security.py # Security auditing
โโโ optimization.py # Disk optimization
โโโ advanced_analysis.py # Forensic analysis
โโโ export.py # VM export
Key Capabilities
Cross-Platform OS Support
Linux Detection (15+ distributions):
- Red Hat family: RHEL, Fedora, CentOS, Rocky, AlmaLinux, Oracle Linux
- SUSE family: SLES, openSUSE (Leap, Tumbleweed)
- Debian family: Debian, Ubuntu
- Others: Arch, Gentoo, Alpine, Slackware, Photon OS
Windows Detection (20+ versions):
- Client: Windows 12, 11, 10, 8.1, 8, 7, Vista, XP, 2000, NT
- Server: Server 2025, 2022, 2019, 2016, 2012 R2, 2012, 2008 R2, 2008, 2003
AI/ML Analytics (v9.0)
- Anomaly Detection: Statistical anomaly detection using z-scores
- Behavior Prediction: Predictive modeling with linear regression
- Workload Classification: AI-powered workload categorization
- Baseline Training: Train from normal operations
- Optimization Recommendations: AI-powered tuning suggestions
Cloud Optimization (v9.0)
- Multi-Cloud Support: AWS, Azure, GCP instance recommendations
- Readiness Assessment: Cloud migration scoring
- Cost Calculation: TCO analysis and optimization
- Migration Planning: 5-phase migration workflows
- Cloud-Native Optimization: Platform-specific tuning
Disaster Recovery (v9.0)
- RTO/RPO Planning: Calculate achievable recovery targets
- 4-Tier Classification: Tier 0-3 recovery requirements
- Backup Strategies: Automated backup planning
- Failover Procedures: Documented runbooks
- DR Testing: Simulation and validation
Compliance & Audit (v9.0)
- Event Logging: Comprehensive audit trail with SHA256 checksums
- Multi-Standard Compliance: SOC2, PCI-DSS, HIPAA, GDPR
- Change Tracking: Configuration version control
- Integrity Verification: Tamper detection
- Export Formats: JSON, CSV, Syslog
Resource Orchestration (v9.0)
- Auto-Scaling: Policy-based scaling (aggressive, moderate, conservative)
- Workload Balancing: Intelligent resource distribution
- Resource Optimization: Allocation efficiency analysis
- Maintenance Scheduling: Automated maintenance windows
- Scaling History: Track all scaling events
Usage Example
from hyper2kvm.core.vmcraft import VMCraft
# Context manager for automatic cleanup
with VMCraft() as g:
# Add disk image
g.add_drive_opts("/path/to/disk.vmdk", readonly=True, format="vmdk")
# Launch (NBD connect + storage activation)
g.launch() # ~1.9s vs libguestfs ~10-13s
# Inspect OS
roots = g.inspect_os()
for root in roots:
os_type = g.inspect_get_type(root) # "linux" or "windows"
product = g.inspect_get_product_name(root) # "Ubuntu 24.04"
version = g.inspect_get_major_version(root)
# Mount filesystem
mounts = g.inspect_get_mountpoints(roots[0])
for mp, dev in mounts.items():
g.mount(dev, mp)
# File operations
content = g.cat("/etc/hostname")
g.write("/etc/motd", "Welcome!\n")
# Windows registry (if Windows)
if os_type == "windows":
product_name = g.win_registry_read(
"SOFTWARE",
r"Microsoft\Windows NT\CurrentVersion",
"ProductName"
)
# AI/ML Analytics (v9.0)
metrics = {
"cpu_usage": [45, 50, 48, 52, 49],
"memory_usage": [60, 62, 61, 63, 59],
"disk_io": [100, 105, 102, 108, 103]
}
anomalies = g.ml_detect_anomalies(metrics, "cpu_usage")
workload = g.ml_classify_workload(metrics)
# Cloud optimization (v9.0)
readiness = g.cloud_analyze_readiness(system_info)
instances = g.cloud_recommend_instance_type(requirements, "aws")
costs = g.cloud_calculate_costs(usage_profile, "azure")
# DR planning (v9.0)
dr_plan = g.dr_create_backup_strategy(requirements)
rto_rpo = g.dr_calculate_rto_rpo(backup_config)
# Automatic cleanup on context exit
Integration with hyper2kvm
VMCraft is fully integrated into hyper2kvm's pipeline:
from hyper2kvm.core.vmcraft import VMCraft
# Direct instantiation
g = VMCraft(python_return_dict=True)
# Or use factory pattern for flexibility
from hyper2kvm.core.guestfs_factory import create_guestfs
g = create_guestfs(backend='vmcraft')
System Dependencies
Required:
qemu-utils(qemu-nbd)util-linux(mount, lsblk, blkid)lvm2(LVM support)cryptsetup(LUKS encryption)
Windows Support:
ntfs-3g(NTFS write support)libhivex-bin(Registry tools)
Optional:
mdadm(Software RAID)zfsutils-linux(ZFS support)exfat-fuse(exFAT support)
Version History
| Version | Methods | Modules | Key Features |
|---|---|---|---|
| v6.0 | 203 | 42 | Advanced security & migration |
| v7.0 | 237 | 47 | Forensic & infrastructure |
| v8.0 | 275 | 52 | Automation & intelligence |
| v9.0 | 307 | 57 | AI/ML & orchestration |
See: VMCraft README | v9.0 Summary
Developer Guide
Where to Add New Functionality
New network backend (e.g., Alpine Linux interfaces format):
โ fixers/network/backend.py - Add new fix_alpine_interfaces() method
New disk format extractor (e.g., Parallels .pvm):
โ converters/extractors/parallels.py - Create new extractor class
โ converters/extractors/__init__.py - Export new class
New VMware transport method (e.g., NFS datastore access):
โ vmware/transports/nfs_client.py - Implement new transport
โ Update vmware/vsphere/mode.py to use new transport
New Windows driver injection strategy:
โ fixers/windows/virtio/ - Add new injection module
โ Update fixers/windows/virtio/injector.py to orchestrate
New CLI validation:
โ cli/args/validators.py - Add new _validate_*() function
โ Update cli/args/validators.py:validate_args() to call it
Code Quality Standards
All modules follow these standards:
- Type annotations: 100% coverage in new code (network package standard)
- Imports:
from __future__ import annotationsfor forward references - Dependencies: Zero circular dependencies (enforced)
- Docstrings: Comprehensive module and function docstrings
- Single Responsibility: Each module has one clear purpose
- Size limit: Modules over 1,000 lines should be considered for splitting
Architecture Highlights
Zero Circular Dependencies: All packages have clean dependency graphs. The refactoring specifically eliminated circular dependencies by:
- Separating data models from business logic
- Using composition over inheritance
- Keeping interfaces in base modules
Composition Over Inheritance: Rather than deep class hierarchies, modules use composition:
# NetworkFixer composes specialized components
class NetworkFixer:
def __init__(self):
self.discovery = NetworkDiscovery()
self.topology = NetworkTopology()
self.validation = NetworkValidation()
self.backend = NetworkFixersBackend()
Backward Compatibility: All reorganizations maintain 100% backward compatibility via wrapper modules that re-export from new locations.
Package Exports:
Each package has an __init__.py that exports public APIs, allowing clean imports:
# fixers/network/__init__.py
from .core import NetworkFixer
from .model import FixLevel, NetworkConfig, InterfaceType
__all__ = ["NetworkFixer", "FixLevel", "NetworkConfig", "InterfaceType"]
4. Supported Inputs and Execution Modes
Hypervisor-Agnostic by Design
hyper2kvm is not a VMware-only tool.
VMware happens to be the most deeply integrated source today because it is:
- Common in enterprises
- Snapshot-heavy
- Full of sharp edges
Architecturally, hyper2kvm does not care about hypervisors.
It cares about:
- Disks
- Firmware assumptions
- Boot chains
- Drivers
- Metadata quality
Any platform that can ultimately produce block devices + minimal metadata can be migrated.
flowchart LR
HV1[VMware]
HV2[Hyper-V]
HV3[Cloud / AMI]
HV4[Physical / Raw]
HV5[Other Hypervisors]
HV1 --> D[Disks + Metadata]
HV2 --> D
HV3 --> D
HV4 --> D
HV5 --> D
D --> P[hyper2kvm Pipeline]
P --> K[KVM / QEMU]
style HV1 fill:#FF9800,stroke:#E65100,color:#fff
style HV2 fill:#FF9800,stroke:#E65100,color:#fff
style HV3 fill:#FF9800,stroke:#E65100,color:#fff
style HV4 fill:#FF9800,stroke:#E65100,color:#fff
style HV5 fill:#FF9800,stroke:#E65100,color:#fff
style D fill:#9C27B0,stroke:#6A1B9A,color:#fff
style P fill:#4CAF50,stroke:#2E7D32,color:#fff
style K fill:#2196F3,stroke:#1565C0,color:#fff
The moment disks are available, all inputs converge.
Primary: VMware (Deep Integration)
-
Descriptor VMDK
-
Monolithic VMDK
-
Multi-extent snapshot chains
-
OVA
-
OVF + extracted disks
-
ESXi over SSH / SCP
-
vCenter / ESXi via:
- govc (primary control-plane)
- pyvmomi / pyVim (fallback and deep inspection)
Used for:
- Inventory
- Snapshot planning
- CBT discovery
- Datastore browsing
- Artifact resolution
This is the most mature path in hyper2kvm.
Hyper-V / Microsoft Disk Formats (Disk-Level)
Supported as artifact inputs, without Hyper-V APIs:
- VHD
- VHDX
Handled via offline inspection, repair, and deterministic driver transitions.
Cloud Images / AMIs (Artifact-Level)
Supported once reduced to disks:
- AWS AMI / EBS snapshots (exported to raw / qcow2)
- Generic cloud images
Fixes include:
- NVMe vs virtio assumptions
- initramfs completeness
- Network configs bound to cloud metadata
- Bootloader defaults that fail off-cloud
No cloud lifecycle or IAM handling is included.
Generic Disk Artifacts
Any block-attachable format:
- raw
- qcow2
- vdi
- vmdk
- vhd / vhdx
Once inside, all inputs are treated equally.
5. Pipeline Model
All execution modes map to a single internal pipeline:
FETCH โ FLATTEN โ INSPECT โ FIX โ CONVERT โ VALIDATE
Stages are optional. Order is not.
| Stage | Purpose |
|---|---|
| FETCH | Obtain disks and metadata |
| FLATTEN | Collapse snapshot chains |
| INSPECT | Detect OS, layout, firmware |
| FIX | Apply deterministic repairs |
| CONVERT | Produce qcow2 / raw / etc |
| VALIDATE | Boot-test and verify |
The pipeline is explicit, inspectable, and restart-safe.
6. Control-Plane vs Data-Plane (Architecture)
This separation is the spine of hyper2kvm.
- Control-Plane decides what exists and what should happen
- Data-Plane moves bytes and produces artifacts
If you mix them, you get โit worked onceโ migrations. If you separate them, you get repeatable ones.
flowchart TB
subgraph CP["CONTROL PLANE (decide)"]
GOVC["govc (primary)"]
HYPERCTL["hyperctl โ hypervisord
high-performance daemon"]
PYVM["pyvmomi / pyVim
fallback / deep inspection"]
INV["Inventory: VM, disks,
firmware, snapshots"]
PLAN["Plans: snapshot flatten,
disk map, export intent"]
DS["Datastore browsing &
artifact resolution"]
CBT["CBT discovery +
changed ranges planning"]
GOVC --> INV
HYPERCTL --> INV
GOVC --> DS
GOVC --> CBT
HYPERCTL --> CBT
PYVM --> INV
PYVM --> CBT
INV --> PLAN
DS --> PLAN
CBT --> PLAN
end
META["plans + metadata
explicit, auditable"]
subgraph DP["DATA PLANE (move bytes)"]
GOVCEXP["govc export.ovf /
export.ova"]
HYPEREXP["hypervisord export
parallel downloads
3-5x faster, resumable"]
OVFTOOL["ovftool
OVF/OVA export/import"]
HTTP["HTTP /folder +
Range requests"]
VDDK["VDDK
high-throughput disk reads"]
SSH["SSH / SCP
fallback"]
RESUME["resume + verify +
atomic publish"]
end
CP --> META --> DP
GOVCEXP --> RESUME
HYPEREXP --> RESUME
OVFTOOL --> RESUME
HTTP --> RESUME
VDDK --> RESUME
SSH --> RESUME
style CP fill:#2196F3,stroke:#1565C0,color:#fff
style DP fill:#4CAF50,stroke:#2E7D32,color:#fff
style META fill:#9C27B0,stroke:#6A1B9A,color:#fff
style GOVC fill:#FF9800,stroke:#E65100,color:#fff
style HYPERCTL fill:#F44336,stroke:#C62828,color:#fff
style HYPEREXP fill:#F44336,stroke:#C62828,color:#fff
style PYVM fill:#FFC107,stroke:#F57C00,color:#000
style RESUME fill:#00BCD4,stroke:#006064,color:#fff
Rule
- Control-plane never moves bulk data
- Data-plane never makes inventory decisions
The bridge is always explicit plans + metadata.
7. Linux Fixes
/etc/fstabrewrite (UUID=/PARTUUID=preferred)- GRUB root stabilization (BIOS + UEFI)
- initramfs regeneration (distro-aware)
- Network cleanup (MAC pinning, hypervisor artifacts)
8. Windows Handling
Windows is a first-class citizen.
- VirtIO storage injected as BOOT_START
- Offline registry and hive edits
CriticalDeviceDatabasefixes- BCD handling with backups
- Two-phase boot: SATA bootstrap โ VirtIO final
- Driver plans are data-driven (JSON/YAML)
No blind binary patching. Everything is logged and reversible.
9. Snapshots and Flattening
- Recursive descriptor resolution
- Parent-chain verification
- Flatten before conversion
- Atomic outputs
10. Output Formats and Validation
Formats
- qcow2 (recommended)
- raw
- vdi
Validation
- Checksums
- libvirt smoke boots
- Direct QEMU boots
- BIOS and UEFI
- Headless supported
11. YAML Configuration Model
YAML is treated as code:
- Mergeable
- Reviewable
- Rerunnable
--config base.yaml --config vm.yaml --config overrides.yaml
12โ20. Advanced Topics
- Batch processing
- Live-fix mode (SSH)
- ESXi and vSphere integration
- Safety mechanisms
- Daemon and automation modes
- Testing and failure analysis
- Explicit non-goals
21. Documentation Index and References
Complete documentation is available in the docs/ directory:
- Getting Started: QUICKSTART.md, INSTALL.md
- Reference: CLI_REFERENCE.md, YAML-EXAMPLES.md
- Architecture: ARCHITECTURE.md, orchestrator/README.md
- Platform Guides: WINDOWS.md, PHOTONOS.md, RHEL10.md
- Troubleshooting: FAILURE_MODES.md, cookbook.md
- Development: BUILDING.md - Build, test, and development guide
Contributing
We welcome contributions! Here's how to get started:
Development Setup
# Clone the repository
git clone https://github.com/ssahani/hyper2kvm.git
cd hyper2kvm
# Quick start (recommended)
make quickstart
# Or manually
pip install hatch
pip install -e .[dev,full]
# Run tests
make test # Using Make
hatch run test # Using Hatch
# Run linting and security checks
make lint # Using Make
make security # Security scans
hatch run ci # Full CI pipeline using Hatch
See BUILDING.md for complete build and testing documentation.
Contribution Guidelines
- Fork and Branch: Create a feature branch from
main - Code Standards:
- Follow PEP 8 style guidelines
- Add type annotations for all new code
- Write comprehensive docstrings
- Keep modules under 1,000 lines when possible
- Testing:
- Add unit tests for new features
- Ensure all tests pass (
pytest tests/) - Run security scans (
bandit -r hyper2kvm/)
- Documentation:
- Update relevant documentation in
docs/ - Add examples to
examples/README.mdif applicable - Update
ARCHITECTURE.mdfor structural changes
- Update relevant documentation in
- Pull Requests:
- Write clear commit messages
- Reference related issues
- Ensure CI passes (tests, linting, security)
See ARCHITECTURE.md for detailed architecture guidelines.
Reporting Issues
- Bugs: Use the bug report template
- Features: Use the feature request template
- Security: Email security issues privately (see SECURITY.md if available)
License
This project is licensed under the GNU Lesser General Public License v3.0 (LGPL-3.0).
See LICENSE for full license text.
Key Points:
- You can use hyper2kvm in proprietary software without making your code open source
- Modifications to hyper2kvm itself must be released under LGPL-3.0
- No warranty provided (see license for details)
Support
Community Support
- GitHub Discussions: Ask questions and share experiences
- Issue Tracker: Report bugs and request features
- Documentation: Comprehensive guides in
docs/
Professional Support
For enterprise support, consulting, or custom development:
- Open a support request issue
- Contact the maintainers directly
Acknowledgments
hyper2kvm builds on excellent open-source projects:
- libguestfs - Offline disk inspection and modification
- QEMU - Disk format conversion and virtualization
- govc - vSphere CLI
- pyvmomi - VMware vSphere API Python SDK
- hypersdk - High-performance multi-cloud provider daemon (optional, 3-5x faster exports)
- libvirt - Virtualization management
Special thanks to all contributors.
Project Status
Current Status: Active development
- Latest Release: Check releases
- Build Status:
- Security:
Made with โค๏ธ for reliable VM migrations
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hyper2kvm-0.2.0.tar.gz.
File metadata
- Download URL: hyper2kvm-0.2.0.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4f478f9a32ea2c3fba1792ac29c16d351852fb57bcb5009ebc71c6e2c70b35f
|
|
| MD5 |
1e8f612b5d42d60b2b98c701b4846943
|
|
| BLAKE2b-256 |
bd02eaf3f93269e75cffa521ae80e787bc0f5e72bdcafa6a485731706ce6696c
|
File details
Details for the file hyper2kvm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: hyper2kvm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 979.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13b4ce28e8f4f799a10b7f3a6bd52ee6545a98cde7c2565e1f331cca893f1781
|
|
| MD5 |
2bf6af22445f96baecf3df228ea95d68
|
|
| BLAKE2b-256 |
a3dc6f68bc481d5bd335ceb548eab069b39f4d49e030b244be54db6ce4f61b49
|