Rev 45 | Go to most recent revision | Last modification | Compare with Previous | View Log | Download | RSS feed
havirt is a cluster management tool for KVM/libvirt hypervisors with shared storage. It provides safe, automated management of virtual machines across multiple nodes with resource validation, maintenance mode support, and automatic load balancing.
Data::Dumper, YAML::Tiny, FindBinsvn co http://svn.dailydata.net/svn/havirt/stable /media/shared/havirt
ln -s /media/shared/havirt/havirt /usr/local/bin/havirt
apt install -y libdata-dump-perl libyaml-tiny-perl
havirt
This creates config.yaml with safe defaults (dry-run mode enabled)
See INSTALL.md for complete installation instructions including:
Scan cluster for running VMs:
havirt node scan --force
List all nodes and their resources:
havirt node list
List all VMs:
havirt domain list
Start a VM on a specific node:
havirt domain start vmname nodename
Migrate VM to another node:
havirt domain migrate vmname targetnode
Shutdown a VM gracefully:
havirt domain shutdown vmname
Put node in maintenance mode (evacuates all VMs):
havirt node maintenance nodename 1
Take node out of maintenance:
havirt node maintenance nodename 0
Balance cluster (redistribute VMs):
havirt cluster balance
Check cluster statistics:
havirt cluster stats
havirt domain new myvm
havirt node scan --force
havirt domain update myvm
The configuration file is auto-generated at first run. Key settings:
flags:
dryrun: 1 # Set to 0 to execute commands (default=1 for safety)
verbose: 1 # Show detailed output
debug: 0 # Debug level (0-3)
testing: 0 # Use test data instead of live systems
node reserved memory: 8388608 # Reserve 8GB per node
min scan time: 300 # Minimum seconds between scans
havirt/
├── havirt # Main executable
├── *.pm # Module files (cluster, domain, node)
├── config.yaml # Configuration (auto-generated)
├── conf/ # VM XML configurations (shared across nodes)
├── var/ # Runtime data
│ ├── status.yaml # Cluster state database
│ └── lastscan # Last scan timestamp
└── tests/ # Test suite
By default, havirt operates in dry-run mode and only displays commands without executing them. To execute commands:
config.yaml and set dryrun: 0, or--dryrun 0 flag: havirt --dryrun 0 domain start vmname node1Before starting or migrating VMs, havirt verifies:
Nodes in maintenance mode:
Regular scanning keeps the cluster database current:
/5 * root /usr/local/bin/havirt node scan 2>&1 | logger -t havirt
See havirt.sample.cron for more examples.
A comprehensive test suite is available in the tests/ directory:
cd tests
./test_havirt_safe.sh # Safe tests using --testing mode
./test_integration.pl # Unit tests for modules
See tests/TESTING.md for details.
havirt extends virsh with cluster awareness:
| Task | virsh | havirt |
|------|-------|--------|
| Start VM | Starts on current node | Validates resources, checks cluster-wide, starts safely |
| Config location | /etc/libvirt/qemu/ | Shared conf/ directory |
| Cluster awareness | None | Full cluster state tracking |
| Safety checks | None | Prevents duplicate VMs, validates resources |
Enable verbose output:
havirt --verbose 1 [command]
Enable debug output:
havirt --debug 3 [command]
Force rescan if status seems incorrect:
havirt node scan --force
Check cluster state:
cat var/status.yaml
stable for productiontrunk contains latest development (may be unstable)Copyright 2024-2026 Daily Data, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that redistributions retain the copyright notice and disclaimer. See source files for complete license text (BSD-style license).