Skip to content

safiya2610/VirtPilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VirtPilot

VirtPilot is a CLI wrapper over libvirt that provides fast shortcuts for common VM workflows.

It helps you avoid repetitive virsh + manual disk/metadata steps by supporting:

  • VM creation from QCOW2/raw base images (using qemu-img)
  • Attach additional disks (qemu-img + libvirt device hotplug)
  • Basic VM lifecycle management (start/stop/delete/list/show)
  • SSH convenience helper
  • Optional cloud-init + first-boot customization

Requirements

  • libvirt (daemon + a usable system/session connection)
  • qemu-img
  • libguestfs-tools

Installation

$ make
$ sudo make install

After installing:

$ virtpilot -h

Connection

Most commands use the libvirt connection URI.

  • Default: qemu:///system
  • Flag: -c, --connect <uri>

Example:

$ virtpilot -c qemu:///system list

Quick Start

1) Create a VM from a base image

$ virtpilot create -i cirros.qcow2 simpleVM

2) Create a customized VM

$ virtpilot create \
  -i fedora-30-x86_64-kvm.qcow2 \
  --pool=vms \
  --first-boot=update.sh \
  --size=20 \
  --password='t0pS3cr3t' \
  --public-key=/home/me/.ssh/id_rsa.pub \
  --cpu=2 \
  --memory=4096 \
  rhel8-virtpilot

update.sh can be a simple script, for example:

#!/bin/bash

dnf clean all
dnf update -y
dnf install httpd
systemctl enable --now httpd

3) Add a disk

$ virtpilot add-disk <vm-name> <disk-size>

# Example:
$ virtpilot add-disk test-vm 10GB

Command Reference

Run virtpilot <command> --help for full flag details.

create <VM name>

Creates a new libvirt domain.

Required:

  • -i, --image <path-or-url> (backing image, required)

Common flags:

  • --format, -f <qcow2|raw> (default: qcow2)
  • --size, -s <GiB> (default: 10)
  • --pool, -p <pool-name> (default: default)
  • --cpu, -c <n> (default: 1)
  • --memory, -m <MiB> (default: 1024)
  • --nets <net1,net2,...> (default: default)
  • --cloud-init (enable cloud-init)
  • --password <root-password>
  • --ssh-user <user> (default: root)
  • --public-key <path> (default: $HOME/.ssh/id_rsa.pub)
  • --first-boot <script-path>

Example:

$ virtpilot create -i ubuntu.qcow2 --pool=vms --size=20 vm1

add-disk <vm> <disk-size>

Adds and attaches a disk to a VM.

  • --format, -f <qcow2|raw> (default: qcow2)
  • --bus, -b <virtio|...> (default: virtio)

Example:

$ virtpilot add-disk vm1 25GB --bus=virtio

list

Lists libvirt domains.

Supports -o/--output:

  • yaml
  • json
  • template (render a provided template)

Example:

$ virtpilot list
$ virtpilot list -o json

show <VM name>

Shows basic VM info (vCPUs, memory, and NIC IPs when available).

$ virtpilot show vm1

ssh <user>@<VM name>

Runs an SSH connection to a VM (helper around ssh).

Example:

$ virtpilot ssh root@vm1
$ virtpilot ssh vm1            # user part can be omitted
$ virtpilot ssh root@vm1 -o IdentitiesOnly=yes

start <VM...>

Starts one or more VMs.

$ virtpilot start vm1 vm2

stop <VM...>

Stops one or more VMs.

  • -f, --force uses a shutdown-style stop.
$ virtpilot stop vm1
$ virtpilot stop -f vm1

delete <VM...>

Deletes one or more VMs.

$ virtpilot delete vm1 vm2

completion [bash|zsh]

Generates shell completion.

Bash:

. <(virtpilot completion bash)

ZSH:

. <(virtpilot completion zsh)

Development

$ make test

About

A command-line utility built with Go to automate virtual machine lifecycle management using libvirt and QEMU.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors