Subversion Repositories havirt

Rev

Rev 46 | Last modification | Compare with Previous | View Log | Download | RSS feed

Last modification

Path Last modification Log Download RSS
[NODE] [DIRECTORY] tests/ 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] CHANGES.md 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] cluster.pm 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] config.sample.yaml 42  240 d 22 h rodolico Log Download RSS
[NODE] [FILE] domain.pm 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] havirt 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] havirt.pm 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] havirt.sample.cron 26  497 d 23 h rodolico Log Download RSS
[NODE] [FILE] INSTALL.md 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] node.pm 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] PROGRAMMING.md 42  240 d 22 h rodolico Log Download RSS
[NODE] [FILE] README.md 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] TODO.md 44  237 d 4 h rodolico Log Download RSS
[NODE] [FILE] USAGE.md 47  3 d 23 h rodolico Log Download RSS
[NODE] [FILE] virt-install.template.sample 14  530 d 3 h rodolico Log Download RSS

havirt - High Availability Virtual Machine Cluster Manager

Overview

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.

Key Features

Requirements

Quick Start

Installation

  1. Check out from repository to shared NFS mount:

svn co http://svn.dailydata.net/svn/havirt/stable /media/shared/havirt

  1. Create symlink on each node:

ln -s /media/shared/havirt/havirt /usr/local/bin/havirt

  1. Install dependencies:

apt install -y libdata-dump-perl libyaml-tiny-perl

  1. Generate initial config:

havirt

This creates config.yaml with safe defaults (dry-run mode enabled)

Initial Setup

See INSTALL.md for complete installation instructions including:

Common Tasks

Daily Operations

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

Maintenance Operations

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

Adding New VMs

  1. Generate a virt-install template:

havirt domain new myvm

  1. Create the VM using the generated command
  1. Scan to discover the new VM:

havirt node scan --force

  1. Update VM metadata:

havirt domain update myvm

Configuration

config.yaml

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

Directory Structure

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

Safety Features

Dry-Run Mode (Default)

By default, havirt operates in dry-run mode and only displays commands without executing them. To execute commands:

Resource Validation

Before starting or migrating VMs, havirt verifies:

Maintenance Mode

Nodes in maintenance mode:

Automation

Cron Job Setup

Regular scanning keeps the cluster database current:

/etc/cron.d/havirt

/5 * root /usr/local/bin/havirt node scan 2>&1 | logger -t havirt

See havirt.sample.cron for more examples.

Testing

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.

Documentation

Architecture

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 |

Troubleshooting

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

Support and Development

License

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).