Files
easyqemu/README.md
2026-01-07 02:01:17 +01:00

11 KiB

EasyQEMU

EasyQEMU is an intuitive command-line tool for managing QEMU virtual machines. It provides a Docker-like interface for creating, managing, and organizing VMs with features like snapshots, volume management, and a repository system.

Features

  • 🚀 Easy VM Management: Create, start, stop, modify, and delete virtual machines
  • 💾 Volume Management: Create, convert, import, and export disk images
  • 📸 Snapshot Support: Create and restore VM snapshots
  • 📦 Repository System: Save and load VM configurations (like Docker images)
  • 🔄 Format Conversion: Support for multiple disk formats (qcow2, raw, vmdk, vdi, vhdx)
  • KVM Acceleration: Automatic KVM support for better performance
  • 🎨 Intuitive Interface: Simple, memorable commands

Requirements

  • QEMU/KVM installed
    • qemu-system-x86_64
    • qemu-img
  • Bash 4.0+
  • Linux operating system

Installation on Debian/Ubuntu

sudo apt-get install qemu-system-x86 qemu-utils

Installation on Fedora/RHEL

sudo dnf install qemu-kvm qemu-img

Installation on Arch Linux

sudo pacman -S qemu

Installation

  1. Clone or download the repository
  2. Make the script executable:
    chmod +x easyqemu
    
  3. (Optional) Add to PATH:
    sudo ln -s $(pwd)/easyqemu /usr/local/bin/easyqemu
    
    Or add the directory to your PATH in ~/.bashrc:
    export PATH="$PATH:/path/to/easyqemu"
    

Quick Start

Create your first VM

# Create a VM with default settings (2GB RAM, 2 CPUs, 20GB disk)
easyqemu vm create --name myvm

# Create a VM with custom settings
easyqemu vm create --name ubuntu \
    --memory 4096 \
    --cpus 4 \
    --disk-size 50G \
    --cdrom /path/to/ubuntu.iso

Start the VM

# List all VMs to get the VM ID
easyqemu vm list

# Start the VM using its ID
easyqemu vm start myvm_1704672000

Manage VMs

# List all VMs
easyqemu vm list

# Show VM information
easyqemu vm info myvm_1704672000

# Modify VM settings
easyqemu vm modify myvm_1704672000 --memory 8192 --cpus 8

# Delete a VM
easyqemu vm delete myvm_1704672000

Commands

VM Management

Create VM

easyqemu vm create [OPTIONS]

Options:
  --name NAME           VM name (required)
  --memory MB           Memory in MB (default: 2048)
  --cpus N              Number of CPUs (default: 2)
  --disk PATH           Path to existing disk
  --disk-size SIZE      Size for new disk (default: 20G)
  --cdrom PATH          Path to ISO file
  --network TYPE        Network type (default: user)
  --display TYPE        Display type: gtk, sdl, none (default: gtk)
  --boot DEVICE         Boot device: cd, hd (default: cd)

List VMs

easyqemu vm list

Start VM

easyqemu vm start <vm_id>

Show VM Info

easyqemu vm info <vm_id>

Modify VM

easyqemu vm modify <vm_id> [OPTIONS]

Options:
  --name NAME           New VM name
  --memory MB           Memory in MB
  --cpus N              Number of CPUs
  --cdrom PATH          Path to ISO file
  --network TYPE        Network type
  --display TYPE        Display type
  --boot DEVICE         Boot device

Delete VM

easyqemu vm delete <vm_id> [-f|--force]

Volume Management

Create Volume

easyqemu volume create --name NAME --size SIZE [--format FORMAT]

Options:
  --name NAME           Volume name (required)
  --size SIZE           Volume size (e.g., 10G, 500M)
  --format FORMAT       Format: qcow2, raw, vmdk, vdi, vhdx (default: qcow2)

List Volumes

easyqemu volume list

Show Volume Info

easyqemu volume info <path>

Convert Volume

easyqemu volume convert --source PATH --target PATH --format FORMAT

Options:
  --source PATH         Source volume path (required)
  --target PATH         Target volume path (required)
  --format FORMAT       Target format (required)

Example:

# Convert raw to qcow2
easyqemu volume convert --source disk.raw --target disk.qcow2 --format qcow2

# Convert qcow2 to vmdk (for VMware)
easyqemu volume convert --source disk.qcow2 --target disk.vmdk --format vmdk

Import Volume

easyqemu volume import <source_path> [name]

Export Volume

easyqemu volume export <volume_name> <target_path>

Delete Volume

easyqemu volume delete <volume_name> [-f|--force]

Snapshot Management

Create Snapshot

easyqemu snapshot create <vm_id> [snapshot_name]

If no snapshot name is provided, it will be auto-generated with a timestamp.

List Snapshots

easyqemu snapshot list <vm_id>

Apply Snapshot

easyqemu snapshot apply <vm_id> <snapshot_name>

Delete Snapshot

easyqemu snapshot delete <vm_id> <snapshot_name>

Repository Management

The repository system allows you to save VM configurations and disks for later use, similar to Docker images.

Save VM to Repository

easyqemu repo save <vm_id> [repo_name]

Load VM from Repository

easyqemu repo load <repo_name> [new_name]

This creates a new VM instance from the saved configuration.

List Repository Entries

easyqemu repo list

Delete Repository Entry

easyqemu repo delete <repo_name> [-f|--force]

Examples

Example 1: Create and Run Ubuntu VM

# Download Ubuntu ISO (example)
wget https://releases.ubuntu.com/22.04/ubuntu-22.04.3-desktop-amd64.iso

# Create VM
easyqemu vm create \
    --name ubuntu-desktop \
    --memory 4096 \
    --cpus 4 \
    --disk-size 50G \
    --cdrom ubuntu-22.04.3-desktop-amd64.iso

# List VMs to get the ID
easyqemu vm list

# Start the VM
easyqemu vm start ubuntu-desktop_1704672000

# After installation, modify to boot from hard disk
easyqemu vm modify ubuntu-desktop_1704672000 --boot hd --cdrom ""

Example 2: Create a Snapshot Before Updates

# Create a snapshot before system updates
easyqemu snapshot create myvm_1704672000 before_update

# Start VM and perform updates
easyqemu vm start myvm_1704672000

# If something goes wrong, restore the snapshot
easyqemu snapshot apply myvm_1704672000 before_update

Example 3: Save and Clone a VM

# Save VM to repository
easyqemu repo save myvm_1704672000 my_base_vm

# Load it with a new name (creates a clone)
easyqemu repo load my_base_vm cloned_vm

# List to see the new VM
easyqemu vm list

Example 4: Convert Disk Formats

# Convert qcow2 to raw
easyqemu volume convert \
    --source ~/.easyqemu/volumes/myvm.qcow2 \
    --target ~/myvm.raw \
    --format raw

# Convert to VMDK for VMware
easyqemu volume convert \
    --source ~/.easyqemu/volumes/myvm.qcow2 \
    --target ~/myvm.vmdk \
    --format vmdk

# Convert to VDI for VirtualBox
easyqemu volume convert \
    --source ~/.easyqemu/volumes/myvm.qcow2 \
    --target ~/myvm.vdi \
    --format vdi

Example 5: Import Existing Disk

# Import an existing disk
easyqemu volume import /path/to/existing-disk.qcow2 imported-disk.qcow2

# Create a VM using the imported disk
easyqemu vm create \
    --name imported-vm \
    --disk ~/.easyqemu/volumes/imported-disk.qcow2 \
    --boot hd

Directory Structure

EasyQEMU stores all data in ~/.easyqemu/:

~/.easyqemu/
├── vms/              # VM runtime data
├── volumes/          # Disk images
├── configs/          # VM configurations (JSON)
├── repository/       # Saved VMs
├── locks/            # Lock files for running VMs
└── easyqemu.log      # Log file

Configuration

EasyQEMU can be configured via environment variables or by editing ~/.easyqemu/config:

# Custom home directory
export EASYQEMU_HOME="/path/to/custom/location"

# Default settings
export DEFAULT_MEMORY="4096"
export DEFAULT_CPUS="4"
export DEFAULT_DISK_SIZE="50G"

Network Modes

EasyQEMU supports different network modes:

  • user: Default, user-mode networking (NAT)
  • bridge: Bridge networking (requires setup)
  • tap: TAP device networking

Example with bridge:

easyqemu vm create --name myvm --network bridge,br0

Display Options

  • gtk: GTK window (default, best for desktop)
  • sdl: SDL window
  • vnc: VNC server (headless)
  • none: No display (serial console only)

Example with VNC:

easyqemu vm create --name myvm --display vnc=:1

Advanced Features

Custom QEMU Arguments

You can pass additional QEMU arguments when creating a VM:

easyqemu vm create \
    --name myvm \
    --memory 4096 \
    -- \
    -vga qxl \
    -device usb-tablet

USB Passthrough

easyqemu vm create \
    --name myvm \
    -- \
    -usb \
    -device usb-host,vendorid=0x1234,productid=0x5678

Troubleshooting

KVM Not Available

If you see errors about KVM:

  1. Check if KVM is enabled:

    lsmod | grep kvm
    
  2. Check if your CPU supports virtualization:

    egrep -c '(vmx|svm)' /proc/cpuinfo
    
  3. Add your user to the kvm group:

    sudo usermod -a -G kvm $USER
    

Permission Denied

If you get permission errors:

sudo chmod 666 /dev/kvm

Or add yourself to the kvm group (recommended):

sudo usermod -a -G kvm $USER
# Log out and log back in

VM Won't Start

  1. Check if the disk exists:

    easyqemu vm info <vm_id>
    
  2. Check disk integrity:

    easyqemu volume info <disk_path>
    
  3. Check available memory:

    free -h
    

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

MIT License - See LICENSE file for details

Credits

EasyQEMU is built on top of QEMU/KVM and provides a user-friendly interface for common VM management tasks.

Roadmap

  • Support for Windows VMs (UEFI boot)
  • Web UI dashboard
  • Remote VM management
  • Automated ISO downloads
  • Cloud-init integration
  • Network configuration wizard
  • Resource monitoring
  • Backup and restore
  • VM templates library

FAQ

Q: Can I use existing QEMU disk images?
A: Yes! Use easyqemu volume import to import existing disks.

Q: How do I access a VM without a display?
A: Use --display none and connect via SSH or serial console.

Q: Can I run multiple VMs simultaneously?
A: Yes, just start multiple VMs with different IDs.

Q: How do I increase disk size?
A: Use qemu-img resize directly:

qemu-img resize disk.qcow2 +10G

Q: Can I use this for production?
A: EasyQEMU is designed for development and testing. For production, consider enterprise solutions like libvirt/virt-manager.

See Also


EasyQEMU - Making QEMU management easy! 🚀