A collection of interactive bash scripts to simplify KVM/QEMU virtual machine management via libvirt.
| Command | Description |
|---|---|
kvm.start |
Start a virtual machine from a selection list |
kvm.stop |
Stop a VM (graceful or force shutdown) |
kvm.clone |
Clone an existing VM with a new name |
kvm.snapshot |
Manage snapshots (create, list, restore, delete) |
kvm.rename |
Rename an existing VM |
kvm.getip |
Get IP address of a running VM |
kvm.getcli |
Connect to VM console via virsh console |
kvm.getstats |
Display dashboard with active VMs info |
# Clone the repository (anywhere you want)
git clone https://github.com/Dxsk/kvm-cli-scripts.git
cd kvm-cli-scripts
# Source in current shell
source source.me
# For permanent setup, add to ~/.bashrc or ~/.zshrc
echo 'source /path/to/kvm-cli-scripts/source.me' >> ~/.bashrcOnce sourced, commands are available as kvm.*:
kvm.start # Start a VM
kvm.stop # Stop a VM
kvm.clone # Clone a VM
kvm.snapshot # Manage snapshots
kvm.rename # Rename a VM
kvm.getip # Get VM IP address
kvm.getcli # Connect to VM console
kvm.getstats # View VM dashboardConsole Connection Tips
When using kvm.getcli, to exit the console:
- Press
Ctrl+] - Type
quit
| Dependency | Purpose |
|---|---|
virsh |
Core libvirt CLI tool |
virt-clone |
VM cloning functionality |
jq |
JSON parsing for stats dashboard |
| QEMU guest agent | IP retrieval and OS info |
System Requirements
- Linux system with KVM/QEMU installed
- libvirt daemon running
- Admin privileges for VM operations
- QEMU guest agent installed in VMs (optional, for enhanced features)
Click to expand
kvm-cli-scripts/
├── source.me # Shell functions entry point
├── colors.bash # ANSI colors and display utilities
├── clone.bash # VM cloning script
├── start.bash # VM startup script
├── stop.bash # VM shutdown script
├── rename.bash # VM renaming script
├── snapshot.bash # Snapshot management script
├── getip.bash # IP address retrieval script
├── getcli.bash # Console connection script
├── getstats.bash # VM dashboard script
├── LICENSE # MIT License
└── README.md # This file
Pre-commit Hook Setup
Install the pre-commit hook to validate scripts before committing:
cp .github/hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commitManual Linting
# Check all scripts
shellcheck *.bash source.me
# Check specific script
shellcheck clone.bashContributions are welcome! Feel free to submit issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.